@jsenv/navi 0.29.26 → 0.29.27
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/dist/jsenv_navi.js +81 -1
- package/dist/jsenv_navi.js.map +2 -2
- package/docs/navigation.md +41 -0
- package/package.json +2 -2
package/docs/navigation.md
CHANGED
|
@@ -98,6 +98,47 @@ const sectionSignal = stateSignal("to_come", {
|
|
|
98
98
|
export const GAMES_SECTION_ROUTE = route(`/games/:section=${sectionSignal}`);
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
+
#### Declaring the sections is what makes them places
|
|
102
|
+
|
|
103
|
+
Both forms can be written together, and they say different things — which is
|
|
104
|
+
why declaring the literals is not decoration:
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
export const MY_GAMES_ROUTE = route(`/games/me/:section=${sectionSignal}`);
|
|
108
|
+
export const MY_GAMES_TO_COME_ROUTE = route("/games/me"); // the default: no segment
|
|
109
|
+
export const MY_GAMES_CANDIDATE_ROUTE = route("/games/me/candidate");
|
|
110
|
+
export const MY_GAMES_DONE_ROUTE = route("/games/me/done");
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Standing on `/games/me/done`:
|
|
114
|
+
|
|
115
|
+
- `MY_GAMES_ROUTE.buildUrl()` → `/games/me/done`. The parameterized route reads
|
|
116
|
+
its signal, so a link to "my games" from the bottom bar **reopens the section
|
|
117
|
+
you were looking at**. That is what the signal is for, and `persists` makes it
|
|
118
|
+
survive the night;
|
|
119
|
+
- `MY_GAMES_TO_COME_ROUTE.buildUrl()` → `/games/me`, always. A tab must point at
|
|
120
|
+
its own section, never at the one already open — a tab pointing at the current
|
|
121
|
+
page is a tab that cannot be clicked.
|
|
122
|
+
|
|
123
|
+
The default section is the delicate one: it has no segment of its own, so its
|
|
124
|
+
literal route is the **parent** of the parameterized one. It still means the
|
|
125
|
+
default section and does not inherit the param.
|
|
126
|
+
|
|
127
|
+
What tells navi these values name pages rather than qualify one is precisely
|
|
128
|
+
that the literal routes exist. Where no literal is declared, the value stays a
|
|
129
|
+
qualifier and an ancestor url keeps it:
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
const tabSignal = stateSignal("general", { id: "settings_tab" });
|
|
133
|
+
export const ADMIN_ROUTE = route(`/admin/:section=${sectionSignal}/`);
|
|
134
|
+
export const ADMIN_SETTINGS_ROUTE = route(`/admin/settings/:tab=${tabSignal}`);
|
|
135
|
+
// nobody declared /admin/settings/advanced, so on tab "advanced":
|
|
136
|
+
// ADMIN_ROUTE.buildUrl() → /admin/settings/advanced — "admin, where you left it"
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
So the rule is the one you would want: name a section and it becomes a place;
|
|
140
|
+
leave it unnamed and it stays a setting carried along.
|
|
141
|
+
|
|
101
142
|
### Search params
|
|
102
143
|
|
|
103
144
|
A param that qualifies a page rather than naming it — a zoom level, a sort, a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/navi",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Library of components including navigation to create frontend applications",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"prepublishOnly": "npm run build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@jsenv/dom": "0.17.
|
|
32
|
+
"@jsenv/dom": "0.17.9",
|
|
33
33
|
"@jsenv/humanize": "1.7.8",
|
|
34
34
|
"@jsenv/validity": "0.4.2"
|
|
35
35
|
},
|