From ab5e5f4bdf40b5bc1ccf82dc1b4aca94d5171ec3 Mon Sep 17 00:00:00 2001 From: Armand Philippot 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 ++++++----- src/components/Buttons/ButtonLink/ButtonLink.tsx | 6 +++--- src/components/Form/Form.tsx | 6 ++---- src/components/Icons/Hamburger/Hamburger.tsx | 11 ++++------- src/components/Notice/Notice.tsx | 4 +++- src/components/Sharing/Sharing.tsx | 19 +++++++++++-------- src/pages/contact.tsx | 3 ++- 7 files changed, 31 insertions(+), 29 deletions(-) (limited to 'src') 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 (