aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/atoms/layout/footer
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-09-27 18:43:25 +0200
committerArmand Philippot <git@armandphilippot.com>2023-10-24 12:25:00 +0200
commitd17d894f398650209c0ddd29502308de8c07bd93 (patch)
tree858402dfd362e74686d25fec155f247ad3217635 /src/components/atoms/layout/footer
parent7255d25f6834a208c0ed44636356cc260f6ab6ba (diff)
feat(components): add Article, Aside, Footer, Header, Main & Nav
Some components have been renamed to be able to create Footer, Header and Nav.
Diffstat (limited to 'src/components/atoms/layout/footer')
-rw-r--r--src/components/atoms/layout/footer/footer.stories.tsx34
-rw-r--r--src/components/atoms/layout/footer/footer.test.tsx13
-rw-r--r--src/components/atoms/layout/footer/footer.tsx23
-rw-r--r--src/components/atoms/layout/footer/index.ts1
4 files changed, 71 insertions, 0 deletions
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<typeof FooterComponent>;
+
+const Template: ComponentStory<typeof FooterComponent> = (args) => (
+ <FooterComponent {...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(<Footer>{children}</Footer>);
+
+ 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<HTMLElement> & {
+ /**
+ * The footer contents.
+ */
+ children: ReactNode;
+};
+
+const FooterWithRef: ForwardRefRenderFunction<HTMLElement, FooterProps> = (
+ props,
+ ref
+) => <footer {...props} ref={ref} />;
+
+/**
+ * Footer component.
+ */
+export const Footer = forwardRef(FooterWithRef);
diff --git a/src/components/atoms/layout/footer/index.ts b/src/components/atoms/layout/footer/index.ts
new file mode 100644
index 0000000..a058eae
--- /dev/null
+++ b/src/components/atoms/layout/footer/index.ts
@@ -0,0 +1 @@
+export * from './footer';