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

Feature/navigation component #100

Merged
merged 8 commits into from
Jul 13, 2017
73 changes: 73 additions & 0 deletions app/components/Navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React from 'react'
import { connect as connectFela } from 'react-fela'
import { not } from 'ramda'
import AppBar from 'material-ui/AppBar'
import Drawer from 'material-ui/Drawer'
import MenuItem from 'material-ui/MenuItem'
import Divider from 'material-ui/Divider'
import { withState, withHandlers, compose } from 'recompose'

import styles from '../styles/Navigation'
import { FormattedMessage } from '../../lib/Intl'

function Navigation (props) {
const { styles, isDrawerOpen, toggleDrawer } = props

return (
<div>
<AppBar
title={
<FormattedMessage
id='app.name'
className={styles.labelText}
/>
}
onLeftIconButtonTouchTap={toggleDrawer}
/>
<Drawer open={isDrawerOpen}>
<MenuItem
leftIcon={
<i className="fa fa-bars" aria-hidden="true"/>
}
onTouchTap={toggleDrawer}
>
<FormattedMessage
id='app.closeMenu'
className={styles.labelText}
/>
</MenuItem>
<Divider />
<MenuItem
leftIcon={
<i className="fa fa-tachometer" aria-hidden="true" />
}
>
<FormattedMessage
id='app.dashboard'
className={styles.labelText}
/>
</MenuItem>
<Divider />
<MenuItem
leftIcon={
<i className="fa fa-sign-out" aria-hidden="true" />
}
>
<FormattedMessage
id='app.logOut'
className={styles.labelText}
/>
</MenuItem>
<Divider />
</Drawer>
</div>
)
}

export default compose(
connectFela(styles),
withState('isDrawerOpen', 'setDrawerOpen', false),
withHandlers({
toggleDrawer: ({ setDrawerOpen }) => () => setDrawerOpen(not)
})
)(Navigation)
3 changes: 3 additions & 0 deletions app/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"app.name": "Cobuy",
"app.closeMenu": "close menu",
"app.dashboard": "dashboard",
"app.logOut": "log out",
"agents.nameLabel": "name",
"agents.descriptionLabel": "description",
"agents.logout": "log out",
Expand Down
9 changes: 9 additions & 0 deletions app/stories/Navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'
import { storiesOf } from '@storybook/react'

import Navigation from '../components/Navigation'

storiesOf('app.Navigation', module)
.add('default', () => (
<Navigation />
))
1 change: 1 addition & 0 deletions app/stories/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require('./Button')
require('./TextField')
require('./AvatarField')
require('./Navigation')
6 changes: 6 additions & 0 deletions app/styles/Navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
container: (props) => ({}),
labelText: () => ({
textTransform: 'capitalize'
})
}