Skip to content

Commit add7acd

Browse files
committed
Implemented state for the side bar.
1 parent 0d256cb commit add7acd

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

docs/sass/main.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,12 @@ pre code.hljs {
255255
.sidebar-links {
256256
&--item {
257257
line-height: 1.2em;
258+
margin-top: 1em;
258259
margin-bottom: 1em;
259260
}
261+
&--item-active {
262+
background-color: #E8E4E4;
263+
padding: 1em;
264+
}
260265
}
261266

docs/src/main.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,24 @@ addScrollClass("scrolled")
66

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

9+
updateSideBar()
10+
911
function render(component, id) {
1012
var el = document.getElementById(id)
1113
if (el) {
1214
React.render(React.createElement(ItemFilterExample), el)
1315
}
1416
}
17+
18+
function updateSideBar() {
19+
var sideBarElements = document.getElementsByClassName('sidebar-links--item')
20+
for (var i in sideBarElements) {
21+
if (sideBarElements[i].firstChild) {
22+
if (window.location.href === sideBarElements[i].firstChild.href) {
23+
sideBarElements[i].className = 'sidebar-links--item-active'
24+
} else {
25+
sideBarElements[i].className = 'sidebar-links--item'
26+
}
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)