-
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.
- Loading branch information
Showing
5 changed files
with
103 additions
and
40 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 |
---|---|---|
@@ -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 => ( | ||
<Address | ||
items={[ | ||
<a key="phone" href="tel:123-456-7890"> | ||
(123) 456 - 7890 | ||
</a>, | ||
<a key="email" href="mailto:thisnotfake@emailaddress.com"> | ||
thisnotfake@emailaddress.com | ||
</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,26 @@ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
|
||
import { Address } from './Address' | ||
|
||
const addressItems = [ | ||
<a key="phone" href="tel:123-456-7890"> | ||
(123) 456 - 7890 | ||
</a>, | ||
<a key="email" href="mailto:thisnotfake@emailaddress.com"> | ||
thisnotfake@emailaddress.com | ||
</a>, | ||
] | ||
|
||
describe('Address component', () => { | ||
it('renders without errors', () => { | ||
const { container } = render(<Address items={addressItems} />) | ||
expect(container.querySelector('address')).toBeInTheDocument() | ||
}) | ||
|
||
it('renders address items', () => { | ||
const { getByText } = render(<Address items={addressItems} />) | ||
expect(getByText('(123)')).toBeInTheDocument() | ||
expect(getByText('thisnotfake@emailaddress.com')).toBeInTheDocument() | ||
}) | ||
}) |
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,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<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> | ||
</div> | ||
))} | ||
</div> | ||
</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