Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navbar light/dark #325

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/less/nav-bar.less
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,13 @@
transform: translate(0, -100%);
box-shadow: @shadow-none;
}

&.dark {
background-color: @tertiary;
color: @white;
}

&.light {
background-color: @white;
}
}
31 changes: 31 additions & 0 deletions src/ts/components/navigation/nav-bar.examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,37 @@ class NavBarExample extends React.Component {

return (
<div>
<NavBar fixed={type === 'fixed'} shy={type === 'shy'} dark>
<Column>
<h1 className="font-size-large display-inline-block margin-bottom-none margin-top-small">
Title
</h1>

<Nav className="float-right">
<NavItem active>
<a>
One
</a>
</NavItem>
<NavItem>
<a>
Two
</a>
</NavItem>
<NavItem>
<a>
Three
</a>
</NavItem>
<NavItem className="button hollow primary">
<a>
Logout
</a>
</NavItem>
</Nav>
</Column>
</NavBar>

<NavBar fixed={type === 'fixed'} shy={type === 'shy'}>
<Column>
<h1 className="font-size-large display-inline-block margin-bottom-none margin-top-small">
Expand Down
6 changes: 6 additions & 0 deletions src/ts/components/navigation/nav-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface NavBarProps extends ComponentProps, HTMLProps<HTMLElement> {
* Remove NavBar shadow
*/
noShadow?: boolean;
dark?: boolean;
light?: boolean;
}

export interface NavBarState {
Expand Down Expand Up @@ -74,6 +76,8 @@ export class NavBar extends PureComponent<NavBarProps, NavBarState> {
className,
fixed,
shy,
dark,
light,
noShadow,
component: Component = 'div',
...remainingProps
Expand All @@ -87,6 +91,8 @@ export class NavBar extends PureComponent<NavBarProps, NavBarState> {
shy ? 'shy' : null,
hidden ? 'hidden' : null,
noShadow ? 'no-shadow' : null,
dark ? 'dark' : null,
light ? 'light' : null,
className,
];

Expand Down
12 changes: 12 additions & 0 deletions tests/__snapshots__/nav-bar.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ exports[`NavBar should apply shy class 1`] = `
/>
`;

exports[`NavBar should apply the dark class 1`] = `
<div
className="nav-bar dark"
/>
`;

exports[`NavBar should apply the hidden class 1`] = `
<NavBar
shy={true}
Expand All @@ -28,6 +34,12 @@ exports[`NavBar should apply the hidden class 1`] = `
</NavBar>
`;

exports[`NavBar should apply the light class 1`] = `
<div
className="nav-bar light"
/>
`;

exports[`NavBar should match snapshot 1`] = `
<div
className="nav-bar"
Expand Down
12 changes: 12 additions & 0 deletions tests/nav-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ describe('NavBar', () => {
expect(tree).toMatchSnapshot();
});

it('should apply the dark class', () => {
const tree = renderer.create(<NavBar dark />);

expect(tree).toMatchSnapshot();
});

it('should apply the light class', () => {
const tree = renderer.create(<NavBar light />);

expect(tree).toMatchSnapshot();
});

it('should apply the hidden class', () => {
const instance = enzyme.mount(<NavBar shy />);

Expand Down