From 2cd38e9a8f25dbfcb177be97ef65eb747bff46e5 Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Fri, 6 Jul 2018 09:55:30 +0100 Subject: [PATCH 1/2] feat: navbar width toggle Click on the logo to collapse the side nav. Click again to get it back. License: MIT Signed-off-by: Oli Evans --- src/App.js | 21 +++++++++++---- src/navigation/NavBar.js | 44 ++++++++++++++++++------------- src/navigation/NavBar.stories.js | 5 ++-- src/navigation/ipfs-logo-text.svg | 1 + src/navigation/ipfs-logo.svg | 18 ++++++++++++- 5 files changed, 62 insertions(+), 27 deletions(-) create mode 100644 src/navigation/ipfs-logo-text.svg diff --git a/src/App.js b/src/App.js index 97f11d1c2..46dbe2ef7 100644 --- a/src/App.js +++ b/src/App.js @@ -16,23 +16,34 @@ export class App extends Component { ]).isRequired } + state = { + isNavOpen: true + } + + onToggleNavbar = () => { + this.setState(s => ({isNavOpen: !s.isNavOpen})) + } + componentWillMount () { this.props.doInitIpfs() } render () { const Page = this.props.route + const {isNavOpen} = this.state return (
-
-
- +
+
+
+ +
-
+
-
+
diff --git a/src/navigation/NavBar.js b/src/navigation/NavBar.js index 57a9bb996..d331006e6 100644 --- a/src/navigation/NavBar.js +++ b/src/navigation/NavBar.js @@ -1,6 +1,7 @@ import React from 'react' import { connect } from 'redux-bundler-react' import ipfsLogo from './ipfs-logo.svg' +import ipfsLogoText from './ipfs-logo-text.svg' import StrokeMarketing from '../icons/StrokeMarketing' import StrokeWeb from '../icons/StrokeWeb' import StrokeCube from '../icons/StrokeCube' @@ -10,6 +11,7 @@ import StrokeIpld from '../icons/StrokeIpld' const NavLink = ({ to, icon, + open, exact, disabled, children, @@ -22,8 +24,8 @@ const NavLink = ({ const active = exact ? hash === href : hash && hash.startsWith(href) const cls = active ? className + ' ' + activeClassName : className return ( - - + + - {children} + {open ? children : null} ) } -export const NavBar = ({isSettingsEnabled}) => ( -
- - IPFS - - -
-) +export const NavBar = ({isSettingsEnabled, open, onToggle}) => { + const width = open ? 250 : 100 + return ( +
+
+ IPFS + IPFS +
+ +
+ ) +} -export const NavBarContainer = ({configRaw}) => { +export const NavBarContainer = ({configRaw, ...props}) => { const isSettingsEnabled = !!configRaw.data return ( - + ) } diff --git a/src/navigation/NavBar.stories.js b/src/navigation/NavBar.stories.js index 9076f49e2..975c600dd 100644 --- a/src/navigation/NavBar.stories.js +++ b/src/navigation/NavBar.stories.js @@ -1,6 +1,7 @@ import React from 'react' import { storiesOf } from '@storybook/react' import { checkA11y } from '@storybook/addon-a11y' +import { action } from '@storybook/addon-actions' import { withKnobs, boolean } from '@storybook/addon-knobs' import { NavBar } from './NavBar' @@ -9,7 +10,7 @@ storiesOf('Nav', module) .addDecorator(checkA11y) .addDecorator(withKnobs) .add('sidebar', () => ( -
- +
+
)) diff --git a/src/navigation/ipfs-logo-text.svg b/src/navigation/ipfs-logo-text.svg new file mode 100644 index 000000000..5d24074b6 --- /dev/null +++ b/src/navigation/ipfs-logo-text.svg @@ -0,0 +1 @@ +IPFS logo (new) \ No newline at end of file diff --git a/src/navigation/ipfs-logo.svg b/src/navigation/ipfs-logo.svg index 5d24074b6..a1e2c7f49 100644 --- a/src/navigation/ipfs-logo.svg +++ b/src/navigation/ipfs-logo.svg @@ -1 +1,17 @@ -IPFS logo (new) \ No newline at end of file + + + + + + + + + + + + + + + + + From 36ac9eff69a843e82ba7c5b9db0cfbce7c81bed1 Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Fri, 6 Jul 2018 10:09:05 +0100 Subject: [PATCH 2/2] remove redundent div License: MIT Signed-off-by: Oli Evans --- src/App.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/App.js b/src/App.js index 46dbe2ef7..d115d17a1 100644 --- a/src/App.js +++ b/src/App.js @@ -35,9 +35,7 @@ export class App extends Component {
-
- -
+