From d17d894f398650209c0ddd29502308de8c07bd93 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 27 Sep 2023 18:43:25 +0200 Subject: feat(components): add Article, Aside, Footer, Header, Main & Nav Some components have been renamed to be able to create Footer, Header and Nav. --- .../atoms/layout/footer/footer.stories.tsx | 34 ++++++++++++++++++++++ src/components/atoms/layout/footer/footer.test.tsx | 13 +++++++++ src/components/atoms/layout/footer/footer.tsx | 23 +++++++++++++++ src/components/atoms/layout/footer/index.ts | 1 + 4 files changed, 71 insertions(+) create mode 100644 src/components/atoms/layout/footer/footer.stories.tsx create mode 100644 src/components/atoms/layout/footer/footer.test.tsx create mode 100644 src/components/atoms/layout/footer/footer.tsx create mode 100644 src/components/atoms/layout/footer/index.ts (limited to 'src/components/atoms/layout/footer') diff --git a/src/components/atoms/layout/footer/footer.stories.tsx b/src/components/atoms/layout/footer/footer.stories.tsx new file mode 100644 index 0000000..0df1647 --- /dev/null +++ b/src/components/atoms/layout/footer/footer.stories.tsx @@ -0,0 +1,34 @@ +import type { ComponentMeta, ComponentStory } from '@storybook/react'; +import { Footer as FooterComponent } from './footer'; + +/** + * Footer - Storybook Meta + */ +export default { + title: 'Atoms/Layout', + component: FooterComponent, + argTypes: { + children: { + control: { + type: 'text', + }, + description: 'The contents.', + type: { + name: 'string', + required: true, + }, + }, + }, +} as ComponentMeta; + +const Template: ComponentStory = (args) => ( + +); + +/** + * Layout Stories - Footer + */ +export const Footer = Template.bind({}); +Footer.args = { + children: 'The footer content.', +}; diff --git a/src/components/atoms/layout/footer/footer.test.tsx b/src/components/atoms/layout/footer/footer.test.tsx new file mode 100644 index 0000000..15c6e6d --- /dev/null +++ b/src/components/atoms/layout/footer/footer.test.tsx @@ -0,0 +1,13 @@ +import { describe, expect, it } from '@jest/globals'; +import { render, screen as rtlScreen } from '@testing-library/react'; +import { Footer } from './footer'; + +describe('Footer', () => { + it('renders the contents of a footer', () => { + const children = 'The footer content.'; + + render(
{children}
); + + expect(rtlScreen.getByRole('contentinfo')).toHaveTextContent(children); + }); +}); diff --git a/src/components/atoms/layout/footer/footer.tsx b/src/components/atoms/layout/footer/footer.tsx new file mode 100644 index 0000000..deb3956 --- /dev/null +++ b/src/components/atoms/layout/footer/footer.tsx @@ -0,0 +1,23 @@ +import { + type ForwardRefRenderFunction, + type HTMLAttributes, + type ReactNode, + forwardRef, +} from 'react'; + +export type FooterProps = HTMLAttributes & { + /** + * The footer contents. + */ + children: ReactNode; +}; + +const FooterWithRef: ForwardRefRenderFunction = ( + props, + ref +) =>