Skip to content

Implemented state awareness for the sidebar. #137

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

Merged
merged 2 commits into from
Jul 31, 2015
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
2 changes: 1 addition & 1 deletion docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
- [ ] scaffold design patterns/examples area
- [ ] mobile side navbar
- [ ] build pipeline for examples, create example component, possibly with code editing
- [ ] add active state to Docs side bar. (currently doesn't show which tab is active/selected)
- [x] add active state to Docs side bar. (currently doesn't show which tab is active/selected)
5 changes: 5 additions & 0 deletions docs/sass/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,12 @@ pre code.hljs {
.sidebar-links {
&--item {
line-height: 1.2em;
margin-top: 1em;
margin-bottom: 1em;
}
&--item-active {
background-color: #E8E4E4;
padding: 1em;
}
}

15 changes: 15 additions & 0 deletions docs/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,24 @@ addScrollClass("scrolled")

render(ItemFilterExample, 'item-filter-example')

updateSideBar()

function render(component, id) {
var el = document.getElementById(id)
if (el) {
React.render(React.createElement(ItemFilterExample), el)
}
}

function updateSideBar() {
var sideBarElements = document.getElementsByClassName('sidebar-links--item')
for (var i in sideBarElements) {
if (sideBarElements[i].firstChild) {
if (window.location.href === sideBarElements[i].firstChild.href) {
sideBarElements[i].className = 'sidebar-links--item-active'
} else {
sideBarElements[i].className = 'sidebar-links--item'
}
}
}
}