Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions components/sidebar-item/sidebar-item-style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
margin: 0.5em 0 1em;
}

&__version {
margin-bottom: 10px;
}

&__anchor {
margin:0.25em 0;

Expand Down
9 changes: 9 additions & 0 deletions components/sidebar-mobile/sidebar-mobile-style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@
text-transform: uppercase;
color: getColor(mine-shaft);
margin: 1em 16px 0.25em;

&--block {
display: block;
}

&:active,
&--active {
color: getColor(malibu);
}
}

.sidebar-mobile__page {
Expand Down
29 changes: 23 additions & 6 deletions components/sidebar-mobile/sidebar-mobile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,29 @@ export default class SidebarMobile extends React.Component {
* @return {array} - Markup containing sections and links
*/
_getSections() {
return this.props.sections.map(section => (
<div key={ section.url }>
<h3 className='sidebar-mobile__section'>{ section.title }</h3>
{ this._getPages(section.pages) }
</div>
));
let pathname = '';

if (typeof window !== 'undefined') {
pathname = window.location.pathname;
}

return this.props.sections.map(section => {
let active = pathname === section.url || pathname.includes(`/${section.url}`),
absoluteUrl = `/${section.url}`;
return (
<div key={ absoluteUrl }>
<Link
className={ `sidebar-mobile__section sidebar-mobile__section--block ${active ? 'sidebar-mobile__section--active' : ''}` }
key={ absoluteUrl }
to={ absoluteUrl }
onClick={ this._close.bind(this) }>
<h3>{ section.title }</h3>
</Link>

{ this._getPages(section.pages) }
</div>
);
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion components/sidebar/sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export default props => {
return (
<nav className="sidebar">
<div className="sidebar__inner">
<h3 className="sidebar-item__version">Version 2.1</h3>
<SidebarItem
url={ `/${sectionName}` }
title="Introduction"
currentPage= { currentPage }
/>

{
pages.map(({ url, title, anchors }, i) =>
<SidebarItem
Expand Down