-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add FooterNav, SocialLinks components * Add medium Footer story * Add medium styles to Logo, Address components
- Loading branch information
Showing
10 changed files
with
309 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,44 @@ | ||
import React from 'react' | ||
|
||
import classnames from 'classnames' | ||
type AddressProps = { | ||
big?: boolean | ||
medium?: boolean | ||
slim?: boolean | ||
/* | ||
Contact info items - e.g. anchor tags or text for email, phone, website, etc. | ||
*/ | ||
items: React.ReactNode[] | ||
} | ||
|
||
export const Address = ({ | ||
big, | ||
medium, | ||
slim, | ||
items, | ||
}: AddressProps & React.HTMLAttributes<HTMLElement>): React.ReactElement => ( | ||
<address className="usa-footer__address"> | ||
<div className="grid-row grid-gap"> | ||
{items.map((item, i) => ( | ||
<div | ||
className="grid-col-auto mobile-lg:grid-col-12 desktop:grid-col-auto" | ||
key={`addressItem-${i}`}> | ||
<div className="usa-footer__contact-info">{item}</div> | ||
}: AddressProps & React.HTMLAttributes<HTMLElement>): React.ReactElement => { | ||
const itemClasses = classnames({ | ||
'grid-col-auto': big || medium, | ||
'grid-col-auto mobile-lg:grid-col-12 desktop:grid-col-auto': slim, | ||
}) | ||
return ( | ||
<address className="usa-footer__address"> | ||
{slim ? ( | ||
<div className="grid-row grid-gap"> | ||
{items.map((item, i) => ( | ||
<div className={itemClasses} key={`addressItem-${i}`}> | ||
<div className="usa-footer__contact-info">{item}</div> | ||
</div> | ||
))} | ||
</div> | ||
) : ( | ||
<div className="usa-footer__contact-info grid-row grid-gap"> | ||
{items.map((item, i) => ( | ||
<div className={itemClasses} key={`addressItem-${i}`}> | ||
{item} | ||
</div> | ||
))} | ||
</div> | ||
))} | ||
</div> | ||
</address> | ||
) | ||
)} | ||
</address> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* eslint-disable jsx-a11y/anchor-is-valid */ | ||
import React from 'react' | ||
|
||
import { FooterNav } from './FooterNav' | ||
|
||
export default { | ||
title: 'FooterNav', | ||
parameters: { | ||
info: ` | ||
Used in USWDS 2.0 Footer component | ||
Source: https://designsystem.digital.gov/components/form-controls/#footer | ||
`, | ||
}, | ||
} | ||
|
||
export const SlimFooterNav = (): React.ReactElement => ( | ||
<FooterNav | ||
slim | ||
links={Array(4).fill( | ||
<a className="usa-footer__primary-link" href="#"> | ||
PrimaryLink | ||
</a> | ||
)} | ||
/> | ||
) | ||
|
||
export const MediumFooterNav = (): React.ReactElement => ( | ||
<FooterNav | ||
medium | ||
links={Array(4).fill( | ||
<a className="usa-footer__primary-link" href="#"> | ||
PrimaryLink | ||
</a> | ||
)} | ||
/> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* eslint-disable jsx-a11y/anchor-is-valid */ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
|
||
import { FooterNav } from './FooterNav' | ||
|
||
const links = Array(4).fill( | ||
<a className="usa-footer__primary-link" href="#"> | ||
Primary Link | ||
</a> | ||
) | ||
describe('FooterNav component', () => { | ||
it('renders without errors', () => { | ||
const { getByRole } = render(<FooterNav links={links} />) | ||
expect(getByRole('navigation')).toBeInTheDocument() | ||
}) | ||
|
||
it('renders links', () => { | ||
const { container, getAllByText } = render(<FooterNav links={links} />) | ||
expect(container.querySelectorAll('a').length).toBe(4) | ||
expect(getAllByText('Primary Link').length).toBe(4) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react' | ||
import classnames from 'classnames' | ||
|
||
type FooterNavProps = { | ||
big?: boolean | ||
medium?: boolean | ||
slim?: boolean | ||
links: React.ReactNode[] | ||
} | ||
|
||
export const FooterNav = ( | ||
props: FooterNavProps & React.HTMLAttributes<HTMLElement> | ||
): React.ReactElement => { | ||
const { medium, slim, links, ...elementAttributes } = props | ||
|
||
const navClasses = classnames(`usa-footer__nav`, elementAttributes.className) | ||
const listItemClasses = classnames( | ||
'desktop:grid-col-auto usa-footer__primary-content', | ||
{ | ||
'mobile-lg:grid-col-4': medium, | ||
'mobile-lg:grid-col-6': slim, | ||
} | ||
) | ||
|
||
return ( | ||
<nav className={navClasses} aria-label="Footer navigation"> | ||
<ul className="grid-row grid-gap"> | ||
{links.map((link, i) => ( | ||
<li key={`navLink-${i}`} className={listItemClasses}> | ||
{link} | ||
</li> | ||
))} | ||
</ul> | ||
</nav> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-disable jsx-a11y/anchor-is-valid */ | ||
import React from 'react' | ||
import { SocialLinks } from './SocialLinks' | ||
|
||
const links = [ | ||
<a | ||
key="facebook" | ||
className="usa-social-link usa-social-link--facebook" | ||
href="#"> | ||
<span>Facebook</span> | ||
</a>, | ||
<a | ||
key="twitter" | ||
className="usa-social-link usa-social-link--twitter" | ||
href="#"> | ||
<span>Twitter</span> | ||
</a>, | ||
<a | ||
key="youtube" | ||
className="usa-social-link usa-social-link--youtube" | ||
href="#"> | ||
<span>YouTube</span> | ||
</a>, | ||
<a key="rss" className="usa-social-link usa-social-link--rss" href="#"> | ||
<span>RSS</span> | ||
</a>, | ||
] | ||
export const Example = (): React.ReactElement => <SocialLinks links={links} /> |
Oops, something went wrong.