methanol 0.0.23 → 0.0.24
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 +1 -1
- package/themes/default/src/nav-tree.jsx +47 -55
package/package.json
CHANGED
|
@@ -45,74 +45,66 @@ const toSignal = (i) => {
|
|
|
45
45
|
return sig
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
const filterVisible = (items) => {
|
|
49
|
-
if (!Array.isArray(items)) return []
|
|
50
|
-
return items.filter(({ value: item }) => {
|
|
51
|
-
if (!item.hidden) {
|
|
52
|
-
return true
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const _currentPath = currentPath.value
|
|
56
|
-
return _currentPath.startsWith(item.routePath)
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
|
|
60
48
|
const NavTree = ({ nodes, depth }) => {
|
|
61
|
-
const filtered = signal(nodes, filterVisible)
|
|
62
49
|
return (
|
|
63
|
-
<For entries={
|
|
50
|
+
<For entries={nodes}>
|
|
64
51
|
{({ item }) => {
|
|
65
52
|
const node = read(item)
|
|
66
53
|
const { routeHref: href, routePath, type, name, isRoot } = node
|
|
67
|
-
const { title } = extract(item, 'title')
|
|
54
|
+
const { title, hidden } = extract(item, 'title', 'hidden')
|
|
68
55
|
|
|
69
56
|
const isActive = matchCurrentPath(routePath)
|
|
70
|
-
|
|
57
|
+
let show = isActive
|
|
71
58
|
if (type === 'directory') {
|
|
72
|
-
|
|
73
|
-
const { children } = extract(item, 'children')
|
|
74
|
-
|
|
75
|
-
const isOpen = $(() => {
|
|
76
|
-
if (depth < 1) {
|
|
77
|
-
return true
|
|
78
|
-
}
|
|
59
|
+
show = $(() => {
|
|
79
60
|
const _active = isActive.value
|
|
80
61
|
const _currentPath = currentPath.value
|
|
81
62
|
return _active || _currentPath.startsWith(routePath)
|
|
82
63
|
})
|
|
83
|
-
|
|
84
|
-
const header = href ? (
|
|
85
|
-
<a class={isActive.choose('nav-dir-link active', 'nav-dir-link')} href={href}>
|
|
86
|
-
{label}
|
|
87
|
-
</a>
|
|
88
|
-
) : (
|
|
89
|
-
<span class="nav-dir-label">{label}</span>
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<li class={isActive.choose('is-active', null)}>
|
|
94
|
-
<details class="sidebar-collapsible" open={isOpen.choose(true, null)}>
|
|
95
|
-
<summary class="sb-dir-header">{header}</summary>
|
|
96
|
-
<If condition={() => children.value.length}>
|
|
97
|
-
{() => (
|
|
98
|
-
<ul data-depth={depth + 1}>
|
|
99
|
-
<NavTree nodes={children} depth={depth + 1} />
|
|
100
|
-
</ul>
|
|
101
|
-
)}
|
|
102
|
-
</If>
|
|
103
|
-
</details>
|
|
104
|
-
</li>
|
|
105
|
-
)
|
|
106
|
-
} else {
|
|
107
|
-
const label = title.or(node.isIndex ? 'Home' : name)
|
|
108
|
-
return (
|
|
109
|
-
<li>
|
|
110
|
-
<a class={isActive.choose('active', null)} href={href}>
|
|
111
|
-
{label}
|
|
112
|
-
</a>
|
|
113
|
-
</li>
|
|
114
|
-
)
|
|
115
64
|
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<If condition={hidden.inverseOr(show)}>
|
|
68
|
+
{() => {
|
|
69
|
+
if (type === 'directory') {
|
|
70
|
+
const label = title.or(name)
|
|
71
|
+
const { children } = extract(item, 'children')
|
|
72
|
+
|
|
73
|
+
const header = href ? (
|
|
74
|
+
<a class={isActive.choose('nav-dir-link active', 'nav-dir-link')} href={href}>
|
|
75
|
+
{label}
|
|
76
|
+
</a>
|
|
77
|
+
) : (
|
|
78
|
+
<span class="nav-dir-label">{label}</span>
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<li class={isActive.choose('is-active', null)}>
|
|
83
|
+
<details class="sidebar-collapsible" open={depth < 1 || show.choose(true, null)}>
|
|
84
|
+
<summary class="sb-dir-header">{header}</summary>
|
|
85
|
+
<If condition={() => children.value.length}>
|
|
86
|
+
{() => (
|
|
87
|
+
<ul data-depth={depth + 1}>
|
|
88
|
+
<NavTree nodes={children} depth={depth + 1} />
|
|
89
|
+
</ul>
|
|
90
|
+
)}
|
|
91
|
+
</If>
|
|
92
|
+
</details>
|
|
93
|
+
</li>
|
|
94
|
+
)
|
|
95
|
+
} else {
|
|
96
|
+
const label = title.or(node.isIndex ? 'Home' : name)
|
|
97
|
+
return (
|
|
98
|
+
<li>
|
|
99
|
+
<a class={isActive.choose('active', null)} href={href}>
|
|
100
|
+
{label}
|
|
101
|
+
</a>
|
|
102
|
+
</li>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
}}
|
|
106
|
+
</If>
|
|
107
|
+
)
|
|
116
108
|
}}
|
|
117
109
|
</For>
|
|
118
110
|
)
|