diff --git a/pages/doc-components/Header.js b/pages/doc-components/Header.js index cac597423f3..5f1b88fbd6b 100644 --- a/pages/doc-components/Header.js +++ b/pages/doc-components/Header.js @@ -1,10 +1,11 @@ import React from 'react' +import {withRouter} from 'next/router' import Octicon, {MarkGithub} from '@githubprimer/octicons-react' import NextLink from 'next/link' import BoxShadow from './BoxShadow' import {Text, FlexContainer, Link, Sticky} from '../..' -const Header = () => ( +const Header = ({router}) => ( @@ -18,12 +19,23 @@ const Header = () => (
- + Docs - + Sandbox @@ -33,4 +45,4 @@ const Header = () => ( ) -export default Header +export default withRouter(Header) diff --git a/pages/doc-components/SideNav.js b/pages/doc-components/SideNav.js index 0079e55de1c..9dcb84ec0ec 100644 --- a/pages/doc-components/SideNav.js +++ b/pages/doc-components/SideNav.js @@ -1,19 +1,52 @@ import React from 'react' +import {withRouter} from 'next/router' import {default as NextLink} from 'next/link' import {Text, Box, Link, FlexContainer, Relative} from '../..' import * as docs from '../components/docs' -const SideNav = () => ( +const getLink = router => { + return Object.values(docs).map(({displayName: name}) => { + const isSelected = router.pathname === `/components/docs/${name}` + return ( + + + + {name} + + + + ) + }) +} + +const isComponentLink = componentName => { + return Object.values(docs) + .map(n => n.displayName) + .includes(componentName) +} + +const SideNav = ({router}) => ( - + System Props - + Primer Theme @@ -21,23 +54,19 @@ const SideNav = () => ( - + Components - {Object.values(docs).map(({displayName: name}) => ( - - - - {name} - - - - ))} + {getLink(router)} ) -export default SideNav +export default withRouter(SideNav)