-
Notifications
You must be signed in to change notification settings - Fork 90
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
Suzanne Rozier
committed
Apr 24, 2020
1 parent
da573fd
commit db15b39
Showing
8 changed files
with
137 additions
and
2 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,8 +1,10 @@ | ||
{ | ||
"plugins": ["stylelint-prettier"], | ||
"plugins": ["stylelint-scss", "stylelint-prettier"], | ||
"rules": { | ||
"at-rule-no-unknown": null, | ||
"scss/at-rule-no-unknown": true, | ||
"prettier/prettier": true, | ||
"selector-class-pattern": "" | ||
}, | ||
"extends": ["stylelint-config-recommended", "stylelint-prettier/recommended", "stylelint-config-sass-guidelines"], | ||
"extends": ["stylelint-config-recommended", "stylelint-prettier/recommended", "stylelint-config-sass-guidelines", "stylelint-config-css-modules"], | ||
} |
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,31 @@ | ||
/* stylelint-disable max-nesting-depth, selector-max-compound-selectors */ | ||
|
||
.HorizontalNav { | ||
> ul { | ||
display: flex; | ||
margin: 0; | ||
padding: 0; | ||
|
||
> li { | ||
@include u-font-size('body', '2xs'); | ||
|
||
list-style: none; | ||
|
||
> a { | ||
@include u-text('bold'); | ||
@include u-text('base'); | ||
|
||
display: block; | ||
line-height: 0.9; | ||
padding: 1.5rem 2.5rem; | ||
text-decoration: none; | ||
|
||
&:global(.usa-current), | ||
&:hover { | ||
@include u-border('primary'); | ||
border-width: 0 0 3px; | ||
} | ||
} | ||
} | ||
} | ||
} |
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,7 @@ | ||
// This file is automatically generated. | ||
// Please do not change this file! | ||
interface CssExports { | ||
HorizontalNav: string | ||
} | ||
export const cssExports: CssExports | ||
export default cssExports |
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,22 @@ | ||
import React from 'react' | ||
import { HorizontalNav } from './HorizontalNav' | ||
|
||
export default { | ||
title: 'HorizontalNav', | ||
} | ||
|
||
const testItems = [ | ||
<a href="#one" className="usa-current" key="one"> | ||
Current page | ||
</a>, | ||
<a href="#two" key="two"> | ||
Link one | ||
</a>, | ||
<a href="#three" key="three"> | ||
Link two | ||
</a>, | ||
] | ||
|
||
export const flat = (): React.ReactElement => ( | ||
<HorizontalNav items={testItems} /> | ||
) |
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,34 @@ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
|
||
import { HorizontalNav } from './HorizontalNav' | ||
|
||
const testItems = [ | ||
<a href="#one" className="usa-current" key="one"> | ||
Current page | ||
</a>, | ||
<a href="#two" key="two"> | ||
Link one | ||
</a>, | ||
<a href="#three" key="three"> | ||
Link two | ||
</a>, | ||
] | ||
|
||
describe('HorizontalNav component', () => { | ||
it('renders without errors', () => { | ||
const { queryByTestId } = render(<HorizontalNav items={testItems} />) | ||
expect(queryByTestId('horizontalnav')).toBeInTheDocument() | ||
}) | ||
|
||
it('renders each item', () => { | ||
const { queryByText } = render(<HorizontalNav items={testItems} />) | ||
expect(queryByText('Current page')).toBeInTheDocument() | ||
expect(queryByText('Link one')).toBeInTheDocument() | ||
expect(queryByText('Link two')).toBeInTheDocument() | ||
}) | ||
|
||
describe('with a subnav', () => { | ||
/* TODO */ | ||
}) | ||
}) |
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,21 @@ | ||
import React from 'react' | ||
|
||
import styles from './HorizontalNav.module.scss' | ||
|
||
type HorizontalNavProps = { | ||
items: React.ReactNode[] | ||
} | ||
|
||
export const HorizontalNav = ({ | ||
items, | ||
}: HorizontalNavProps): React.ReactElement => { | ||
return ( | ||
<nav className={styles.HorizontalNav} data-testid="horizontalnav"> | ||
<ul> | ||
{items.map((item, i) => ( | ||
<li key={`horizontalnav_item_${i}`}>{item}</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