component: add resuable NavigationItem component

This commit is contained in:
oscarzhou 2020-12-13 15:41:29 +13:00
parent 33a13f76e2
commit 67a49ad12b
5 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,25 @@
.NavigationItem {
margin: 0;
box-sizing: border-box;
display: flex;
height: 100%;
align-items: center;
}
.NavigationItem a{
color: white;
text-decoration: none;
height: 100%;
padding: 16px 10px;
border-bottom: 4px solid transparent;
box-sizing: border-box;
display: block;
}
.NavigationItem a:hover,
.NavigationItem a:active,
.NavigationItem a.active {
background-color: #8f5c2c;
border-bottom: 4px solid #40a4c8;
}

View File

@ -0,0 +1,14 @@
import React from 'react';
import classes from './NavigationItem.css';
const navigationItem = (props) => (
<li className={classes.NavigationItem}>
<a href={props.link}
className={props.active ? classes.active : null}>
{props.children}
</a>
</li>
)
export default navigationItem;

View File

@ -0,0 +1,8 @@
.NavigationItems {
margin: 0;
padding: 0;
list-style: none;
display: flex;
align-items: center;
height: 100%;
}

View File

@ -0,0 +1,13 @@
import React from 'react';
import NavigationItem from './NavigationItem/NavigationItem';
import classes from './NavigationItems.css';
const navigationItems = () => (
<ul className={classes.NavigationItems}>
<NavigationItem link="/" active>Burger Builder</NavigationItem>
<NavigationItem link="/">Checkout</NavigationItem>
</ul>
)
export default navigationItems

View File

@ -2,6 +2,7 @@ import React from 'react';
import classes from './Toolbar.css'; import classes from './Toolbar.css';
import Logo from '../../Logo/Logo'; import Logo from '../../Logo/Logo';
import NavigationItems from '../NavigationItems/NavigationItems';
const toolbar = () => { const toolbar = () => {
return ( return (
@ -9,7 +10,7 @@ const toolbar = () => {
<div>MENU</div> <div>MENU</div>
<Logo /> <Logo />
<nav> <nav>
... <NavigationItems />
</nav> </nav>
</header> </header>
) )