@nil-/doc 0.2.12 → 0.2.13
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/CHANGELOG.md
CHANGED
package/components/Layout.svelte
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
import Nav from "./navigation/Nav.svelte";
|
|
23
23
|
import { inRoot } from "./context";
|
|
24
24
|
export let data;
|
|
25
|
-
export let current
|
|
25
|
+
export let current;
|
|
26
26
|
export let sorter = null;
|
|
27
27
|
export let renamer = null;
|
|
28
28
|
const r = inRoot();
|
|
@@ -33,7 +33,7 @@ const r = inRoot();
|
|
|
33
33
|
<div class="content nil-doc-scrollable">
|
|
34
34
|
<Nav
|
|
35
35
|
info={data}
|
|
36
|
-
selected={current
|
|
36
|
+
selected={current}
|
|
37
37
|
sorter={sorter ?? ((l, r) => (l === r ? 0 : l < r ? -1 : +1))}
|
|
38
38
|
renamer={renamer ?? ((s) => s)}
|
|
39
39
|
on:navigate
|
|
@@ -63,6 +63,20 @@ export let sorter;
|
|
|
63
63
|
export let renamer;
|
|
64
64
|
let filter = "";
|
|
65
65
|
let states = apply(info, () => ({ expanded: false, sub: {} }), (t, path) => ({ expanded: t.expanded || selected === path, sub: t.sub }), (t) => t.sub);
|
|
66
|
+
function update(selected) {
|
|
67
|
+
if (!info.includes(selected)) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
let node = states;
|
|
71
|
+
const paths = selected.split("/").slice(1);
|
|
72
|
+
for (const [i, p] of paths.entries()) {
|
|
73
|
+
if (i < paths.length - 1) {
|
|
74
|
+
node[p].expanded = true;
|
|
75
|
+
}
|
|
76
|
+
node = node[p].sub;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
$: update(selected);
|
|
66
80
|
</script>
|
|
67
81
|
<div class="nav">
|
|
68
82
|
<div class="logo"><slot /></div>
|
|
@@ -18,28 +18,28 @@
|
|
|
18
18
|
cursor: pointer;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
.header
|
|
21
|
+
.header:hover {
|
|
22
|
+
background-color: rgba(2, 156, 253, 0.07);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.header.selected {
|
|
26
|
+
background-color: rgba(2, 157, 253, 0.822);
|
|
27
|
+
color: black;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.icon {
|
|
22
31
|
justify-content: center;
|
|
23
32
|
height: 15px;
|
|
24
33
|
width: 15px;
|
|
25
34
|
}
|
|
26
35
|
|
|
27
|
-
.
|
|
36
|
+
.icon.expanded {
|
|
28
37
|
transform: rotate(90deg);
|
|
29
38
|
}
|
|
30
39
|
|
|
31
|
-
.
|
|
40
|
+
.icon > div {
|
|
32
41
|
margin: auto;
|
|
33
42
|
}
|
|
34
|
-
|
|
35
|
-
.header:hover {
|
|
36
|
-
background-color: rgba(2, 156, 253, 0.07);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.header.selected {
|
|
40
|
-
background-color: rgba(2, 157, 253, 0.822);
|
|
41
|
-
color: black;
|
|
42
|
-
}
|
|
43
43
|
</style>
|
|
44
44
|
|
|
45
45
|
<script>import { slide } from "svelte/transition";
|