File tree Expand file tree Collapse file tree 4 files changed +37
-7
lines changed Expand file tree Collapse file tree 4 files changed +37
-7
lines changed Original file line number Diff line number Diff line change 34
34
margin : 0.5em 0 1em ;
35
35
}
36
36
37
+ & __version {
38
+ margin-bottom : 10px ;
39
+ }
40
+
37
41
& __anchor {
38
42
margin :0.25em 0 ;
39
43
Original file line number Diff line number Diff line change 63
63
text-transform : uppercase ;
64
64
color : getColor (mine-shaft );
65
65
margin : 1em 16px 0.25em ;
66
+
67
+ & --block {
68
+ display : block ;
69
+ }
70
+
71
+ & :active ,
72
+ & --active {
73
+ color : getColor (malibu );
74
+ }
66
75
}
67
76
68
77
.sidebar-mobile__page {
Original file line number Diff line number Diff line change @@ -58,12 +58,29 @@ export default class SidebarMobile extends React.Component {
58
58
* @return {array } - Markup containing sections and links
59
59
*/
60
60
_getSections ( ) {
61
- return this . props . sections . map ( section => (
62
- < div key = { section . url } >
63
- < h3 className = 'sidebar-mobile__section' > { section . title } </ h3 >
64
- { this . _getPages ( section . pages ) }
65
- </ div >
66
- ) ) ;
61
+ let pathname = '' ;
62
+
63
+ if ( typeof window !== 'undefined' ) {
64
+ pathname = window . location . pathname ;
65
+ }
66
+
67
+ return this . props . sections . map ( section => {
68
+ let active = pathname === section . url || pathname . includes ( `/${ section . url } ` ) ,
69
+ absoluteUrl = `/${ section . url } ` ;
70
+ return (
71
+ < div key = { absoluteUrl } >
72
+ < Link
73
+ className = { `sidebar-mobile__section sidebar-mobile__section--block ${ active ? 'sidebar-mobile__section--active' : '' } ` }
74
+ key = { absoluteUrl }
75
+ to = { absoluteUrl }
76
+ onClick = { this . _close . bind ( this ) } >
77
+ < h3 > { section . title } </ h3 >
78
+ </ Link >
79
+
80
+ { this . _getPages ( section . pages ) }
81
+ </ div >
82
+ ) ;
83
+ } ) ;
67
84
}
68
85
69
86
/**
Original file line number Diff line number Diff line change @@ -8,12 +8,12 @@ export default props => {
8
8
return (
9
9
< nav className = "sidebar" >
10
10
< div className = "sidebar__inner" >
11
+ < h3 className = "sidebar-item__version" > Version 2.1</ h3 >
11
12
< SidebarItem
12
13
url = { `/${ sectionName } ` }
13
14
title = "Introduction"
14
15
currentPage = { currentPage }
15
16
/>
16
-
17
17
{
18
18
pages . map ( ( { url, title, anchors } , i ) =>
19
19
< SidebarItem
You can’t perform that action at this time.
0 commit comments