From ab5e5f4bdf40b5bc1ccf82dc1b4aca94d5171ec3 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Tue, 4 Jan 2022 13:07:15 +0100
Subject: refactor(sharing): avoid nested template literals

This improves readability. I also rename a variable to avoid duplicate
between global scope and useEffect scope.
---
 src/components/Buttons/Button/Button.tsx | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

(limited to 'src/components/Buttons/Button/Button.tsx')

diff --git a/src/components/Buttons/Button/Button.tsx b/src/components/Buttons/Button/Button.tsx
index 80acf8d..4d26ea4 100644
--- a/src/components/Buttons/Button/Button.tsx
+++ b/src/components/Buttons/Button/Button.tsx
@@ -15,11 +15,12 @@ const Button = ({
   isDisabled?: boolean;
   isPrimary?: boolean;
 }) => {
-  const classes = `${styles.btn} ${
-    isPrimary
-      ? `${styles.primary} ${styles[`primary--${position}`]}`
-      : `${styles.secondary} ${styles[`secondary--${position}`]}`
-  }`;
+  const primaryPosition = `primary--${position}`;
+  const secondaryPosition = `secondary--${position}`;
+  const typeStyles = isPrimary
+    ? `${styles.primary} ${styles[primaryPosition]}`
+    : `${styles.secondary} ${styles[secondaryPosition]}`;
+  const classes = `${styles.btn} ${typeStyles}`;
 
   return (
     <button
-- 
cgit v1.2.3

