diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-04 13:07:15 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-04 13:32:04 +0100 |
| commit | ab5e5f4bdf40b5bc1ccf82dc1b4aca94d5171ec3 (patch) | |
| tree | d5b26588c08cbc3aac1f281aa848e68c522eabcd /src/components/Buttons/Button | |
| parent | 1856796cef0989b10030906c9b1383d44800fb00 (diff) | |
refactor(sharing): avoid nested template literals
This improves readability. I also rename a variable to avoid duplicate
between global scope and useEffect scope.
Diffstat (limited to 'src/components/Buttons/Button')
| -rw-r--r-- | src/components/Buttons/Button/Button.tsx | 11 |
1 files changed, 6 insertions, 5 deletions
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 |
