Skip to content

Commit

Permalink
Adding Reusable <NavigationItem/> inside <NavigationItems/>
Browse files Browse the repository at this point in the history
  • Loading branch information
Ch-sriram committed Aug 4, 2020
1 parent e9073bd commit 7b491ba
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ Layout, Component & State Design: **[View](https://codepen.io/ch-sriram/full/JjX

1. Adding a `<Toolbar />` Component: [Commit Details](https://github.com/Ch-sriram/burger-builder/commit/1f5cf0c1ae06912264691a5bd2cbdaed15d066a8)
2. Using & Adding a `<Logo />` in our Application: [Commit Details](https://github.com/Ch-sriram/burger-builder/commit/fe3e10f5665a6943e2e480ce280ce4afe06355df)
3. Adding Reusable `<NavigationItem />` inside `<NavigationItems />`: [Commit Details]()
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react';
import styled from 'styled-components';

const NavigationItem = styled.div`
margin: 0;
box-sizing: border-box;
display: flex;
height: 100%;
align-items: center;
& a {
color: white;
text-decoration: none;
height: 100%;
padding: 16px 10px;
border-bottom: 4px solid transparent;
box-sizing: border-box;
display: block;
&:hover,
&:active,
&.active {
background-color: #8F5C2C;
border-bottom: 4px solid #40A4C8;
}
}
`;

const navigationItem = (props) => (
<NavigationItem>
<a
href={props.link}
className={props.active ? 'active' : null}
>
{props.children}
</a>
</NavigationItem>
);

export default navigationItem;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// LIBRARY IMPORTS
import React from 'react';
import styled from 'styled-components';

// CUSTOM COMPONENT
import NavigationItem from './NavigationItem/NavigationItem.component';

// STYLED UL
const NavigationItems = styled.ul`
margin: 0;
padding: 0;
list-style: none;
display: flex;
align-items: center;
height: 100%;
`;

const navigationItems = () => (
<NavigationItems>
<NavigationItem link="/" active>Burger Builder</NavigationItem>
<NavigationItem link="/">Checkout</NavigationItem>
</NavigationItems>
);

export default navigationItems;
3 changes: 2 additions & 1 deletion src/components/Navigation/Toolbar/Toolbar.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import styled from 'styled-components';

// OUR CUSTOM COMPONENTS
import Logo from '../../Logo/Logo.component';
import NavigationItems from '../NavigationItems/NavigationItems.component';

// Custom Toolbar
const Toolbar = styled.header`
Expand All @@ -30,7 +31,7 @@ const toolbar = props => (
<div>MENU</div>
<Logo />
<nav>
...
<NavigationItems />
</nav>
</Toolbar>
);
Expand Down

0 comments on commit 7b491ba

Please sign in to comment.