@colisweb/rescript-toolkit 2.62.4 → 2.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -148,6 +148,7 @@ module Make = (Config: RouterConfig) => {
|
|
|
148
148
|
and groupInfo = {
|
|
149
149
|
label: React.element,
|
|
150
150
|
icon: React.element,
|
|
151
|
+
activeForCurrentRoute?: Config.t => bool,
|
|
151
152
|
}
|
|
152
153
|
and appLink = {
|
|
153
154
|
route: Config.t,
|
|
@@ -198,7 +199,7 @@ module Make = (Config: RouterConfig) => {
|
|
|
198
199
|
<Link
|
|
199
200
|
route
|
|
200
201
|
className={cx([commonClassName, isSubLink ? "ml-3" : "", "sidenav-link"])}
|
|
201
|
-
activeClassName="bg-primary-100 text-neutral-700"
|
|
202
|
+
activeClassName="bg-primary-100/75 text-neutral-700"
|
|
202
203
|
onClick={_ => onLinkClick()}>
|
|
203
204
|
<span className="overflow-hidden flex">
|
|
204
205
|
<span className={cx(["text-neutral-800", isNavOpen ? "pl-2" : "px-2"])}> icon </span>
|
|
@@ -231,8 +232,14 @@ module Make = (Config: RouterConfig) => {
|
|
|
231
232
|
~openMenu,
|
|
232
233
|
) => {
|
|
233
234
|
let (isOpen, setIsOpen) = React.useState(() => false)
|
|
234
|
-
|
|
235
|
+
let currentRoute = useRoute()
|
|
235
236
|
let toggle = React.useCallback0(_ => setIsOpen(v => !v))
|
|
237
|
+
let hasActiveSubRoute = links->Array.some(link => {
|
|
238
|
+
switch link {
|
|
239
|
+
| Legacy(_) => false
|
|
240
|
+
| App({route}) => isRouteEqual(currentRoute, route)
|
|
241
|
+
}
|
|
242
|
+
})
|
|
236
243
|
|
|
237
244
|
React.useEffect1(() => {
|
|
238
245
|
if !isNavOpen {
|
|
@@ -247,7 +254,15 @@ module Make = (Config: RouterConfig) => {
|
|
|
247
254
|
openMenu()
|
|
248
255
|
toggle()
|
|
249
256
|
}}
|
|
250
|
-
className={cx([
|
|
257
|
+
className={cx([
|
|
258
|
+
commonClassName,
|
|
259
|
+
"flex items-center w-full sidenav-link",
|
|
260
|
+
switch (hasActiveSubRoute, isNavOpen) {
|
|
261
|
+
| (true, true) => "bg-primary-100/50"
|
|
262
|
+
| (true, false) => "bg-primary-100/75"
|
|
263
|
+
| (false, _) => ""
|
|
264
|
+
},
|
|
265
|
+
])}>
|
|
251
266
|
<span className={cx(["mr-2 text-neutral-800", isNavOpen ? "pl-2" : "px-2"])}>
|
|
252
267
|
groupInfo.icon
|
|
253
268
|
</span>
|