@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
@@ -1,5 +1,11 @@
1
1
  # @nil-/doc
2
2
 
3
+ ## 0.2.13
4
+
5
+ ### Patch Changes
6
+
7
+ - 39dbce9: [doc] navigation now automatically opens when redirected to a route that is still collapsed
8
+
3
9
  ## 0.2.12
4
10
 
5
11
  ### Patch Changes
@@ -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 = null;
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
@@ -3,7 +3,7 @@ import type { Sorter, Renamer } from "./navigation/types";
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  data: string[];
6
- current?: string | null | undefined;
6
+ current: string;
7
7
  sorter?: Sorter | null | undefined;
8
8
  renamer?: Renamer | null | undefined;
9
9
  };
@@ -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 > div {
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
- .header > div.expanded {
36
+ .icon.expanded {
28
37
  transform: rotate(90deg);
29
38
  }
30
39
 
31
- .header > div > div {
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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nil-/doc",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "author": {
5
5
  "email": "njaldea@gmail.com",
6
6
  "name": "Neil Aldea"