From f861e6a269ba9f62700776d3cd13b644a9e836d4 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 20 Sep 2023 16:38:54 +0200 Subject: 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. --- src/components/organisms/toolbar/index.ts | 4 +++ .../organisms/toolbar/main-nav.stories.tsx | 2 +- src/components/organisms/toolbar/main-nav.test.tsx | 2 +- src/components/organisms/toolbar/main-nav.tsx | 31 +++++++++++----------- .../organisms/toolbar/search.stories.tsx | 2 +- src/components/organisms/toolbar/search.test.tsx | 2 +- src/components/organisms/toolbar/search.tsx | 19 ++++++------- .../organisms/toolbar/settings.stories.tsx | 2 +- src/components/organisms/toolbar/settings.test.tsx | 2 +- src/components/organisms/toolbar/settings.tsx | 20 +++++++------- .../organisms/toolbar/toolbar.stories.tsx | 2 +- src/components/organisms/toolbar/toolbar.test.tsx | 2 +- src/components/organisms/toolbar/toolbar.tsx | 25 ++++++++--------- 13 files changed, 58 insertions(+), 57 deletions(-) create mode 100644 src/components/organisms/toolbar/index.ts (limited to 'src/components/organisms/toolbar') diff --git a/src/components/organisms/toolbar/index.ts b/src/components/organisms/toolbar/index.ts new file mode 100644 index 0000000..9433412 --- /dev/null +++ b/src/components/organisms/toolbar/index.ts @@ -0,0 +1,4 @@ +export * from './main-nav'; +export * from './search'; +export * from './settings'; +export * from './toolbar'; diff --git a/src/components/organisms/toolbar/main-nav.stories.tsx b/src/components/organisms/toolbar/main-nav.stories.tsx index 7d6d915..1ef10b5 100644 --- a/src/components/organisms/toolbar/main-nav.stories.tsx +++ b/src/components/organisms/toolbar/main-nav.stories.tsx @@ -1,6 +1,6 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; import { useState } from 'react'; -import MainNav from './main-nav'; +import { MainNav } from './main-nav'; /** * MainNav - Storybook Meta diff --git a/src/components/organisms/toolbar/main-nav.test.tsx b/src/components/organisms/toolbar/main-nav.test.tsx index 47e7c38..12f30ce 100644 --- a/src/components/organisms/toolbar/main-nav.test.tsx +++ b/src/components/organisms/toolbar/main-nav.test.tsx @@ -1,5 +1,5 @@ import { render, screen } from '../../../../tests/utils'; -import MainNav from './main-nav'; +import { MainNav } from './main-nav'; const items = [ { id: 'home', label: 'Home', href: '/' }, 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 = ( +const MainNavWithRef: ForwardRefRenderFunction = ( { className = '', isActive, items, setIsActive }, ref ) => { @@ -62,20 +58,25 @@ const MainNav: ForwardRefRenderFunction = ( value="open" />