diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
| commit | f861e6a269ba9f62700776d3cd13b644a9e836d4 (patch) | |
| tree | a5a107e7a6e4ff8b4261fe04349357bc00b783ee /src/components/organisms/toolbar/main-nav.tsx | |
| parent | 03331c44276ec56e9f235e4d5ee75030455a753f (diff) | |
refactor: use named export for everything except pages
Next expect a default export for pages so only those components should
use default exports. Everything else should use named exports to
reduce the number of import statements.
Diffstat (limited to 'src/components/organisms/toolbar/main-nav.tsx')
| -rw-r--r-- | src/components/organisms/toolbar/main-nav.tsx | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/components/organisms/toolbar/main-nav.tsx b/src/components/organisms/toolbar/main-nav.tsx index 3a2fbf5..cf49bd4 100644 --- a/src/components/organisms/toolbar/main-nav.tsx +++ b/src/components/organisms/toolbar/main-nav.tsx @@ -1,11 +1,12 @@ import { forwardRef, ForwardRefRenderFunction } from 'react'; import { useIntl } from 'react-intl'; -import BooleanField, { +import { + BooleanField, type BooleanFieldProps, -} from '../../atoms/forms/boolean-field'; -import Label from '../../atoms/forms/label'; -import Hamburger from '../../atoms/icons/hamburger'; -import Nav, { type NavProps, type NavItem } from '../../molecules/nav/nav'; + Hamburger, + Label, +} from '../../atoms'; +import { Nav, type NavProps, type NavItem } from '../../molecules'; import mainNavStyles from './main-nav.module.scss'; import sharedStyles from './toolbar-items.module.scss'; @@ -28,12 +29,7 @@ export type MainNavProps = { setIsActive: BooleanFieldProps['onChange']; }; -/** - * MainNav component - * - * Render the main navigation. - */ -const MainNav: ForwardRefRenderFunction<HTMLDivElement, MainNavProps> = ( +const MainNavWithRef: ForwardRefRenderFunction<HTMLDivElement, MainNavProps> = ( { className = '', isActive, items, setIsActive }, ref ) => { @@ -62,20 +58,25 @@ const MainNav: ForwardRefRenderFunction<HTMLDivElement, MainNavProps> = ( value="open" /> <Label - htmlFor="main-nav-button" aria-label={label} className={`${sharedStyles.label} ${mainNavStyles.label}`} + htmlFor="main-nav-button" > <Hamburger iconClassName={mainNavStyles.icon} /> </Label> <Nav - kind="main" - items={items} className={`${sharedStyles.modal} ${mainNavStyles.modal} ${className}`} + items={items} + kind="main" listClassName={mainNavStyles.modal__list} /> </div> ); }; -export default forwardRef(MainNav); +/** + * MainNav component + * + * Render the main navigation. + */ +export const MainNav = forwardRef(MainNavWithRef); |
