From 7255d25f6834a208c0ed44636356cc260f6ab6ba Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 27 Sep 2023 17:38:23 +0200 Subject: refactor(components): rewrite Heading component * remove `alignment` and `withMargin` props (consumer should handle that) * move styles to Sass placeholders to avoid repeats with headings coming from WordPress * refactor some other components that depend on Heading to avoid ESlint errors --- .../molecules/buttons/heading-button.tsx | 17 +++++---- src/components/molecules/layout/branding.tsx | 15 +++----- src/components/molecules/layout/card.module.scss | 5 ++- src/components/molecules/layout/card.tsx | 8 +---- src/components/molecules/layout/page-header.tsx | 41 +++++++++++++--------- 5 files changed, 41 insertions(+), 45 deletions(-) (limited to 'src/components/molecules') diff --git a/src/components/molecules/buttons/heading-button.tsx b/src/components/molecules/buttons/heading-button.tsx index 93ccdbe..97e2c84 100644 --- a/src/components/molecules/buttons/heading-button.tsx +++ b/src/components/molecules/buttons/heading-button.tsx @@ -1,4 +1,4 @@ -import { FC, SetStateAction } from 'react'; +import { useCallback, type FC, type SetStateAction } from 'react'; import { useIntl } from 'react-intl'; import { Heading, type HeadingProps, PlusMinus } from '../../atoms'; import styles from './heading-button.module.scss'; @@ -35,6 +35,7 @@ export const HeadingButton: FC = ({ title, }) => { const intl = useIntl(); + const btnClass = `${styles.wrapper} ${className}`; const iconState = expanded ? 'minus' : 'plus'; const titlePrefix = expanded ? intl.formatMessage({ @@ -48,13 +49,15 @@ export const HeadingButton: FC = ({ id: 'bcyOgC', }); + const toggleExpand = useCallback( + () => setExpanded((prev) => !prev), + [setExpanded] + ); + return ( -