Skip to content

Commit

Permalink
fix: update gov banner to uswds version 2.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eamahanna authored May 22, 2020
1 parent 85a1780 commit c5bd62c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/components/GovBanner/GovBanner.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ import { GovBanner } from './GovBanner'

export default { title: 'GovBanner', component: GovBanner }

export const govBanner = (): React.ReactElement => <GovBanner />
export const govBanner = (): React.ReactElement => (
<GovBanner aria-label="Official government website" />
)
7 changes: 7 additions & 0 deletions src/components/GovBanner/GovBanner.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@ describe('GovBanner component', () => {
const { queryByTestId } = render(<GovBanner />)
expect(queryByTestId('govBanner')).toBeInTheDocument()
})

it('renders section attributes passed in through props', () => {
const { queryByTestId } = render(
<GovBanner aria-label="Official government website" />
)
expect(queryByTestId('govBanner')).toHaveAttribute('aria-label')
})
})
12 changes: 9 additions & 3 deletions src/components/GovBanner/GovBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import React, { useState } from 'react'
import classnames from 'classnames'

// assets
import flagImg from 'uswds/src/img/us_flag_small.png'
import dotGovIcon from 'uswds/src/img/icon-dot-gov.svg'
import httpsIcon from 'uswds/src/img/icon-https.svg'

export const GovBanner = (): React.ReactElement => {
export const GovBanner = (
props: React.HTMLAttributes<HTMLElement>
): React.ReactElement => {
const { className, ...sectionProps } = props
const [isOpen, setOpenState] = useState(false)

const classes = classnames('usa-banner', className)

return (
<div className="usa-banner" data-testid="govBanner">
<section className={classes} data-testid="govBanner" {...sectionProps}>
<div className="usa-accordion">
<header className="usa-banner__header">
<div className="usa-banner__inner">
Expand Down Expand Up @@ -82,7 +88,7 @@ export const GovBanner = (): React.ReactElement => {
</div>
</div>
</div>
</div>
</section>
)
}

Expand Down

0 comments on commit c5bd62c

Please sign in to comment.