-
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.
- serve static files via directory as per storybook docs - include story for slim logo only, other types to be added in future
- Loading branch information
Showing
5 changed files
with
116 additions
and
1 deletion.
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
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,44 @@ | ||
import React from 'react' | ||
|
||
import { Logo } from './Logo' | ||
|
||
export default { | ||
title: 'Logo', | ||
parameters: { | ||
info: ` | ||
Used within USWDS 2.0 Footer component | ||
Source: https://designsystem.digital.gov/components/form-controls/#footer | ||
`, | ||
}, | ||
} | ||
|
||
export const Slim = (): React.ReactElement => ( | ||
<div className="usa-footer__secondary-section"> | ||
<Logo | ||
slim | ||
image={ | ||
<img | ||
className="usa-footer__logo-img" | ||
src="/logo-img.png" | ||
alt="Mock logo" | ||
/> | ||
} | ||
heading={<h3 className="usa-footer__logo-heading">Name of Agency</h3>} | ||
/> | ||
</div> | ||
) | ||
|
||
export const NoHeading = (): React.ReactElement => ( | ||
<div className="usa-footer__secondary-section"> | ||
<Logo | ||
image={ | ||
<img | ||
className="usa-footer__logo-img" | ||
src="/logo-img.png" | ||
alt="Mock logo" | ||
/> | ||
} | ||
/> | ||
</div> | ||
) |
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,30 @@ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
|
||
import { Logo } from './Logo' | ||
|
||
const heading = <h3 className="usa-footer__logo-heading">Swoosh Branding</h3> | ||
const logoImage = ( | ||
<img | ||
className="usa-footer__logo-img" | ||
src="src/components/Footer/Logo/logo-img.png" | ||
alt="Nike logo" | ||
/> | ||
) | ||
|
||
describe('Logo component', () => { | ||
it('renders without errors', () => { | ||
const { queryByTestId } = render(<Logo image={logoImage} />) | ||
expect(queryByTestId('footerLogo')).toBeInTheDocument() | ||
}) | ||
|
||
it('renders logo image', () => { | ||
const { container } = render(<Logo image={logoImage} />) | ||
expect(container.querySelector('img')).toBeInTheDocument() | ||
}) | ||
|
||
it('renders heading when present', () => { | ||
const { getByText } = render(<Logo image={logoImage} heading={heading} />) | ||
expect(getByText('Swoosh Branding')).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,41 @@ | ||
import React from 'react' | ||
import classnames from 'classnames' | ||
|
||
type LogoProps = { | ||
big?: boolean | ||
medium?: boolean | ||
slim?: boolean | ||
heading?: React.ReactNode | ||
image: React.ReactNode | ||
} | ||
|
||
export const Logo = ({ | ||
big, | ||
medium, | ||
slim, | ||
heading, | ||
image, | ||
...elementAttributes | ||
}: LogoProps & React.HtmlHTMLAttributes<HTMLElement>): React.ReactElement => { | ||
const containerClasses = classnames( | ||
'usa-footer__logo grid-row', | ||
{ | ||
'mobile-lg:grid-col-6 mobile-lg:grid-gap-2': big || medium, | ||
'grid-gap-2': slim, | ||
}, | ||
elementAttributes.className | ||
) | ||
|
||
return ( | ||
<div className={containerClasses} data-testid="footerLogo"> | ||
{heading ? ( | ||
<> | ||
<div className="grid-col-auto">{image}</div> | ||
<div className="grid-col-auto">{heading}</div> | ||
</> | ||
) : ( | ||
<>{image}</> | ||
)} | ||
</div> | ||
) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.