@@ -5,24 +5,21 @@ open ReactMultiversal;
55let styles =
66 StyleSheet . create(
77 Style . {
8- "container" : style(~height= 100 .-> pct, ~overflow= ` scroll , () ),
9- "title" : style(~fontSize= 16 ., ~fontWeight= `_600 , ~color= "#333" , () ),
10- "link" :
11- style(
12- ~fontSize= 14 .,
13- ~fontWeight= `_400 ,
14- ~color= "#555" ,
15- ~paddingVertical= (Spacer . space /. 4 . )-> dp,
16- () ,
17- ),
18- "notlink" :
19- style(
20- ~fontSize= 14 .,
21- ~fontWeight= `_400 ,
22- ~color= "#ddd" ,
23- ~paddingVertical= (Spacer . space /. 4 . )-> dp,
8+ "container" : viewStyle(~height= 100 .-> pct, ~overflow= ` scroll , () ),
9+ "title" : textStyle(~fontSize= 16 ., ~fontWeight= `_600 , ~color= "#333" , () ),
10+ "link" : viewStyle() ,
11+ "linkActive" :
12+ viewStyle(
13+ ~shadowColor= Predefined . Colors . blue,
14+ ~shadowOffset= offset(~width=- 3 ., ~height= 0 . ),
15+ ~shadowOpacity= 1 .,
16+ ~shadowRadius= 0 .,
2417 () ,
2518 ),
19+ "linkText" :
20+ textStyle(~fontSize= 14 ., ~fontWeight= `_400 , ~color= "#555" , () ),
21+ "linkTextActive" : textStyle(~color= Predefined . Colors . blue, () ),
22+ "notlinkText" : textStyle(~color= "#ddd" , () ),
2623 },
2724 );
2825
@@ -47,7 +44,7 @@ let makeSections =
4744let sections = makeSections(Consts . sections);
4845
4946[@ react . component ]
50- let make = (~docsIndex) => {
47+ let make = (~docsIndex, ~currentLocation ) => {
5148 <div
5249 className= "stick"
5350 style= {ReactDOMRe . Style . make(
@@ -108,14 +105,18 @@ let make = (~docsIndex) => {
108105 ++ ")" ,
109106 () ,
110107 )}>
111- <SpacedView vertical= SpacedView . M horizontal= SpacedView . None >
108+ <SpacedView vertical= M horizontal= None >
112109 <Text style= styles##title>
113110 {section. title-> String . uppercase-> React . string}
114111 </Text >
115112 </SpacedView >
116113 </div >
117114 {{section. data
118- -> List . map(((title, link)) =>
115+ -> List . map(((title, link)) => {
116+ let fulllink = "en/" ++ link;
117+ let isActive =
118+ currentLocation## pathname
119+ |> Js . String . startsWith(fulllink ++ "index.html" );
119120 ! (link |> Js . String . startsWith("docs/apis/" ))
120121 && ! (link |> Js . String . startsWith("docs/components/" ))
121122 || (
@@ -127,16 +128,34 @@ let make = (~docsIndex) => {
127128 && docsIndex-> Array . some(path =>
128129 link == "docs/" ++ path ++ "/"
129130 )
130- ? <TextLink
131+ ? <ViewLink
131132 key= title
132- href= {Consts . baseUrl ++ "/en/" ++ link}
133- style= styles##link>
134- title-> React . string
135- </TextLink >
136- : <Text key= title style= styles##notlink>
137- title-> React . string
138- </Text >
139- )}
133+ href= {Consts . baseUrl ++ "/" ++ fulllink}
134+ style= {Style . arrayOption([|
135+ Some (styles## link),
136+ isActive ? Some (styles## linkActive) : None ,
137+ |] )}>
138+ <SpacedView horizontal= XS vertical= XXS >
139+ <Text
140+ style= {Style . arrayOption([|
141+ Some (styles## linkText),
142+ isActive ? Some (styles## linkTextActive) : None ,
143+ |] )}>
144+ title-> React . string
145+ </Text >
146+ </SpacedView >
147+ </ViewLink >
148+ : <SpacedView horizontal= XS vertical= XXS >
149+ <Text
150+ key= title
151+ style= {Style . array([|
152+ styles## link,
153+ styles## notlinkText,
154+ |] )}>
155+ title-> React . string
156+ </Text >
157+ </SpacedView >;
158+ })}
140159 -> List . toArray
141160 -> React . array}
142161 <Spacer size= Spacer . S />
0 commit comments