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/atoms/icons/arrow.stories.tsx | 2 +- src/components/atoms/icons/arrow.test.tsx | 2 +- src/components/atoms/icons/arrow.tsx | 28 +++++++++------------- src/components/atoms/icons/career.stories.tsx | 2 +- src/components/atoms/icons/career.test.tsx | 2 +- src/components/atoms/icons/career.tsx | 21 ++++------------ src/components/atoms/icons/cc-by-sa.stories.tsx | 2 +- src/components/atoms/icons/cc-by-sa.test.tsx | 2 +- src/components/atoms/icons/cc-by-sa.tsx | 14 ++++------- src/components/atoms/icons/close.stories.tsx | 2 +- src/components/atoms/icons/close.test.tsx | 2 +- src/components/atoms/icons/close.tsx | 21 ++++------------ src/components/atoms/icons/cog.stories.tsx | 2 +- src/components/atoms/icons/cog.test.tsx | 2 +- src/components/atoms/icons/cog.tsx | 21 ++++------------ .../atoms/icons/computer-screen.stories.tsx | 2 +- .../atoms/icons/computer-screen.test.tsx | 2 +- src/components/atoms/icons/computer-screen.tsx | 21 ++++------------ src/components/atoms/icons/envelop.stories.tsx | 2 +- src/components/atoms/icons/envelop.test.tsx | 2 +- src/components/atoms/icons/envelop.tsx | 21 ++++------------ src/components/atoms/icons/feed.stories.tsx | 2 +- src/components/atoms/icons/feed.test.tsx | 2 +- src/components/atoms/icons/feed.tsx | 21 ++++------------ src/components/atoms/icons/hamburger.stories.tsx | 2 +- src/components/atoms/icons/hamburger.test.tsx | 2 +- src/components/atoms/icons/hamburger.tsx | 5 +--- src/components/atoms/icons/home.stories.tsx | 2 +- src/components/atoms/icons/home.test.tsx | 2 +- src/components/atoms/icons/home.tsx | 21 ++++------------ src/components/atoms/icons/index.ts | 15 ++++++++++++ .../atoms/icons/magnifying-glass.stories.tsx | 2 +- .../atoms/icons/magnifying-glass.test.tsx | 2 +- src/components/atoms/icons/magnifying-glass.tsx | 21 ++++------------ src/components/atoms/icons/moon.stories.tsx | 2 +- src/components/atoms/icons/moon.test.tsx | 2 +- src/components/atoms/icons/moon.tsx | 20 ++++------------ src/components/atoms/icons/plus-minus.stories.tsx | 2 +- src/components/atoms/icons/plus-minus.test.tsx | 2 +- src/components/atoms/icons/plus-minus.tsx | 8 +++---- src/components/atoms/icons/posts-stack.stories.tsx | 2 +- src/components/atoms/icons/posts-stack.test.tsx | 2 +- src/components/atoms/icons/posts-stack.tsx | 24 +++++++------------ src/components/atoms/icons/sun.stories.tsx | 2 +- src/components/atoms/icons/sun.test.tsx | 2 +- src/components/atoms/icons/sun.tsx | 18 ++++---------- 46 files changed, 121 insertions(+), 239 deletions(-) create mode 100644 src/components/atoms/icons/index.ts (limited to 'src/components/atoms/icons') diff --git a/src/components/atoms/icons/arrow.stories.tsx b/src/components/atoms/icons/arrow.stories.tsx index 9234886..a49be55 100644 --- a/src/components/atoms/icons/arrow.stories.tsx +++ b/src/components/atoms/icons/arrow.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import ArrowIcon from './arrow'; +import { Arrow as ArrowIcon } from './arrow'; /** * Arrow icon - Storybook Meta diff --git a/src/components/atoms/icons/arrow.test.tsx b/src/components/atoms/icons/arrow.test.tsx index 9985717..ed1d1e2 100644 --- a/src/components/atoms/icons/arrow.test.tsx +++ b/src/components/atoms/icons/arrow.test.tsx @@ -1,5 +1,5 @@ import { render } from '../../../../tests/utils'; -import Arrow from './arrow'; +import { Arrow } from './arrow'; describe('Arrow', () => { it('renders an arrow icon oriented to the right', () => { diff --git a/src/components/atoms/icons/arrow.tsx b/src/components/atoms/icons/arrow.tsx index 8aec5a1..2ef0185 100644 --- a/src/components/atoms/icons/arrow.tsx +++ b/src/components/atoms/icons/arrow.tsx @@ -1,17 +1,9 @@ -import { FC } from 'react'; +import { FC, SVGAttributes } from 'react'; import styles from './arrow.module.scss'; export type ArrowDirection = 'top' | 'right' | 'bottom' | 'left'; -export type ArrowProps = { - /** - * Should the svg be hidden from assistive technologies? - */ - 'aria-hidden'?: boolean; - /** - * Set additional classnames to the icon. - */ - className?: string; +export type ArrowProps = SVGAttributes & { /** * The arrow direction. Default: right. */ @@ -23,17 +15,21 @@ export type ArrowProps = { * * Render a svg arrow icon. */ -const Arrow: FC = ({ className = '', direction, ...props }) => { +export const Arrow: FC = ({ + className = '', + direction, + ...props +}) => { const directionClass = styles[`icon--${direction}`]; const classes = `${styles.icon} ${directionClass} ${className}`; if (direction === 'top') { return ( = ({ className = '', direction, ...props }) => { if (direction === 'bottom') { return ( = ({ className = '', direction, ...props }) => { if (direction === 'left') { return ( = ({ className = '', direction, ...props }) => { return ( = ({ className = '', direction, ...props }) => { ); }; - -export default Arrow; diff --git a/src/components/atoms/icons/career.stories.tsx b/src/components/atoms/icons/career.stories.tsx index 400ed21..5c3ae12 100644 --- a/src/components/atoms/icons/career.stories.tsx +++ b/src/components/atoms/icons/career.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import CareerIcon from './career'; +import { Career as CareerIcon } from './career'; /** * Career icon - Storybook Meta diff --git a/src/components/atoms/icons/career.test.tsx b/src/components/atoms/icons/career.test.tsx index 0c47262..7e53f6e 100644 --- a/src/components/atoms/icons/career.test.tsx +++ b/src/components/atoms/icons/career.test.tsx @@ -1,5 +1,5 @@ import { render } from '../../../../tests/utils'; -import Career from './career'; +import { Career } from './career'; describe('Career', () => { it('renders a Career icon', () => { diff --git a/src/components/atoms/icons/career.tsx b/src/components/atoms/icons/career.tsx index 009c2b4..6456d40 100644 --- a/src/components/atoms/icons/career.tsx +++ b/src/components/atoms/icons/career.tsx @@ -1,29 +1,20 @@ -import { FC } from 'react'; +import { FC, SVGAttributes } from 'react'; import styles from './career.module.scss'; -export type CareerProps = { - /** - * Should the svg be hidden from assistive technologies? - */ - 'aria-hidden'?: boolean; - /** - * Set additional classnames to the icon. - */ - className?: string; -}; +export type CareerProps = SVGAttributes; /** * Career Component * * Render a career svg icon. */ -const Career: FC = ({ className = '', ...props }) => { +export const Career: FC = ({ className = '', ...props }) => { return ( = ({ className = '', ...props }) => { ); }; - -export default Career; diff --git a/src/components/atoms/icons/cc-by-sa.stories.tsx b/src/components/atoms/icons/cc-by-sa.stories.tsx index 4229725..2a29ee3 100644 --- a/src/components/atoms/icons/cc-by-sa.stories.tsx +++ b/src/components/atoms/icons/cc-by-sa.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import CCBySAIcon from './cc-by-sa'; +import { CCBySA as CCBySAIcon } from './cc-by-sa'; /** * CC BY SA icon - Storybook Meta diff --git a/src/components/atoms/icons/cc-by-sa.test.tsx b/src/components/atoms/icons/cc-by-sa.test.tsx index 2bcb437..a23059d 100644 --- a/src/components/atoms/icons/cc-by-sa.test.tsx +++ b/src/components/atoms/icons/cc-by-sa.test.tsx @@ -1,5 +1,5 @@ import { render, screen } from '../../../../tests/utils'; -import CCBySA from './cc-by-sa'; +import { CCBySA } from './cc-by-sa'; describe('CCBySA', () => { it('renders a CC BY SA icon', () => { diff --git a/src/components/atoms/icons/cc-by-sa.tsx b/src/components/atoms/icons/cc-by-sa.tsx index 8239154..ba6d278 100644 --- a/src/components/atoms/icons/cc-by-sa.tsx +++ b/src/components/atoms/icons/cc-by-sa.tsx @@ -1,24 +1,20 @@ -import { FC } from 'react'; +import { FC, SVGAttributes } from 'react'; import { useIntl } from 'react-intl'; import styles from './cc-by-sa.module.scss'; -export type CCBySAProps = { - /** - * Set additional classnames to the icon. - */ - className?: string; -}; +export type CCBySAProps = SVGAttributes; /** * CCBySA component * * Render a CC BY SA svg icon. */ -const CCBySA: FC = ({ className = '' }) => { +export const CCBySA: FC = ({ className = '', ...props }) => { const intl = useIntl(); return ( = ({ className = '' }) => { ); }; - -export default CCBySA; diff --git a/src/components/atoms/icons/close.stories.tsx b/src/components/atoms/icons/close.stories.tsx index 05251c5..d075141 100644 --- a/src/components/atoms/icons/close.stories.tsx +++ b/src/components/atoms/icons/close.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import CloseIcon from './close'; +import { Close as CloseIcon } from './close'; /** * Close icon - Storybook Meta diff --git a/src/components/atoms/icons/close.test.tsx b/src/components/atoms/icons/close.test.tsx index dc82a2d..058b793 100644 --- a/src/components/atoms/icons/close.test.tsx +++ b/src/components/atoms/icons/close.test.tsx @@ -1,5 +1,5 @@ import { render } from '../../../../tests/utils'; -import Close from './close'; +import { Close } from './close'; describe('Close', () => { it('renders a Close icon', () => { diff --git a/src/components/atoms/icons/close.tsx b/src/components/atoms/icons/close.tsx index 14239a1..5db8620 100644 --- a/src/components/atoms/icons/close.tsx +++ b/src/components/atoms/icons/close.tsx @@ -1,29 +1,20 @@ -import { FC } from 'react'; +import { FC, SVGAttributes } from 'react'; import styles from './close.module.scss'; -export type CloseProps = { - /** - * Should the svg be hidden from assistive technologies? - */ - 'aria-hidden'?: boolean; - /** - * Set additional classnames to the icon. - */ - className?: string; -}; +export type CloseProps = SVGAttributes; /** * Close component * * Render a close svg icon. */ -const Close: FC = ({ className = '', ...props }) => { +export const Close: FC = ({ className = '', ...props }) => { return ( = ({ className = '', ...props }) => { ); }; - -export default Close; diff --git a/src/components/atoms/icons/cog.stories.tsx b/src/components/atoms/icons/cog.stories.tsx index 74228ca..1b6d440 100644 --- a/src/components/atoms/icons/cog.stories.tsx +++ b/src/components/atoms/icons/cog.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import CogIcon from './cog'; +import { Cog as CogIcon } from './cog'; /** * Cogs icon - Storybook Meta diff --git a/src/components/atoms/icons/cog.test.tsx b/src/components/atoms/icons/cog.test.tsx index 9d201b1..016ef15 100644 --- a/src/components/atoms/icons/cog.test.tsx +++ b/src/components/atoms/icons/cog.test.tsx @@ -1,5 +1,5 @@ import { render } from '../../../../tests/utils'; -import Cog from './cog'; +import { Cog } from './cog'; describe('Cog', () => { it('renders a Cog icon', () => { diff --git a/src/components/atoms/icons/cog.tsx b/src/components/atoms/icons/cog.tsx index 5431f9e..6e44708 100644 --- a/src/components/atoms/icons/cog.tsx +++ b/src/components/atoms/icons/cog.tsx @@ -1,34 +1,23 @@ -import { FC } from 'react'; +import { FC, SVGAttributes } from 'react'; import styles from './cog.module.scss'; -export type CogProps = { - /** - * Should the svg be hidden from assistive technologies? - */ - 'aria-hidden'?: boolean; - /** - * Set additional classnames to the icon. - */ - className?: string; -}; +export type CogProps = SVGAttributes; /** * Cog component * * Render a cog svg icon. */ -const Cog: FC = ({ className = '', ...props }) => { +export const Cog: FC = ({ className = '', ...props }) => { return ( ); }; - -export default Cog; diff --git a/src/components/atoms/icons/computer-screen.stories.tsx b/src/components/atoms/icons/computer-screen.stories.tsx index ad457a9..d4b257b 100644 --- a/src/components/atoms/icons/computer-screen.stories.tsx +++ b/src/components/atoms/icons/computer-screen.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import ComputerScreenIcon from './computer-screen'; +import { ComputerScreen as ComputerScreenIcon } from './computer-screen'; /** * Computer Screen icon - Storybook Meta diff --git a/src/components/atoms/icons/computer-screen.test.tsx b/src/components/atoms/icons/computer-screen.test.tsx index baa2c78..d74933a 100644 --- a/src/components/atoms/icons/computer-screen.test.tsx +++ b/src/components/atoms/icons/computer-screen.test.tsx @@ -1,5 +1,5 @@ import { render } from '../../../../tests/utils'; -import ComputerScreen from './computer-screen'; +import { ComputerScreen } from './computer-screen'; describe('ComputerScreen', () => { it('renders a computer screen icon', () => { diff --git a/src/components/atoms/icons/computer-screen.tsx b/src/components/atoms/icons/computer-screen.tsx index 9293316..32f41a0 100644 --- a/src/components/atoms/icons/computer-screen.tsx +++ b/src/components/atoms/icons/computer-screen.tsx @@ -1,32 +1,23 @@ -import { FC } from 'react'; +import { FC, SVGAttributes } from 'react'; import styles from './computer-screen.module.scss'; -export type ComputerScreenProps = { - /** - * Should the svg be hidden from assistive technologies? - */ - 'aria-hidden'?: boolean; - /** - * Set additional classnames to the icon. - */ - className?: string; -}; +export type ComputerScreenProps = SVGAttributes; /** * ComputerScreen component * * Render a computer screen svg icon. */ -const ComputerScreen: FC = ({ +export const ComputerScreen: FC = ({ className = '', ...props }) => { return ( = ({ ); }; - -export default ComputerScreen; diff --git a/src/components/atoms/icons/envelop.stories.tsx b/src/components/atoms/icons/envelop.stories.tsx index 3d24d2e..666cd86 100644 --- a/src/components/atoms/icons/envelop.stories.tsx +++ b/src/components/atoms/icons/envelop.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import EnvelopIcon from './envelop'; +import { Envelop as EnvelopIcon } from './envelop'; /** * Envelop icon - Storybook Meta diff --git a/src/components/atoms/icons/envelop.test.tsx b/src/components/atoms/icons/envelop.test.tsx index c040134..1829fe2 100644 --- a/src/components/atoms/icons/envelop.test.tsx +++ b/src/components/atoms/icons/envelop.test.tsx @@ -1,5 +1,5 @@ import { render } from '../../../../tests/utils'; -import Envelop from './envelop'; +import { Envelop } from './envelop'; describe('Envelop', () => { it('renders an envelop icon', () => { diff --git a/src/components/atoms/icons/envelop.tsx b/src/components/atoms/icons/envelop.tsx index 99a003b..968c51f 100644 --- a/src/components/atoms/icons/envelop.tsx +++ b/src/components/atoms/icons/envelop.tsx @@ -1,29 +1,20 @@ -import { FC } from 'react'; +import { FC, SVGAttributes } from 'react'; import styles from './envelop.module.scss'; -export type EnvelopProps = { - /** - * Should the svg be hidden from assistive technologies? - */ - 'aria-hidden'?: boolean; - /** - * Set additional classnames to the icon. - */ - className?: string; -}; +export type EnvelopProps = SVGAttributes; /** * Envelop Component * * Render an envelop svg icon. */ -const Envelop: FC = ({ className = '', ...props }) => { +export const Envelop: FC = ({ className = '', ...props }) => { return ( = ({ className = '', ...props }) => { ); }; - -export default Envelop; diff --git a/src/components/atoms/icons/feed.stories.tsx b/src/components/atoms/icons/feed.stories.tsx index 5e4615f..1a297e9 100644 --- a/src/components/atoms/icons/feed.stories.tsx +++ b/src/components/atoms/icons/feed.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import FeedIcon from './feed'; +import { Feed as FeedIcon } from './feed'; /** * Feed icon - Storybook Meta diff --git a/src/components/atoms/icons/feed.test.tsx b/src/components/atoms/icons/feed.test.tsx index 630089d..ca6f331 100644 --- a/src/components/atoms/icons/feed.test.tsx +++ b/src/components/atoms/icons/feed.test.tsx @@ -1,5 +1,5 @@ import { render } from '../../../../tests/utils'; -import Feed from './feed'; +import { Feed } from './feed'; describe('Feed', () => { it('renders a feed icon', () => { diff --git a/src/components/atoms/icons/feed.tsx b/src/components/atoms/icons/feed.tsx index 4428eb9..40b3156 100644 --- a/src/components/atoms/icons/feed.tsx +++ b/src/components/atoms/icons/feed.tsx @@ -1,29 +1,20 @@ -import { FC } from 'react'; +import { FC, SVGAttributes } from 'react'; import styles from './feed.module.scss'; -export type FeedProps = { - /** - * Should the svg be hidden from assistive technologies? - */ - 'aria-hidden'?: boolean; - /** - * Set additional classnames to the icon. - */ - className?: string; -}; +export type FeedProps = SVGAttributes; /** * Feed Component * * Render a feed svg icon. */ -const Feed: FC = ({ className = '', ...props }) => { +export const Feed: FC = ({ className = '', ...props }) => { return ( @@ -75,5 +66,3 @@ const Feed: FC = ({ className = '', ...props }) => { ); }; - -export default Feed; diff --git a/src/components/atoms/icons/hamburger.stories.tsx b/src/components/atoms/icons/hamburger.stories.tsx index 0a8a8cc..b2416c6 100644 --- a/src/components/atoms/icons/hamburger.stories.tsx +++ b/src/components/atoms/icons/hamburger.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import HamburgerIcon from './hamburger'; +import { Hamburger as HamburgerIcon } from './hamburger'; /** * Hamburger icon - Storybook Meta diff --git a/src/components/atoms/icons/hamburger.test.tsx b/src/components/atoms/icons/hamburger.test.tsx index 4f6a457..b208a42 100644 --- a/src/components/atoms/icons/hamburger.test.tsx +++ b/src/components/atoms/icons/hamburger.test.tsx @@ -1,5 +1,5 @@ import { render } from '../../../../tests/utils'; -import Hamburger from './hamburger'; +import { Hamburger } from './hamburger'; describe('Hamburger', () => { it('renders a Hamburger icon', () => { diff --git a/src/components/atoms/icons/hamburger.tsx b/src/components/atoms/icons/hamburger.tsx index 93aed2a..cc4e7b9 100644 --- a/src/components/atoms/icons/hamburger.tsx +++ b/src/components/atoms/icons/hamburger.tsx @@ -6,7 +6,6 @@ export type HamburgerProps = { * Set additional classnames to the icon wrapper. */ className?: string; - /** * Set additional classnames to the icon. */ @@ -18,7 +17,7 @@ export type HamburgerProps = { * * Render a Hamburger icon. */ -const Hamburger: FC = ({ +export const Hamburger: FC = ({ className = '', iconClassName = '', }) => { @@ -28,5 +27,3 @@ const Hamburger: FC = ({ ); }; - -export default Hamburger; diff --git a/src/components/atoms/icons/home.stories.tsx b/src/components/atoms/icons/home.stories.tsx index 90650fc..7492af7 100644 --- a/src/components/atoms/icons/home.stories.tsx +++ b/src/components/atoms/icons/home.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import HomeIcon from './home'; +import { Home as HomeIcon } from './home'; /** * Home icon - Storybook Meta diff --git a/src/components/atoms/icons/home.test.tsx b/src/components/atoms/icons/home.test.tsx index 0473d0b..2fbe42f 100644 --- a/src/components/atoms/icons/home.test.tsx +++ b/src/components/atoms/icons/home.test.tsx @@ -1,5 +1,5 @@ import { render } from '../../../../tests/utils'; -import Home from './home'; +import { Home } from './home'; describe('Home', () => { it('renders a home icon', () => { diff --git a/src/components/atoms/icons/home.tsx b/src/components/atoms/icons/home.tsx index dd39b15..0081f37 100644 --- a/src/components/atoms/icons/home.tsx +++ b/src/components/atoms/icons/home.tsx @@ -1,29 +1,20 @@ -import { FC } from 'react'; +import { FC, SVGAttributes } from 'react'; import styles from './home.module.scss'; -export type HomeProps = { - /** - * Should the svg be hidden from assistive technologies? - */ - 'aria-hidden'?: boolean; - /** - * Set additional classnames to the icon. - */ - className?: string; -}; +export type HomeProps = SVGAttributes; /** * Home component. * * Render a home svg icon. */ -const Home: FC = ({ className = '', ...props }) => { +export const Home: FC = ({ className = '', ...props }) => { return ( = ({ className = '', ...props }) => { ); }; - -export default Home; diff --git a/src/components/atoms/icons/index.ts b/src/components/atoms/icons/index.ts new file mode 100644 index 0000000..1b413ba --- /dev/null +++ b/src/components/atoms/icons/index.ts @@ -0,0 +1,15 @@ +export * from './arrow'; +export * from './career'; +export * from './cc-by-sa'; +export * from './close'; +export * from './cog'; +export * from './computer-screen'; +export * from './envelop'; +export * from './feed'; +export * from './hamburger'; +export * from './home'; +export * from './magnifying-glass'; +export * from './moon'; +export * from './plus-minus'; +export * from './posts-stack'; +export * from './sun'; diff --git a/src/components/atoms/icons/magnifying-glass.stories.tsx b/src/components/atoms/icons/magnifying-glass.stories.tsx index 0715a11..7dec505 100644 --- a/src/components/atoms/icons/magnifying-glass.stories.tsx +++ b/src/components/atoms/icons/magnifying-glass.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import MagnifyingGlassIcon from './magnifying-glass'; +import { MagnifyingGlass as MagnifyingGlassIcon } from './magnifying-glass'; /** * Magnifying Glass icon - Storybook Meta diff --git a/src/components/atoms/icons/magnifying-glass.test.tsx b/src/components/atoms/icons/magnifying-glass.test.tsx index c6ddb18..4e2f449 100644 --- a/src/components/atoms/icons/magnifying-glass.test.tsx +++ b/src/components/atoms/icons/magnifying-glass.test.tsx @@ -1,5 +1,5 @@ import { render } from '../../../../tests/utils'; -import MagnifyingGlass from './magnifying-glass'; +import { MagnifyingGlass } from './magnifying-glass'; describe('MagnifyingGlass', () => { it('renders a magnifying glass icon', () => { diff --git a/src/components/atoms/icons/magnifying-glass.tsx b/src/components/atoms/icons/magnifying-glass.tsx index ad8da39..619adef 100644 --- a/src/components/atoms/icons/magnifying-glass.tsx +++ b/src/components/atoms/icons/magnifying-glass.tsx @@ -1,32 +1,23 @@ -import { FC } from 'react'; +import { FC, SVGAttributes } from 'react'; import styles from './magnifying-glass.module.scss'; -export type MagnifyingGlassProps = { - /** - * Should the svg be hidden from assistive technologies? - */ - 'aria-hidden'?: boolean; - /** - * Set additional classnames to the icon. - */ - className?: string; -}; +export type MagnifyingGlassProps = SVGAttributes; /** * MagnifyingGlass component * * Render a magnifying glass svg icon. */ -const MagnifyingGlass: FC = ({ +export const MagnifyingGlass: FC = ({ className = '', ...props }) => { return ( = ({ ); }; - -export default MagnifyingGlass; diff --git a/src/components/atoms/icons/moon.stories.tsx b/src/components/atoms/icons/moon.stories.tsx index 9584e47..a8faf03 100644 --- a/src/components/atoms/icons/moon.stories.tsx +++ b/src/components/atoms/icons/moon.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import MoonIcon from './moon'; +import { Moon as MoonIcon } from './moon'; /** * Moon icon - Storybook Meta diff --git a/src/components/atoms/icons/moon.test.tsx b/src/components/atoms/icons/moon.test.tsx index 09415a9..3c1021a 100644 --- a/src/components/atoms/icons/moon.test.tsx +++ b/src/components/atoms/icons/moon.test.tsx @@ -1,5 +1,5 @@ import { render } from '../../../../tests/utils'; -import Moon from './moon'; +import { Moon } from './moon'; describe('Moon', () => { it('renders a moon icon', () => { diff --git a/src/components/atoms/icons/moon.tsx b/src/components/atoms/icons/moon.tsx index d04605a..2139ce1 100644 --- a/src/components/atoms/icons/moon.tsx +++ b/src/components/atoms/icons/moon.tsx @@ -1,33 +1,23 @@ -import { FC } from 'react'; +import { FC, SVGAttributes } from 'react'; import styles from './moon.module.scss'; -export type MoonProps = { - /** - * Should the svg be hidden from assistive technologies? - */ - 'aria-hidden'?: boolean; - /** - * Set additional classnames to the icon. - */ - className?: string; +export type MoonProps = SVGAttributes & { /** * The SVG title. */ title?: string; }; -const Moon: FC = ({ className = '', title, ...props }) => { +export const Moon: FC = ({ className = '', title, ...props }) => { return ( - {title !== 'undefined' && {title}} + {title ? {title} : null} ); }; - -export default Moon; diff --git a/src/components/atoms/icons/plus-minus.stories.tsx b/src/components/atoms/icons/plus-minus.stories.tsx index eebf1e5..c556076 100644 --- a/src/components/atoms/icons/plus-minus.stories.tsx +++ b/src/components/atoms/icons/plus-minus.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import PlusMinusIcon from './plus-minus'; +import { PlusMinus as PlusMinusIcon } from './plus-minus'; /** * Plus/Minus icon - Storybook Meta diff --git a/src/components/atoms/icons/plus-minus.test.tsx b/src/components/atoms/icons/plus-minus.test.tsx index 5105403..174f8e1 100644 --- a/src/components/atoms/icons/plus-minus.test.tsx +++ b/src/components/atoms/icons/plus-minus.test.tsx @@ -1,5 +1,5 @@ import { render } from '../../../../tests/utils'; -import PlusMinus from './plus-minus'; +import { PlusMinus } from './plus-minus'; describe('PlusMinus', () => { it('renders a plus/minus icon', () => { diff --git a/src/components/atoms/icons/plus-minus.tsx b/src/components/atoms/icons/plus-minus.tsx index e8897b7..e2eb55e 100644 --- a/src/components/atoms/icons/plus-minus.tsx +++ b/src/components/atoms/icons/plus-minus.tsx @@ -17,15 +17,13 @@ export type PlusMinusProps = { * * Render a plus or a minus icon. */ -const PlusMinus: FC = ({ className, state }) => { +export const PlusMinus: FC = ({ className = '', state }) => { const stateClass = `icon--${state}`; return (
+ className={`${styles.icon} ${styles[stateClass]} ${className}`} + /> ); }; - -export default PlusMinus; diff --git a/src/components/atoms/icons/posts-stack.stories.tsx b/src/components/atoms/icons/posts-stack.stories.tsx index f11b13b..7daeecf 100644 --- a/src/components/atoms/icons/posts-stack.stories.tsx +++ b/src/components/atoms/icons/posts-stack.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import PostsStackIcon from './posts-stack'; +import { PostsStack as PostsStackIcon } from './posts-stack'; /** * Posts Stack icon - Storybook Meta diff --git a/src/components/atoms/icons/posts-stack.test.tsx b/src/components/atoms/icons/posts-stack.test.tsx index 65e0d3b..3728d1e 100644 --- a/src/components/atoms/icons/posts-stack.test.tsx +++ b/src/components/atoms/icons/posts-stack.test.tsx @@ -1,5 +1,5 @@ import { render } from '../../../../tests/utils'; -import PostsStack from './posts-stack'; +import { PostsStack } from './posts-stack'; describe('PostsStack', () => { it('renders a posts stack icon', () => { diff --git a/src/components/atoms/icons/posts-stack.tsx b/src/components/atoms/icons/posts-stack.tsx index af070de..c783892 100644 --- a/src/components/atoms/icons/posts-stack.tsx +++ b/src/components/atoms/icons/posts-stack.tsx @@ -1,29 +1,23 @@ -import { FC } from 'react'; +import { FC, SVGAttributes } from 'react'; import styles from './posts-stack.module.scss'; -export type PostsStackProps = { - /** - * Should the svg be hidden from assistive technologies? - */ - 'aria-hidden'?: boolean; - /** - * Set additional classnames to the icon. - */ - className?: string; -}; +export type PostsStackProps = SVGAttributes; /** * Posts stack component. * * Render a posts stack svg icon. */ -const PostsStack: FC = ({ className = '', ...props }) => { +export const PostsStack: FC = ({ + className = '', + ...props +}) => { return ( = ({ className = '', ...props }) => { ); }; - -export default PostsStack; diff --git a/src/components/atoms/icons/sun.stories.tsx b/src/components/atoms/icons/sun.stories.tsx index dabda66..a332bcd 100644 --- a/src/components/atoms/icons/sun.stories.tsx +++ b/src/components/atoms/icons/sun.stories.tsx @@ -1,5 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import SunIcon from './sun'; +import { Sun as SunIcon } from './sun'; /** * Sun icon - Storybook Meta diff --git a/src/components/atoms/icons/sun.test.tsx b/src/components/atoms/icons/sun.test.tsx index af52a5f..8a43221 100644 --- a/src/components/atoms/icons/sun.test.tsx +++ b/src/components/atoms/icons/sun.test.tsx @@ -1,5 +1,5 @@ import { render } from '../../../../tests/utils'; -import Sun from './sun'; +import { Sun } from './sun'; describe('Sun', () => { it('renders a sun icon', () => { diff --git a/src/components/atoms/icons/sun.tsx b/src/components/atoms/icons/sun.tsx index 1d29ff4..69a3044 100644 --- a/src/components/atoms/icons/sun.tsx +++ b/src/components/atoms/icons/sun.tsx @@ -1,15 +1,7 @@ -import { FC } from 'react'; +import { FC, SVGAttributes } from 'react'; import styles from './sun.module.scss'; -export type SunProps = { - /** - * Should the svg be hidden from assistive technologies? - */ - 'aria-hidden'?: boolean; - /** - * Set additional classnames to the icon. - */ - className?: string; +export type SunProps = SVGAttributes & { /** * The SVG title. */ @@ -21,18 +13,16 @@ export type SunProps = { * * Render a svg sun icon. */ -const Sun: FC = ({ className = '', title, ...props }) => { +export const Sun: FC = ({ className = '', title, ...props }) => { return ( {title !== 'undefined' && {title}} ); }; - -export default Sun; -- cgit v1.2.3