From 19e2611b99281f77646c8a0390973d679eeef662 Mon Sep 17 00:00:00 2001 From: erikhallaraaker Date: Fri, 17 Aug 2018 14:49:51 +0200 Subject: [PATCH] Removed top level links from sidebar and made them span-elements which expands submenu instead of redirecting --- src/App/Documentation/SelectPanel.js | 67 +++++++++++++++------------- src/App/index.js | 1 - src/less/themes/documentation.less | 22 +++++++-- 3 files changed, 54 insertions(+), 36 deletions(-) diff --git a/src/App/Documentation/SelectPanel.js b/src/App/Documentation/SelectPanel.js index 0eb30707a..e35a4bf9b 100644 --- a/src/App/Documentation/SelectPanel.js +++ b/src/App/Documentation/SelectPanel.js @@ -9,51 +9,54 @@ const SearchBox = () => ( ); -class SelectPanel extends Component { +const NavLink = ({ childRoute, pathname }) => { + const { title, path } = childRoute; + return ( +
  • + {title} +
  • + ); +}; + +class NavGroup extends Component { constructor (props) { super(props); + this.state = { isActive: props.location.pathname.includes(props.route.path) }; } - titleActive (title) { - return this.props.location.pathname.includes(title); - } - - subtitleActive (title) { - return this.props.location.pathname === title; + toggleActive () { + this.setState({ isActive: !this.state.isActive }); } render () { + const { path, title, routes } = this.props.route; + const { pathname } = this.props.location; return ( -
    - {/* */} - +
    +
    + keyboard_arrow_right + this.toggleActive()}>{title} +
    +
      + {routes.map((childRoute, i) => )} +
    ); } } +const SelectPanel = () => ( +
    + {/* */} + +
    +); + export default withRouter(SelectPanel); /* for testing */ diff --git a/src/App/index.js b/src/App/index.js index 3aca6409a..4a705f864 100644 --- a/src/App/index.js +++ b/src/App/index.js @@ -7,7 +7,6 @@ import AppHeader from "./AppHeader"; import ErrorPage404 from "./ErrorPage404"; const isProd = process.env.NODE_ENV === "production"; -// const history = createBrowserHistory({ basename: "/design.payex.com" }); const history = createBrowserHistory(); const App = () => ( diff --git a/src/less/themes/documentation.less b/src/less/themes/documentation.less index 29e278305..86867fd2b 100644 --- a/src/less/themes/documentation.less +++ b/src/less/themes/documentation.less @@ -65,8 +65,25 @@ display: flex; align-items: center; - a { + > span { padding: 0; + cursor: pointer; + color: @brand-primary; + + &:hover, + &:focus { + color: darken(@brand-primary, 10%); + text-decoration: underline; + } + + &:active, + &:hover { + outline: 0; + } + + &:focus { + .tab-focus(); + } } i { @@ -86,9 +103,8 @@ &.active { .nav-heading { - a { + > span { font-weight: @font-weight-bold; - text-decoration: none; } i {