@nmnmcc/standard 0.4.0 → 0.5.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.
Files changed (47) hide show
  1. package/README.md +45 -68
  2. package/dist/Extend.js +1 -1
  3. package/dist/{Standard-BPpzr5SM.js → Standard-BC6CfFOv.js} +116 -159
  4. package/dist/Standard.js +1 -1
  5. package/dist/Ui-DSgtM8Tf.js +591 -0
  6. package/dist/Ui.d.ts +4 -4
  7. package/dist/Ui.js +1 -1
  8. package/dist/index.js +2 -2
  9. package/dist/standard/page/page.d.ts +4 -6
  10. package/dist/standard/page/page.d.ts.map +1 -1
  11. package/dist/standard/tokens/tokens.d.ts +20 -103
  12. package/dist/standard/tokens/tokens.d.ts.map +1 -1
  13. package/dist/standard.css +1 -1
  14. package/dist/ui/flap/flap.d.ts +10 -10
  15. package/dist/ui/flap/flap.d.ts.map +1 -1
  16. package/dist/ui/modal/modal.d.ts +4 -1
  17. package/dist/ui/modal/modal.d.ts.map +1 -1
  18. package/dist/ui/navigator/navigator.d.ts +58 -59
  19. package/dist/ui/navigator/navigator.d.ts.map +1 -1
  20. package/dist/ui/notice/notice.d.ts +6 -1
  21. package/dist/ui/notice/notice.d.ts.map +1 -1
  22. package/dist/ui/sheet/sheet.d.ts +9 -9
  23. package/dist/ui/toasts/toasts.d.ts +8 -7
  24. package/dist/ui/toasts/toasts.d.ts.map +1 -1
  25. package/package.json +1 -1
  26. package/src/standard/page/page.module.css +85 -47
  27. package/src/standard/page/page.module.d.css.ts +4 -2
  28. package/src/standard/page/page.ts +83 -1
  29. package/src/standard/tokens/tokens.ts +20 -268
  30. package/src/ui/dialog/dialog.module.css +24 -11
  31. package/src/ui/flap/flap.module.css +108 -52
  32. package/src/ui/flap/flap.module.d.css.ts +6 -1
  33. package/src/ui/flap/flap.ts +140 -13
  34. package/src/ui/modal/modal.module.css +73 -22
  35. package/src/ui/modal/modal.module.d.css.ts +1 -0
  36. package/src/ui/modal/modal.ts +21 -15
  37. package/src/ui/navigator/navigator.module.css +334 -176
  38. package/src/ui/navigator/navigator.module.d.css.ts +2 -10
  39. package/src/ui/navigator/navigator.ts +111 -106
  40. package/src/ui/notice/notice.ts +7 -2
  41. package/src/ui/popover/popover.ts +3 -3
  42. package/src/ui/sheet/sheet.module.css +51 -58
  43. package/src/ui/sheet/sheet.ts +9 -9
  44. package/src/ui/toasts/toasts.module.css +70 -11
  45. package/src/ui/toasts/toasts.module.d.css.ts +1 -0
  46. package/src/ui/toasts/toasts.ts +148 -4
  47. package/dist/Ui-B9xQqqNT.js +0 -468
@@ -1,13 +1,12 @@
1
1
  declare const styles: {
2
2
  readonly "is-after": string;
3
3
  readonly "is-before": string;
4
- readonly "mode-sheet": string;
5
4
  readonly "nav-back": string;
6
5
  readonly "nav-bar": string;
7
6
  readonly "nav-brand": string;
8
7
  readonly "nav-cell": string;
9
- readonly "nav-fold": string;
10
8
  readonly "nav-here": string;
9
+ readonly "nav-home": string;
11
10
  readonly "nav-list": string;
12
11
  readonly "nav-lit": string;
13
12
  readonly "nav-mark": string;
@@ -20,20 +19,13 @@ declare const styles: {
20
19
  readonly "nav-sign": string;
21
20
  readonly "nav-tabs": string;
22
21
  readonly "nav-top": string;
23
- readonly "nav-way": string;
22
+ readonly "nav-up": string;
24
23
  readonly "navigator": string;
25
24
  readonly "place-side": string;
26
25
  readonly "place-top": string;
27
26
  readonly "shell": string;
28
27
  readonly "shell-body": string;
29
28
  readonly "state-open": string;
30
- readonly "turn--135": string;
31
- readonly "turn--45": string;
32
- readonly "turn--90": string;
33
- readonly "turn-135": string;
34
- readonly "turn-180": string;
35
- readonly "turn-45": string;
36
- readonly "turn-90": string;
37
29
  };
38
30
  export = styles;
39
31
 
@@ -9,7 +9,7 @@ import type { Html } from "effect/ui/html"
9
9
  import { type Child, contents as inner, type Kind, node, type Node } from "../../Node.ts"
10
10
  import { type Icon, iconOf, leading } from "../../standard/icon/icon.ts"
11
11
  import { tone } from "../../standard/tokens/classes.ts"
12
- import type { Colour, Tone, Travel } from "../../standard/tokens/tokens.ts"
12
+ import type { Colour, Tone } from "../../standard/tokens/tokens.ts"
13
13
  import control from "../control/control.module.css"
14
14
  import { line } from "../control/control.ts"
15
15
  import styles from "./navigator.module.css"
@@ -19,10 +19,10 @@ export const Place = Schema.Literals(["side", "top", "bottom"])
19
19
  export type Place = typeof Place.Type
20
20
 
21
21
  /**
22
- * How an open navigator takes its place: with room taken from the page,
23
- * with the window moved over to it, or with neither, hanging over the page
24
- * as a menu does. The first two can be asked for, at the side. The third
25
- * is what a navigator along the top is.
22
+ * How a navigator is held in its window: docked, with room of its own,
23
+ * which is what one at the side is; in front of the page as a sheet, which
24
+ * is what one along the bottom is; or hanging in front of it as a menu
25
+ * does, which is what one along the top is.
26
26
  */
27
27
  export const Hold = Schema.Literals(["docked", "sheet", "menu"])
28
28
  export type Hold = typeof Hold.Type
@@ -55,83 +55,90 @@ const ShowCurrentPlace = Mount.make(
55
55
  )
56
56
 
57
57
  /**
58
- * How far round the arrow that goes back is turned to point the way the
59
- * window will move: clockwise, in degrees, from pointing back along the line
60
- * of reading, which is how it is drawn. Never more than half a turn either
61
- * way.
62
- */
63
- const turnOf = (travel: ReadonlyArray<Travel>): 0 | 45 | 90 | 135 | 180 | -45 | -90 | -135 => {
64
- const up = travel.includes("up")
65
- const down = travel.includes("down")
66
- if (travel.includes("back")) return up ? 45 : down ? -45 : 0
67
- if (travel.includes("forward")) return up ? 135 : down ? -135 : 180
68
- // With no way at all it stays as it is drawn.
69
- return up ? 90 : down ? -90 : 0
70
- }
71
-
72
- /**
73
- * Turns the arrow that goes back the short way round. A stylesheet can only
74
- * turn it from one number to another, which from up and forward to down and
75
- * forward is three quarters of a turn, by way of back. This turns it on from
76
- * wherever it is by whatever is least: never more than half a turn.
58
+ * Says how far down the page the top of the window is, whenever that
59
+ * changes. The stylesheet needs it to turn the page away from what comes in
60
+ * front of it: the page turns on a line across the window, and is seen from in
61
+ * front of the middle of the window, wherever it is scrolled to.
62
+ *
63
+ * It is worked out from where the shell is. The shell does not turn; the
64
+ * page does, and a turned page is not where it was laid out.
77
65
  */
78
- const PointTheWay = Mount.make("PointTheWay", { args: { turn: Schema.Number } }, (arrow: HTMLElement, _args, changes) =>
79
- Stream.runForEach(changes, ({ turn }) =>
80
- Effect.sync(() => {
81
- const now = Number.parseFloat(arrow.style.rotate)
82
- // The first time it is where its class has it already, and nothing moves.
83
- arrow.style.rotate = `${Number.isNaN(now) ? turn : now + ((((turn - now) % 360) + 540) % 360) - 180}deg`
84
- })
85
- ).pipe(Effect.as(Component.noop))
66
+ const FollowTheWindow = Mount.make("FollowTheWindow", { args: {} }, (page: HTMLElement) =>
67
+ Stream.mergeAll(
68
+ [
69
+ Stream.succeed(undefined),
70
+ Stream.fromEventListener(window, "scroll", { capture: true, passive: true }),
71
+ Stream.fromEventListener(window, "resize", { passive: true })
72
+ ],
73
+ { concurrency: "unbounded" }
74
+ ).pipe(
75
+ Stream.runForEach(() =>
76
+ Effect.sync(() => {
77
+ const shell = page.parentElement
78
+ if (shell === null) return
79
+ const top = shell.getBoundingClientRect().top + page.offsetTop - shell.offsetTop
80
+ page.style.setProperty("--s-ui-seen", `${-top}px`)
81
+ })
82
+ ),
83
+ Effect.as(Component.noop)
84
+ )
86
85
  )
87
86
 
88
87
  export const navigator = <Msg>(h: Html.H<Msg>) => ({
89
88
  /**
90
89
  * The navigator, and the page it leads you round. It has two layers.
91
- * First a bar: each group, by its pictogram and its name. Then a pane: the
92
- * places of the group that is shown. The group shown and its pane are
93
- * a block of colour: the group's colour if it was given one, the accent if
94
- * not. A group that is not shown has its pictogram and name written in
95
- * that colour. The current place is the two colours swapped.
90
+ * First the groups, each by its pictogram and its name. Then the places
91
+ * of the group that is shown. The group shown and its places are a block
92
+ * of colour: the group's colour if it was given one, the accent if not.
93
+ * A group that is not shown has its pictogram and name written in that
94
+ * colour. The current place is the two colours swapped.
96
95
  *
97
- * `place` says where it is. At the `"side"`, the bar is a rail down the
98
- * edge where the page starts, as wide as its pictograms until it is
99
- * opened, and the pane is beside it. Along the `"top"`, the bar is a row
100
- * and the pane hangs under the group that is shown, its places in a list
101
- * read downwards. Along the `"bottom"`, where a thumb is, the bar is a
102
- * row of tabs and the pane rises from behind it. A narrow window always
96
+ * `place` says where it is. Along the `"top"`, the groups are a row and
97
+ * the places hang under the group that is shown, in a list read
98
+ * downwards. Along the `"bottom"`, where a thumb is, the groups are a
99
+ * row of tabs and the places turn up over it. A narrow window always
103
100
  * has it along the bottom, whatever is asked for.
104
101
  *
105
- * At the start of the bar is the button that opens and closes it:
106
- * three bars, or with a `brand`, the app's mark and name. With a `back`,
107
- * the button that goes back is before it, in the corner where the page
108
- * starts. Its arrow points the way the window will move: give the `back`
109
- * its `travel`, and it turns to that as the page changes.
102
+ * At the `"side"` it is one column down the edge where the page starts,
103
+ * always there and always as wide, and its two layers are not side by
104
+ * side: they are one in front of the other, as the leaves of a door
105
+ * are. The groups are the layer behind. Pressing a group turns its
106
+ * places in over them, on the edge of the window, and at their head is
107
+ * the row that goes back: it turns them out again, and the groups are
108
+ * there as they were.
109
+ *
110
+ * At the start of the bar is `home`: a link to the page the app starts
111
+ * at. It is a pictogram of a house, or with a `brand`, the app's mark
112
+ * and name. With a `back`, the button that goes back is before it, in
113
+ * the corner where the page starts.
110
114
  *
111
115
  * Along the bottom the tabs have no room for either. There, and so in
112
116
  * every narrow window, a navigator with a `back` or a `brand` has a bar
113
117
  * along the top of the page as well, with the two in it.
114
118
  *
115
- * Closed, which is how it is until `open` is true, there is only the bar.
116
- * Pressing a group shows its places and goes nowhere: have the Model
117
- * open the navigator on `onShow` as well, because closed there is
118
- * nowhere to show them. Pressing the group that is shown, while it is
119
- * open, closes it.
119
+ * Until `open` is true only the groups are there. Pressing a group shows
120
+ * its places and goes nowhere: have the Model open the navigator on
121
+ * `onShow`. `onClose` is sent when the places are to go: by the row that
122
+ * goes back at the side, and by pressing the group that is shown along
123
+ * the top and the bottom. Both are told how the navigator is held in the
124
+ * window they were pressed in: `"docked"` at the side, where it has its
125
+ * own room; a `"sheet"` along the bottom; a `"menu"` along the top,
126
+ * where it hangs in front of the page.
120
127
  *
121
- * `mode` says how it takes its place when open. `"docked"`, it takes its
122
- * room from the page. As a `"sheet"` it takes none: the window moves over
123
- * to it, so the page slides out by as much as it slides in. That is for
124
- * the side: along the bottom it is always a sheet, and along the top it
125
- * is a `"menu"`: it hangs over the page and moves nothing.
126
- * `onShow` and `onToggle` are told which of the three the window they
127
- * were pressed in has, so the Model knows.
128
+ * The navigator is the post of a revolving door, and the page is a leaf
129
+ * of that door. Whenever something is in front of the page (the places
130
+ * as a sheet or a menu, a `sheet` or a `dialog`), the page turns away by
131
+ * 15 degrees on the edge of the window the navigator is at, and what
132
+ * comes in turns in on the same line. Its far edge goes back from the
133
+ * window, so it is seen smaller there, and the further back a part of
134
+ * it is, the more of the page's ground it takes: paler in the light
135
+ * scheme, darker in the dark scheme. It turns back when nothing is in
136
+ * front of it.
128
137
  *
129
- * Going to a place and closing the navigator are two movements; don't
130
- * make both at once. Docked, leave it open and let the window travel. As
131
- * a sheet, close it and change the page with no transition: the window
132
- * coming back from the navigator is the movement. As a menu, close it
133
- * and let the window travel: a menu closing moves nothing, so the travel
134
- * is the only movement there is.
138
+ * Going to a place is always the same movement: the new view turns in
139
+ * as the old one turns away. Docked, leave the navigator as it is. As a
140
+ * sheet or a menu, close it in the same update: its places were in
141
+ * front of the old view, and go with it.
135
142
  *
136
143
  * The Model keeps which group is `shown`, and whether it is `open`. Its
137
144
  * children are the page. Give `toasts` as the last of them.
@@ -141,7 +148,7 @@ export const navigator = <Msg>(h: Html.H<Msg>) => ({
141
148
  readonly label: string
142
149
  readonly groups: ReadonlyArray<{
143
150
  readonly label: string
144
- /** Its pictogram: all there is of it in a rail that is closed. */
151
+ /** Its pictogram. */
145
152
  readonly icon: Icon
146
153
  readonly colour?: Colour
147
154
  readonly links: ReadonlyArray<{
@@ -155,19 +162,20 @@ export const navigator = <Msg>(h: Html.H<Msg>) => ({
155
162
  readonly shown: number
156
163
  readonly onShow: (index: number, as: Hold) => Msg
157
164
  readonly open?: boolean
158
- readonly toggle: {
159
- /** The button's name, for anyone who can't see its pictogram. */
165
+ /** Sent when the places are to go, with how the navigator is held in the window it was pressed in. */
166
+ readonly onClose: (as: Hold) => Msg
167
+ /** The link to the page the app starts at, at the start of the bar. */
168
+ readonly home: {
169
+ /** The link's name, for anyone who can't see its pictogram. */
160
170
  readonly label: string
161
- /** What it sends: the state to go to, and how the navigator takes its place in the window it was pressed in. */
162
- readonly onToggle: (open: boolean, as: Hold) => Msg
171
+ readonly href: string
163
172
  }
164
173
  /**
165
174
  * Whose app this is: a mark and a name, at the start of the bar, in
166
- * place of the three bars. It is the button that opens and closes the
167
- * navigator. The mark is a picture, or a pictogram, or, with neither,
168
- * a square of colour: its colour if it was given one, the accent if
169
- * not. Along the bottom it is in the bar along the top, and opens
170
- * nothing: the tabs do that.
175
+ * place of the house. It is the link to the page the app starts at.
176
+ * The mark is a picture, or a pictogram, or, with neither, a square
177
+ * of colour: its colour if it was given one, the accent if not.
178
+ * Along the bottom it is in the bar along the top.
171
179
  */
172
180
  readonly brand?: { readonly name: string; readonly icon?: Icon; readonly src?: string; readonly colour?: Colour }
173
181
  /**
@@ -181,18 +189,8 @@ export const navigator = <Msg>(h: Html.H<Msg>) => ({
181
189
  readonly onPress: Msg
182
190
  /** True when there is nowhere to go back to: no page before this one, or one that is not the app's. */
183
191
  readonly disabled?: boolean
184
- /**
185
- * The way the window will move when it is pressed: what
186
- * `Standard.travel` makes of this route and the one it goes back
187
- * to. The arrow points that way, and turns to it, the short way
188
- * round, when it changes. Without one, or with no way at all, it
189
- * points back along the line of reading.
190
- */
191
- readonly travel?: ReadonlyArray<Travel>
192
192
  }
193
193
  readonly place?: Place
194
- /** At the side, whether it is docked or a sheet. Anywhere else it is not asked. */
195
- readonly mode?: Exclude<Hold, "menu">
196
194
  readonly tone?: Tone
197
195
  },
198
196
  ...children: ReadonlyArray<Child<Kind, Msg, R>>
@@ -201,7 +199,6 @@ export const navigator = <Msg>(h: Html.H<Msg>) => ({
201
199
  const open = options.open === true
202
200
  const { back, brand } = options
203
201
  // The button that goes back: in the bar of a wide window, and in the bar along the top of a narrow one.
204
- const turn = turnOf(back?.travel ?? [])
205
202
  const goBack = () =>
206
203
  back !== undefined &&
207
204
  h.button
@@ -210,11 +207,7 @@ export const navigator = <Msg>(h: Html.H<Msg>) => ({
210
207
  .attr("aria-label", back.label)
211
208
  .disabled(back.disabled === true)
212
209
  .on("click", back.onPress)
213
- .children(
214
- iconOf(h, "arrow-back")
215
- .class(styles["nav-way"], turn !== 0 && styles[`turn-${turn}`])
216
- .onMount(PointTheWay({ turn }))
217
- )
210
+ .children(iconOf(h, "arrow-back"))
218
211
  // The app's mark and its name.
219
212
  const sign = (of: NonNullable<typeof brand>) => [
220
213
  h.span
@@ -226,8 +219,9 @@ export const navigator = <Msg>(h: Html.H<Msg>) => ({
226
219
  h.span.class(styles["nav-name"]).children(of.name)
227
220
  ]
228
221
  const place = options.place ?? "side"
229
- // Only at the side can it be docked: along the bottom it is a sheet, and along the top it hangs over the page.
230
- const hold: Hold = place === "side" ? (options.mode ?? "docked") : place === "top" ? "menu" : "sheet"
222
+ // At the side it has its own room. Along the bottom it is a sheet, and along the top it hangs over the page.
223
+ const hold: Hold = place === "side" ? "docked" : place === "top" ? "menu" : "sheet"
224
+ const here = options.groups[options.shown]
231
225
  // A group, in the bar of a wide window or among the tabs along the bottom. Each says how the window it is in holds the navigator.
232
226
  const cells = (as: Hold) =>
233
227
  options.groups.map((group, index) =>
@@ -237,7 +231,7 @@ export const navigator = <Msg>(h: Html.H<Msg>) => ({
237
231
  .attr("aria-controls", id)
238
232
  .attr("aria-pressed", index === options.shown ? "true" : "false")
239
233
  // The group that is shown, pressed while it is open, closes it.
240
- .on("click", open && index === options.shown ? options.toggle.onToggle(false, as) : options.onShow(index, as))
234
+ .on("click", open && index === options.shown ? options.onClose(as) : options.onShow(index, as))
241
235
  // Along the top, once it is open, a mouse that comes onto another group shows it, the way a menu bar does. A finger has to press.
242
236
  .on("pointerenter", ({ pointerType }) =>
243
237
  as === "menu" && open && index !== options.shown && pointerType === "mouse"
@@ -252,7 +246,6 @@ export const navigator = <Msg>(h: Html.H<Msg>) => ({
252
246
  styles.shell,
253
247
  // Along the bottom is how the stylesheet has it until told otherwise.
254
248
  place !== "bottom" && styles[`place-${place}`],
255
- hold !== "docked" && styles["mode-sheet"],
256
249
  open && styles["state-open"]
257
250
  )
258
251
  .children(
@@ -268,14 +261,11 @@ export const navigator = <Msg>(h: Html.H<Msg>) => ({
268
261
  .children(
269
262
  h.div.class(styles["nav-bar"]).children(
270
263
  goBack(),
271
- h.button
272
- .class(control.control, styles["nav-fold"], brand !== undefined && styles["nav-brand"])
273
- .attr("type", "button")
274
- .attr("aria-label", options.toggle.label)
275
- .attr("aria-controls", id)
276
- .attr("aria-expanded", open ? "true" : "false")
277
- .on("click", options.toggle.onToggle(!open, hold))
278
- .children(brand === undefined ? iconOf(h, "menu") : sign(brand)),
264
+ h.a
265
+ .class(control.control, styles["nav-home"], brand !== undefined && styles["nav-brand"])
266
+ .attr("href", options.home.href)
267
+ .attr("aria-label", options.home.label)
268
+ .children(brand === undefined ? iconOf(h, "home") : sign(brand)),
279
269
  // The app's mark is not one of the places to go: a rule sets it apart from them.
280
270
  brand !== undefined && h.div.class(styles["nav-rule"]).attr("aria-hidden", "true"),
281
271
  cells(hold)
@@ -285,6 +275,13 @@ export const navigator = <Msg>(h: Html.H<Msg>) => ({
285
275
  .class(styles["nav-pane"])
286
276
  .attr("id", id)
287
277
  .children(
278
+ // At the side, the row that goes back to the groups: the places turn out, and the groups are there as they were.
279
+ here !== undefined &&
280
+ h.button
281
+ .class(control.control, styles["nav-up"], line(here.colour))
282
+ .attr("type", "button")
283
+ .on("click", options.onClose(hold))
284
+ .children(iconOf(h, "arrow-back"), h.span.class(styles["nav-name"]).children(here.label)),
288
285
  options.groups.map((group, index) => {
289
286
  const name = (link: { readonly label: string; readonly icon?: Icon }) =>
290
287
  link.icon === undefined ? link.label : h.span.children(leading(h, link.icon), link.label)
@@ -329,8 +326,16 @@ export const navigator = <Msg>(h: Html.H<Msg>) => ({
329
326
  (back !== undefined || brand !== undefined) &&
330
327
  h.div
331
328
  .class(styles["nav-top"], options.tone !== undefined && tone(options.tone))
332
- .children(goBack(), brand !== undefined && h.div.class(styles["nav-sign"]).children(sign(brand))),
333
- h.div.class(styles["shell-body"]).children(inner(children))
329
+ .children(
330
+ goBack(),
331
+ brand !== undefined &&
332
+ h.a
333
+ .class(control.control, styles["nav-sign"])
334
+ .attr("href", options.home.href)
335
+ .attr("aria-label", options.home.label)
336
+ .children(sign(brand))
337
+ ),
338
+ h.div.class(styles["shell-body"]).onMount(FollowTheWindow({})).children(inner(children))
334
339
  )
335
340
  )
336
341
  }
@@ -21,11 +21,16 @@ export const notice = <Msg>(h: Html.H<Msg>) => ({
21
21
  * caution, unless another is given. With `dismiss` it can be dismissed:
22
22
  * the button is at its end, as high as the notice. With `actions`, what
23
23
  * can be done about it is across its foot, edge to edge, as the answers
24
- * of a `dialog` are.
24
+ * of a `dialog` are. One of a list that changes, as a toast is, has a
25
+ * `key`: what tells it from the others, such as its id. Then the one
26
+ * that is taken away is the one that goes, and not the last of the list
27
+ * with the others written over.
25
28
  */
26
29
  notice: <R = never>(
27
30
  options: {
28
31
  readonly title: string
32
+ /** What tells it from the others of a list that changes: an id. */
33
+ readonly key?: string | number
29
34
  readonly level?: Level
30
35
  readonly icon?: Icon
31
36
  readonly dismiss?: { readonly label: string; readonly onPress: Msg }
@@ -34,7 +39,7 @@ export const notice = <Msg>(h: Html.H<Msg>) => ({
34
39
  ...children: ReadonlyArray<Child<Kind, Msg, R>>
35
40
  ): Node<"block", Msg, R> =>
36
41
  node(
37
- h.div
42
+ (options.key === undefined ? h.div : h.div.key(String(options.key)))
38
43
  .class(styles.notice, options.level === "caution" && styles["level-caution"])
39
44
  .attr("role", options.level === "caution" ? "alert" : "status")
40
45
  .children(
@@ -61,8 +61,8 @@ const heightOf = (root: HTMLElement, popover: HTMLElement): number => {
61
61
  * its button is can change without anyone touching the page, so it looks
62
62
  * again whenever anything could have moved it or changed what is in it:
63
63
  * the page or the button changing size, the typefaces loading, the page
64
- * scrolling, the window changing size, the page being slid aside by a
65
- * navigator or a sheet and coming back; when a pointer or the focus
64
+ * scrolling, the window changing size, the page turning away from something
65
+ * that opens and turning back; when a pointer or the focus
66
66
  * reaches the button; and when the popover opens or closes.
67
67
  */
68
68
  const FacePopover = Mount.make("FacePopover", { args: {} }, (root: HTMLElement) =>
@@ -75,7 +75,7 @@ const FacePopover = Mount.make("FacePopover", { args: {} }, (root: HTMLElement)
75
75
  Stream.fromEventListener(window, "load", { once: true }),
76
76
  Stream.fromEventListener(window, "scroll", { capture: true, passive: true }),
77
77
  Stream.fromEventListener(window, "resize", { passive: true }),
78
- // The page can move without scrolling: a navigator or a sheet opening slides it aside, and closing brings it back.
78
+ // The page can move without scrolling: it turns away from a navigator or a sheet that opens, and turns back when that closes.
79
79
  // It looks when that starts, and again when the page has come to rest.
80
80
  restated(document.body),
81
81
  Stream.fromEventListener(window, "transitionend", { capture: true, passive: true }),
@@ -1,11 +1,11 @@
1
- /* sheet: the place next to the page, which the window moves over to. */
1
+ /* sheet: a task or some detail, at the side of the window, in front of the page. */
2
2
 
3
3
  @layer standard.ui {
4
4
  .sheet {
5
5
  inset-block: 0;
6
6
  inset-inline: auto 0;
7
7
  inline-size: min(28rem, 100vi);
8
- block-size: 100dvb;
8
+ block-size: 100%;
9
9
  /* It is set on the page's own ground, a step towards its text: light in the light scheme, dark in the dark scheme. */
10
10
  --s-bg: color-mix(in oklch, var(--s-ink) 4%, var(--s-paper));
11
11
  --s-fg: var(--s-ink);
@@ -16,7 +16,7 @@
16
16
  translate: 100% 0;
17
17
 
18
18
  @starting-style {
19
- &[open] {
19
+ [open] > & {
20
20
  translate: 100% 0;
21
21
  }
22
22
  }
@@ -36,7 +36,7 @@
36
36
 
37
37
  /* They are at the bottom of the sheet however little is in it: what is over them is a column, and they take the room that is left above them. */
38
38
  @media (width >= 48rem) {
39
- &[open]:has(> .sheet-actions) {
39
+ [open] > &:has(> .sheet-actions) {
40
40
  display: flex;
41
41
  flex-direction: column;
42
42
 
@@ -52,16 +52,17 @@
52
52
  }
53
53
 
54
54
  /*
55
- * On a narrow screen the place is above the page, and fills the window
56
- * between the navigator's bar at the top and its tabs at the bottom,
57
- * which both stay where they are. The window moves up to it: the sheet
58
- * comes down out of the top bar, and the page goes down behind the tabs
59
- * by as much. The button that closes it is where a thumb is: across the
60
- * bottom, whatever the sheet has been scrolled to.
55
+ * On a narrow screen it fills the window between the navigator's bar
56
+ * at the top and its tabs at the bottom, which both stay where they
57
+ * are. The sheet turns up on the tabs, in front of the page, which
58
+ * turns away on them. With no navigator the window moves up to it,
59
+ * and the page goes down by as much. The button that closes it is at
60
+ * its top, beside its title, as in a wide window.
61
61
  */
62
62
  @media (width < 48rem) {
63
- inset-block: calc(var(--s-ui-top, 0px) + env(safe-area-inset-top, 0px))
64
- calc(var(--s-ui-tabs, 0px) + env(safe-area-inset-bottom, 0px));
63
+ /* With a navigator, its frame is between the bars already. */
64
+ inset-block: calc(var(--s-ui-bare, 1) * env(safe-area-inset-top, 0px))
65
+ calc(var(--s-ui-bare, 1) * env(safe-area-inset-bottom, 0px));
65
66
  inset-inline: 0;
66
67
  inline-size: 100%;
67
68
  block-size: auto;
@@ -76,32 +77,29 @@
76
77
  display var(--s-travel) allow-discrete,
77
78
  overlay var(--s-travel) allow-discrete;
78
79
 
79
- &[open] {
80
- grid-template-rows: auto minmax(0, 1fr) auto auto;
80
+ [open] > & {
81
+ grid-template-rows: auto minmax(0, 1fr) auto;
81
82
  align-content: stretch;
82
83
  row-gap: 0;
83
84
  clip-path: inset(0);
84
85
  }
85
86
 
86
87
  @starting-style {
87
- &[open] {
88
+ [open] > & {
88
89
  translate: 0 -100%;
89
90
  clip-path: inset(100% 0 0 0);
90
91
  }
91
92
  }
92
93
 
93
- /* The title, what scrolls, its actions and the button are its rows. */
94
+ /* The title with the button, what scrolls, and its actions are its rows. */
94
95
  & > .sheet-actions {
95
96
  position: static;
96
97
  grid-row: 3;
97
98
  margin: 0;
98
99
  }
99
100
 
101
+ /* Its title and the button that closes it are at its top, as in a wide window, and stay there whatever the sheet is scrolled to. */
100
102
  & > :global(.s-ui-modal-head) {
101
- display: contents;
102
- }
103
-
104
- & > :global(.s-ui-modal-head) > :global(.s-ui-modal-title) {
105
103
  padding: calc(3 * var(--s-unit));
106
104
  }
107
105
 
@@ -114,33 +112,20 @@
114
112
  overflow-y: auto;
115
113
  overscroll-behavior: contain;
116
114
  }
117
-
118
- & > :global(.s-ui-modal-head) > button {
119
- grid-row: 4;
120
- justify-self: stretch;
121
- padding-inline: calc(3 * var(--s-unit));
122
- min-block-size: var(--s-ui-tabs, var(--s-target));
123
- background: var(--s-fg);
124
- color: var(--s-bg);
125
-
126
- &:active {
127
- background: var(--s-mark);
128
- color: var(--s-on-mark);
129
- }
130
-
131
- &:focus-visible {
132
- outline-offset: calc(var(--s-unit) / -2);
133
- outline-color: var(--s-bg);
134
- }
135
- }
136
115
  }
137
116
  }
138
117
 
139
- /* The page, seen through a window that has moved over to the sheet. The sheet itself and what belongs to the window stay where they are. */
118
+ /*
119
+ * A page with a navigator turns away on it, and the sheet is in front of
120
+ * the page: the navigator's stylesheet does that. A page with no
121
+ * navigator has nothing to turn on. There the window moves over to the
122
+ * sheet: the page slides out by as much as the sheet slides in. The sheet
123
+ * itself and what belongs to the window stay where they are.
124
+ */
140
125
  :global(.s-page) > * {
141
126
  transition: translate var(--s-travel) var(--s-glide);
142
127
  }
143
- :global(.s-page):has(.sheet[open]) > :not(dialog, :global(.s-ui-toasts)) {
128
+ :global(.s-page):has([open] > .sheet) > :not(dialog, :global(.s-ui-toasts), :global(.s-ui-shell)) {
144
129
  translate: calc(-1 * min(28rem, 100vi)) 0;
145
130
  }
146
131
 
@@ -150,45 +135,53 @@
150
135
  inset-inline: 0 auto;
151
136
  translate: -100% 0;
152
137
 
153
- &[open] {
138
+ [open] > & {
154
139
  translate: 0 0;
155
140
  }
156
141
 
157
142
  @starting-style {
158
- &[open] {
143
+ [open] > & {
159
144
  translate: -100% 0;
160
145
  }
161
146
  }
162
147
  }
163
148
 
164
- :global(.s-page):has(.sheet.side-start[open]) > :not(dialog, :global(.s-ui-toasts)) {
149
+ :global(.s-page):has([open] > .sheet.side-start) > :not(dialog, :global(.s-ui-toasts), :global(.s-ui-shell)) {
165
150
  translate: min(28rem, 100vi) 0;
166
151
  }
167
152
  }
168
153
 
169
154
  @media (width < 48rem) {
170
155
  /* As far as the sheet is high, rounded up to a whole pixel so that no line of the page shows under it. */
171
- :global(.s-page):has(.sheet[open]) > :not(dialog, :global(.s-ui-toasts)) {
156
+ :global(.s-page):has([open] > .sheet) > :not(dialog, :global(.s-ui-toasts), :global(.s-ui-shell)) {
172
157
  translate: 0 round(up, 100dvb - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px), 1px);
173
158
  }
174
159
 
175
- /* With a navigator, its bars stay and only what is between them moves. */
176
- :global(.s-page):has(.sheet[open]) > :global(.s-ui-shell) {
177
- translate: none;
160
+ /* Where the page has gone to is not somewhere to scroll to. */
161
+ :global(.s-page):has([open] > .sheet) {
162
+ overflow: clip;
178
163
  }
164
+ }
165
+
166
+ /*
167
+ * With a navigator it does not slide in: it turns in on the navigator.
168
+ * This is where the post is, from its own corner.
169
+ */
170
+ :global(.s-ui-shell) .sheet.sheet {
171
+ --s-ui-post-x: calc(100% + var(--s-ui-hinge-x) - 100vi);
172
+ --s-ui-post-y: calc(var(--s-ui-hinge-y) - var(--s-ui-clear-top));
179
173
 
180
- :global(.s-ui-shell):has(.sheet[open]) > :global(.s-ui-shell-body) {
181
- translate: 0
182
- round(
183
- up,
184
- 100dvb - var(--s-ui-top) - var(--s-ui-tabs) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px),
185
- 1px
186
- );
174
+ translate: none;
175
+ clip-path: none;
176
+
177
+ @media (width >= 48rem) {
178
+ &.side-start {
179
+ --s-ui-post-x: calc(var(--s-ui-hinge-x) - var(--s-ui-clear-start));
180
+ }
187
181
  }
188
182
 
189
- /* Where the page has gone to is not somewhere to scroll to. */
190
- :global(.s-page):has(.sheet[open]) {
191
- overflow: clip;
183
+ @media (width < 48rem) {
184
+ --s-ui-post-x: calc(var(--s-ui-hinge-x) - var(--s-ui-clear-start));
192
185
  }
193
186
  }
194
187
  }