From 49071813d625d7496414eddc09144986974890ac Mon Sep 17 00:00:00 2001 From: HANA Date: Tue, 5 May 2020 09:23:22 -0500 Subject: [PATCH] Add footer, slim footer story example (#107) * Add footer, slim footer story example * Add Logo, static file loading * Add Address --- package.json | 2 +- .../Footer/Address/Address.stories.tsx | 26 +++++ .../Footer/Address/Address.test.tsx | 26 +++++ src/components/Footer/Address/Address.tsx | 24 +++++ src/components/Footer/Footer.stories.tsx | 102 ++++++++++++++++++ src/components/Footer/Footer.test.tsx | 48 +++++++++ src/components/Footer/Footer.tsx | 56 ++++++++++ src/components/Footer/Logo/Logo.stories.tsx | 44 ++++++++ src/components/Footer/Logo/Logo.test.tsx | 30 ++++++ src/components/Footer/Logo/Logo.tsx | 37 +++++++ static/logo-img.png | Bin 0 -> 1022 bytes 11 files changed, 394 insertions(+), 1 deletion(-) create mode 100644 src/components/Footer/Address/Address.stories.tsx create mode 100644 src/components/Footer/Address/Address.test.tsx create mode 100644 src/components/Footer/Address/Address.tsx create mode 100644 src/components/Footer/Footer.stories.tsx create mode 100644 src/components/Footer/Footer.test.tsx create mode 100644 src/components/Footer/Footer.tsx create mode 100644 src/components/Footer/Logo/Logo.stories.tsx create mode 100644 src/components/Footer/Logo/Logo.test.tsx create mode 100644 src/components/Footer/Logo/Logo.tsx create mode 100644 static/logo-img.png diff --git a/package.json b/package.json index 79379c397b..0fceb8d7f0 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "test": "jest", "test:watch": "jest --watch", "test:coverage": "jest --coverage", - "storybook": "start-storybook", + "storybook": "start-storybook -s ./static -p 9001", "storybook:deploy": "storybook-to-ghpages", "build": "webpack", "build:watch": "webpack --watch", diff --git a/src/components/Footer/Address/Address.stories.tsx b/src/components/Footer/Address/Address.stories.tsx new file mode 100644 index 0000000000..19ad7d385a --- /dev/null +++ b/src/components/Footer/Address/Address.stories.tsx @@ -0,0 +1,26 @@ +import React from 'react' +import { Address } from './Address' + +export default { + title: 'Address', + parameters: { + info: ` + Used within USWDS 2.0 Footer component + + Source: https://designsystem.digital.gov/components/form-controls/#footer + `, + }, +} + +export const WithLinks = (): React.ReactElement => ( +
+ (123) 456 - 7890 + , + + thisnotfake@emailaddress.com + , + ]} + /> +) diff --git a/src/components/Footer/Address/Address.test.tsx b/src/components/Footer/Address/Address.test.tsx new file mode 100644 index 0000000000..b1cf52e925 --- /dev/null +++ b/src/components/Footer/Address/Address.test.tsx @@ -0,0 +1,26 @@ +import React from 'react' +import { render } from '@testing-library/react' + +import { Address } from './Address' + +const addressItems = [ + + (123) 456 - 7890 + , + + thisnotfake@emailaddress.com + , +] + +describe('Address component', () => { + it('renders without errors', () => { + const { container } = render(
) + expect(container.querySelector('address')).toBeInTheDocument() + }) + + it('renders address items', () => { + const { getByText } = render(
) + expect(getByText('(123) 456 - 7890')).toBeInTheDocument() + expect(getByText('thisnotfake@emailaddress.com')).toBeInTheDocument() + }) +}) diff --git a/src/components/Footer/Address/Address.tsx b/src/components/Footer/Address/Address.tsx new file mode 100644 index 0000000000..599f202f88 --- /dev/null +++ b/src/components/Footer/Address/Address.tsx @@ -0,0 +1,24 @@ +import React from 'react' + +type AddressProps = { + /* + Contact info items - e.g. anchor tags or text for email, phone, website, etc. + */ + items: React.ReactNode[] +} + +export const Address = ({ + items, +}: AddressProps & React.HTMLAttributes): React.ReactElement => ( +
+
+ {items.map((item, i) => ( +
+
{item}
+
+ ))} +
+
+) diff --git a/src/components/Footer/Footer.stories.tsx b/src/components/Footer/Footer.stories.tsx new file mode 100644 index 0000000000..abd9d67afe --- /dev/null +++ b/src/components/Footer/Footer.stories.tsx @@ -0,0 +1,102 @@ +/* eslint-disable jsx-a11y/anchor-is-valid */ +import React from 'react' +import classnames from 'classnames' + +import { Address } from './Address/Address' +import { Button } from '../Button/Button' +import { Footer } from './Footer' +import { Logo } from './Logo/Logo' + +export default { + title: 'Footer', + parameters: { + info: ` + USWDS 2.0 Footer component + + Source: https://designsystem.digital.gov/components/form-controls/#footer + `, + }, +} + +type SizeProps = { + big?: boolean + medium?: boolean + slim?: boolean +} + +// Placeholder until a dynamic Nav is built out and can be used +const MockNav = ({ medium, slim }: SizeProps): React.ReactElement => { + const itemClasses = classnames( + 'desktop:grid-col-auto usa-footer__primary-content', + { + 'mobile-lg:grid-col-4': medium, + 'mobile-lg:grid-col-6': slim, + } + ) + + const items = Array(4).fill({ + href: 'javascript:void(0);', + heading: 'Primary Link', + }) + + return ( + + ) +} + +const returnToTop = ( +
+ +
+) + +export const SlimFooter = (): React.ReactElement => ( +