-
Notifications
You must be signed in to change notification settings - Fork 104
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
Showing
11 changed files
with
1,043 additions
and
301 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
File renamed without changes.
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
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,4 +1,4 @@ | ||
import SideNav from '../src'; | ||
|
||
export { NavItem, NavIcon, NavText } from '../src'; | ||
export { Toggle, Nav, NavItem, NavIcon, NavText } from '../src'; | ||
export default SideNav; |
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,119 @@ | ||
import styled from 'styled-components'; | ||
import SideNav, { | ||
Toggle, | ||
Nav, | ||
NavItem, | ||
NavIcon, | ||
NavText | ||
} from '../SideNav'; | ||
|
||
// SideNav | ||
const StyledSideNav = styled(SideNav)` | ||
background-color: #fff; | ||
border-right: 1px solid #ddd; | ||
`; | ||
StyledSideNav.defaultProps = SideNav.defaultProps; | ||
|
||
// Toggle | ||
const StyledToggle = styled(Toggle)` | ||
background-color: #db3d44; | ||
`; | ||
StyledToggle.defaultProps = Toggle.defaultProps; | ||
|
||
// Nav | ||
const StyledNav = styled(Nav)` | ||
background-color: #fff; | ||
&&[class*="expanded--"] { | ||
[class*="sidenav-subnav--"] { | ||
> [class*="sidenav-subnavitem--"], | ||
> [class*="sidenav-subnavitem--"]:hover { | ||
> a { | ||
color: #222; | ||
} | ||
} | ||
> [class*="sidenav-subnavitem--"]:hover { | ||
> a { | ||
background-color: #eee; | ||
} | ||
} | ||
> [class*="sidenav-subnavitem--"][class*="selected--"] { | ||
> a { | ||
color: #db3d44; | ||
} | ||
> a::before { | ||
border-left: 2px solid #db3d44; | ||
} | ||
} | ||
} | ||
} | ||
&& > [class*="sidenav-navitem--"] { | ||
> a { | ||
background-color: inherit; | ||
color: #222; | ||
} | ||
} | ||
&& > [class*="sidenav-navitem--"]:hover { | ||
> a { | ||
background-color: #eee; | ||
} | ||
} | ||
&& > [class*="sidenav-navitem--"], | ||
&& > [class*="sidenav-navitem--"]:hover { | ||
> a { | ||
[class*="sidenav-nav-icon--"] { | ||
&, > * { | ||
color: #666; | ||
} | ||
} | ||
[class*="sidenav-nav-text--"] { | ||
&, > * { | ||
color: #222; | ||
} | ||
} | ||
} | ||
} | ||
&& > [class*="sidenav-navitem--"][class*="selected"], | ||
&& > [class*="sidenav-navitem--"][class*="selected"]:hover { | ||
> a { | ||
[class*="sidenav-nav-icon--"], | ||
[class*="sidenav-nav-text--"] { | ||
&, > * { | ||
color: #db3d44; | ||
} | ||
} | ||
[class*="sidenav-nav-text--"] { | ||
font-weight: 700; | ||
} | ||
} | ||
} | ||
`; | ||
StyledNav.defaultProps = Nav.defaultProps; | ||
|
||
// NavItem | ||
const StyledNavItem = styled(NavItem)` | ||
`; | ||
StyledNavItem.defaultProps = NavItem.defaultProps; | ||
|
||
// NavIcon | ||
const StyledNavIcon = styled(NavIcon)` | ||
color: #222; | ||
`; | ||
StyledNavIcon.defaultProps = NavIcon.defaultProps; | ||
|
||
// NavText | ||
const StyledNavText = styled(NavText)` | ||
color: #222; | ||
`; | ||
StyledNavText.defaultProps = NavText.defaultProps; | ||
|
||
export { | ||
StyledToggle as Toggle, | ||
StyledNav as Nav, | ||
StyledNavItem as NavItem, | ||
StyledNavIcon as NavIcon, | ||
StyledNavText as NavText | ||
}; | ||
export default StyledSideNav; |
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,187 @@ | ||
import Breadcrumbs from '@trendmicro/react-breadcrumbs'; | ||
import ensureArray from 'ensure-array'; | ||
import React, { PureComponent } from 'react'; | ||
import styled from 'styled-components'; | ||
import SideNav, { Toggle, Nav, NavItem, NavIcon, NavText } from './StyledSideNav'; | ||
|
||
const navWidthCollapsed = 64; | ||
const navWidthExpanded = 280; | ||
|
||
const NavHeader = styled.div` | ||
display: ${props => (props.expanded ? 'block' : 'none')}; | ||
white-space: nowrap; | ||
background-color: #db3d44; | ||
color: #fff; | ||
> * { | ||
color: inherit; | ||
background-color: inherit; | ||
} | ||
`; | ||
|
||
// height: 20px + 10px + 10px = 40px | ||
const NavTitle = styled.div` | ||
font-size: 2em; | ||
line-height: 20px; | ||
padding: 10px 0; | ||
`; | ||
|
||
// height: 20px + 4px = 24px; | ||
const NavSubTitle = styled.div` | ||
font-size: 1em; | ||
line-height: 20px; | ||
padding-bottom: 4px; | ||
`; | ||
|
||
const NavInfoPane = styled.div` | ||
float: left; | ||
width: 100%; | ||
padding: 10px 20px; | ||
background-color: #eee; | ||
`; | ||
|
||
const Separator = styled.div` | ||
clear: both; | ||
position: relative; | ||
margin: .8rem 0; | ||
background-color: #ddd; | ||
height: 1px; | ||
`; | ||
|
||
const Main = styled.main` | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: ${navWidthCollapsed}px; | ||
overflow: hidden; | ||
transition: all .15s; | ||
padding: 0 20px; | ||
background: ${props => (props.expanded ? 'rgba(0, 0, 0, .6)' : 'inherit')}; | ||
transition: background-color .35s cubic-bezier(.4, 0, .2, 1); | ||
`; | ||
|
||
export default class extends PureComponent { | ||
state = { | ||
selected: 'home', | ||
expanded: false | ||
}; | ||
|
||
lastUpdateTime = new Date().toISOString(); | ||
|
||
onSelect = (selected) => { | ||
this.setState({ selected: selected }); | ||
}; | ||
onToggle = (expanded) => { | ||
this.setState({ expanded: expanded }); | ||
}; | ||
|
||
pageTitle = { | ||
'home': 'Home', | ||
'devices': ['Devices'], | ||
'reports': ['Reports'], | ||
'settings/policy': ['Settings', 'Policy'], | ||
'settings/network': ['Settings', 'Network'] | ||
}; | ||
|
||
renderBreadcrumbs() { | ||
const { selected } = this.state; | ||
const list = ensureArray(this.pageTitle[selected]); | ||
|
||
return ( | ||
<Breadcrumbs> | ||
{list.map((item, index) => ( | ||
<Breadcrumbs.Item | ||
active={index === list.length - 1} | ||
key={`${selected}_${index}`} | ||
> | ||
{item} | ||
</Breadcrumbs.Item> | ||
))} | ||
</Breadcrumbs> | ||
); | ||
} | ||
render() { | ||
const { expanded, selected } = this.state; | ||
|
||
return ( | ||
<div> | ||
<SideNav | ||
style={{ minWidth: expanded ? navWidthExpanded : navWidthCollapsed }} | ||
onSelect={this.onSelect} | ||
onToggle={this.onToggle} | ||
> | ||
<Toggle /> | ||
<NavHeader expanded={expanded}> | ||
<NavTitle>Side Navigation</NavTitle> | ||
<NavSubTitle>Styled Side Navigation</NavSubTitle> | ||
</NavHeader> | ||
{expanded && | ||
<NavInfoPane> | ||
<div>Time: {this.lastUpdateTime}</div> | ||
<div>User: admin</div> | ||
</NavInfoPane> | ||
} | ||
<Nav | ||
defaultSelected={selected} | ||
> | ||
<NavItem eventKey="home"> | ||
<NavIcon> | ||
<i className="fa fa-fw fa-home" style={{ fontSize: '1.75em' }} /> | ||
</NavIcon> | ||
<NavText style={{ paddingRight: 32 }}> | ||
HOME | ||
</NavText> | ||
</NavItem> | ||
<NavItem eventKey="devices"> | ||
<NavIcon> | ||
<i className="fa fa-fw fa-line-chart" style={{ fontSize: '1.75em' }} /> | ||
</NavIcon> | ||
<NavText style={{ paddingRight: 32 }}> | ||
DEVICES | ||
</NavText> | ||
</NavItem> | ||
<NavItem eventKey="reports"> | ||
<NavIcon> | ||
<i className="fa fa-fw fa-list-alt" style={{ fontSize: '1.75em' }} /> | ||
</NavIcon> | ||
<NavText style={{ paddingRight: 32 }}> | ||
REPORTS | ||
</NavText> | ||
</NavItem> | ||
<NavItem eventKey="settings"> | ||
<NavIcon> | ||
<i className="fa fa-fw fa-cogs" style={{ fontSize: '1.5em' }} /> | ||
</NavIcon> | ||
<NavText style={{ paddingRight: 32 }}> | ||
SETTINGS | ||
</NavText> | ||
<NavItem eventKey="settings/policy"> | ||
<NavText> | ||
POLICY | ||
</NavText> | ||
</NavItem> | ||
<NavItem eventKey="settings/network"> | ||
<NavText> | ||
NETWORK | ||
</NavText> | ||
</NavItem> | ||
</NavItem> | ||
<Separator /> | ||
<NavItem eventKey="logout"> | ||
<NavIcon> | ||
<i className="fa fa-fw fa-power-off" style={{ fontSize: '1.5em' }} /> | ||
</NavIcon> | ||
<NavText style={{ paddingRight: 32 }}> | ||
SIGN OUT | ||
</NavText> | ||
</NavItem> | ||
</Nav> | ||
</SideNav> | ||
<Main expanded={expanded}> | ||
{this.renderBreadcrumbs()} | ||
</Main> | ||
</div> | ||
); | ||
} | ||
} |
Oops, something went wrong.