@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,6 +1,9 @@
1
1
  /**
2
2
  * What a `sheet` and a `dialog` share: a modal `dialog` element with a
3
- * title and the button that closes it.
3
+ * title and the button that closes it. The element itself is a frame that
4
+ * is not seen: the part of the window that is not the navigator's. So what
5
+ * is in it is never over the navigator, though a modal `dialog` is over
6
+ * everything else there is.
4
7
  *
5
8
  * @since 0.4.0
6
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/ui/modal/modal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,KAAK,EAA8B,KAAK,IAAI,EAAE,MAAM,eAAe,CAAA;AAIjF,yCAAyC;AACzC,eAAO,MAAM,KAAK,GAAI,GAAG,EAAE,CAAC,KACvB,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,QACR,OAAO,GAAG,QAAQ,QAClB,aAAa,CAAC,MAAM,GAAG,KAAK,CAAC,WAC1B;IACP,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACjE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB,YACS,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;AAC5C,oDAAoD;OAC7C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,+EA6BvB,CAAA"}
1
+ {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/ui/modal/modal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,KAAK,EAA8B,KAAK,IAAI,EAAE,MAAM,eAAe,CAAA;AAIjF,yCAAyC;AACzC,eAAO,MAAM,KAAK,GAAI,GAAG,EAAE,CAAC,KACvB,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,QACR,OAAO,GAAG,QAAQ,QAClB,aAAa,CAAC,MAAM,GAAG,KAAK,CAAC,WAC1B;IACP,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACjE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB,YACS,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;AAC5C,oDAAoD;OAC7C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,+EAgCvB,CAAA"}
@@ -7,65 +7,73 @@ import { Schema } from "effect";
7
7
  import type { Html } from "effect/ui/html";
8
8
  import { type Child, type Kind, type Node } from "../../Node.ts";
9
9
  import { type Icon } from "../../standard/icon/icon.ts";
10
- import type { Colour, Tone, Travel } from "../../standard/tokens/tokens.ts";
10
+ import type { Colour, Tone } from "../../standard/tokens/tokens.ts";
11
11
  /** Where a navigator is: at the side of the page, along its top, or along its bottom. */
12
12
  export declare const Place: Schema.Literals<readonly ["side", "top", "bottom"]>;
13
13
  export type Place = typeof Place.Type;
14
14
  /**
15
- * How an open navigator takes its place: with room taken from the page,
16
- * with the window moved over to it, or with neither, hanging over the page
17
- * as a menu does. The first two can be asked for, at the side. The third
18
- * is what a navigator along the top is.
15
+ * How a navigator is held in its window: docked, with room of its own,
16
+ * which is what one at the side is; in front of the page as a sheet, which
17
+ * is what one along the bottom is; or hanging in front of it as a menu
18
+ * does, which is what one along the top is.
19
19
  */
20
20
  export declare const Hold: Schema.Literals<readonly ["docked", "sheet", "menu"]>;
21
21
  export type Hold = typeof Hold.Type;
22
22
  export declare const navigator: <Msg>(h: Html.H<Msg>) => {
23
23
  /**
24
24
  * The navigator, and the page it leads you round. It has two layers.
25
- * First a bar: each group, by its pictogram and its name. Then a pane: the
26
- * places of the group that is shown. The group shown and its pane are
27
- * a block of colour: the group's colour if it was given one, the accent if
28
- * not. A group that is not shown has its pictogram and name written in
29
- * that colour. The current place is the two colours swapped.
25
+ * First the groups, each by its pictogram and its name. Then the places
26
+ * of the group that is shown. The group shown and its places are a block
27
+ * of colour: the group's colour if it was given one, the accent if not.
28
+ * A group that is not shown has its pictogram and name written in that
29
+ * colour. The current place is the two colours swapped.
30
30
  *
31
- * `place` says where it is. At the `"side"`, the bar is a rail down the
32
- * edge where the page starts, as wide as its pictograms until it is
33
- * opened, and the pane is beside it. Along the `"top"`, the bar is a row
34
- * and the pane hangs under the group that is shown, its places in a list
35
- * read downwards. Along the `"bottom"`, where a thumb is, the bar is a
36
- * row of tabs and the pane rises from behind it. A narrow window always
31
+ * `place` says where it is. Along the `"top"`, the groups are a row and
32
+ * the places hang under the group that is shown, in a list read
33
+ * downwards. Along the `"bottom"`, where a thumb is, the groups are a
34
+ * row of tabs and the places turn up over it. A narrow window always
37
35
  * has it along the bottom, whatever is asked for.
38
36
  *
39
- * At the start of the bar is the button that opens and closes it:
40
- * three bars, or with a `brand`, the app's mark and name. With a `back`,
41
- * the button that goes back is before it, in the corner where the page
42
- * starts. Its arrow points the way the window will move: give the `back`
43
- * its `travel`, and it turns to that as the page changes.
37
+ * At the `"side"` it is one column down the edge where the page starts,
38
+ * always there and always as wide, and its two layers are not side by
39
+ * side: they are one in front of the other, as the leaves of a door
40
+ * are. The groups are the layer behind. Pressing a group turns its
41
+ * places in over them, on the edge of the window, and at their head is
42
+ * the row that goes back: it turns them out again, and the groups are
43
+ * there as they were.
44
+ *
45
+ * At the start of the bar is `home`: a link to the page the app starts
46
+ * at. It is a pictogram of a house, or with a `brand`, the app's mark
47
+ * and name. With a `back`, the button that goes back is before it, in
48
+ * the corner where the page starts.
44
49
  *
45
50
  * Along the bottom the tabs have no room for either. There, and so in
46
51
  * every narrow window, a navigator with a `back` or a `brand` has a bar
47
52
  * along the top of the page as well, with the two in it.
48
53
  *
49
- * Closed, which is how it is until `open` is true, there is only the bar.
50
- * Pressing a group shows its places and goes nowhere: have the Model
51
- * open the navigator on `onShow` as well, because closed there is
52
- * nowhere to show them. Pressing the group that is shown, while it is
53
- * open, closes it.
54
+ * Until `open` is true only the groups are there. Pressing a group shows
55
+ * its places and goes nowhere: have the Model open the navigator on
56
+ * `onShow`. `onClose` is sent when the places are to go: by the row that
57
+ * goes back at the side, and by pressing the group that is shown along
58
+ * the top and the bottom. Both are told how the navigator is held in the
59
+ * window they were pressed in: `"docked"` at the side, where it has its
60
+ * own room; a `"sheet"` along the bottom; a `"menu"` along the top,
61
+ * where it hangs in front of the page.
54
62
  *
55
- * `mode` says how it takes its place when open. `"docked"`, it takes its
56
- * room from the page. As a `"sheet"` it takes none: the window moves over
57
- * to it, so the page slides out by as much as it slides in. That is for
58
- * the side: along the bottom it is always a sheet, and along the top it
59
- * is a `"menu"`: it hangs over the page and moves nothing.
60
- * `onShow` and `onToggle` are told which of the three the window they
61
- * were pressed in has, so the Model knows.
63
+ * The navigator is the post of a revolving door, and the page is a leaf
64
+ * of that door. Whenever something is in front of the page (the places
65
+ * as a sheet or a menu, a `sheet` or a `dialog`), the page turns away by
66
+ * 15 degrees on the edge of the window the navigator is at, and what
67
+ * comes in turns in on the same line. Its far edge goes back from the
68
+ * window, so it is seen smaller there, and the further back a part of
69
+ * it is, the more of the page's ground it takes: paler in the light
70
+ * scheme, darker in the dark scheme. It turns back when nothing is in
71
+ * front of it.
62
72
  *
63
- * Going to a place and closing the navigator are two movements; don't
64
- * make both at once. Docked, leave it open and let the window travel. As
65
- * a sheet, close it and change the page with no transition: the window
66
- * coming back from the navigator is the movement. As a menu, close it
67
- * and let the window travel: a menu closing moves nothing, so the travel
68
- * is the only movement there is.
73
+ * Going to a place is always the same movement: the new view turns in
74
+ * as the old one turns away. Docked, leave the navigator as it is. As a
75
+ * sheet or a menu, close it in the same update: its places were in
76
+ * front of the old view, and go with it.
69
77
  *
70
78
  * The Model keeps which group is `shown`, and whether it is `open`. Its
71
79
  * children are the page. Give `toasts` as the last of them.
@@ -74,7 +82,7 @@ export declare const navigator: <Msg>(h: Html.H<Msg>) => {
74
82
  readonly label: string;
75
83
  readonly groups: ReadonlyArray<{
76
84
  readonly label: string;
77
- /** Its pictogram: all there is of it in a rail that is closed. */
85
+ /** Its pictogram. */
78
86
  readonly icon: Icon;
79
87
  readonly colour?: Colour;
80
88
  readonly links: ReadonlyArray<{
@@ -88,19 +96,20 @@ export declare const navigator: <Msg>(h: Html.H<Msg>) => {
88
96
  readonly shown: number;
89
97
  readonly onShow: (index: number, as: Hold) => Msg;
90
98
  readonly open?: boolean;
91
- readonly toggle: {
92
- /** The button's name, for anyone who can't see its pictogram. */
99
+ /** Sent when the places are to go, with how the navigator is held in the window it was pressed in. */
100
+ readonly onClose: (as: Hold) => Msg;
101
+ /** The link to the page the app starts at, at the start of the bar. */
102
+ readonly home: {
103
+ /** The link's name, for anyone who can't see its pictogram. */
93
104
  readonly label: string;
94
- /** What it sends: the state to go to, and how the navigator takes its place in the window it was pressed in. */
95
- readonly onToggle: (open: boolean, as: Hold) => Msg;
105
+ readonly href: string;
96
106
  };
97
107
  /**
98
108
  * Whose app this is: a mark and a name, at the start of the bar, in
99
- * place of the three bars. It is the button that opens and closes the
100
- * navigator. The mark is a picture, or a pictogram, or, with neither,
101
- * a square of colour: its colour if it was given one, the accent if
102
- * not. Along the bottom it is in the bar along the top, and opens
103
- * nothing: the tabs do that.
109
+ * place of the house. It is the link to the page the app starts at.
110
+ * The mark is a picture, or a pictogram, or, with neither, a square
111
+ * of colour: its colour if it was given one, the accent if not.
112
+ * Along the bottom it is in the bar along the top.
104
113
  */
105
114
  readonly brand?: {
106
115
  readonly name: string;
@@ -119,18 +128,8 @@ export declare const navigator: <Msg>(h: Html.H<Msg>) => {
119
128
  readonly onPress: Msg;
120
129
  /** True when there is nowhere to go back to: no page before this one, or one that is not the app's. */
121
130
  readonly disabled?: boolean;
122
- /**
123
- * The way the window will move when it is pressed: what
124
- * `Standard.travel` makes of this route and the one it goes back
125
- * to. The arrow points that way, and turns to it, the short way
126
- * round, when it changes. Without one, or with no way at all, it
127
- * points back along the line of reading.
128
- */
129
- readonly travel?: ReadonlyArray<Travel>;
130
131
  };
131
132
  readonly place?: Place;
132
- /** At the side, whether it is docked or a sheet. Anywhere else it is not asked. */
133
- readonly mode?: Exclude<Hold, "menu">;
134
133
  readonly tone?: Tone;
135
134
  }, ...children: ReadonlyArray<Child<Kind, Msg, R>>) => Node<"block", Msg, R>;
136
135
  };
@@ -1 +1 @@
1
- {"version":3,"file":"navigator.d.ts","sourceRoot":"","sources":["../../../src/ui/navigator/navigator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAU,MAAM,EAAU,MAAM,QAAQ,CAAA;AAE/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;A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EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,KAC9C,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;CAiJxB,CAAA"}
@@ -18,10 +18,15 @@ export declare const notice: <Msg>(h: Html.H<Msg>) => {
18
18
  * caution, unless another is given. With `dismiss` it can be dismissed:
19
19
  * the button is at its end, as high as the notice. With `actions`, what
20
20
  * can be done about it is across its foot, edge to edge, as the answers
21
- * of a `dialog` are.
21
+ * of a `dialog` are. One of a list that changes, as a toast is, has a
22
+ * `key`: what tells it from the others, such as its id. Then the one
23
+ * that is taken away is the one that goes, and not the last of the list
24
+ * with the others written over.
22
25
  */
23
26
  notice: <R = never>(options: {
24
27
  readonly title: string;
28
+ /** What tells it from the others of a list that changes: an id. */
29
+ readonly key?: string | number;
25
30
  readonly level?: Level;
26
31
  readonly icon?: Icon;
27
32
  readonly dismiss?: {
@@ -1 +1 @@
1
- {"version":3,"file":"notice.d.ts","sourceRoot":"","sources":["../../../src/ui/notice/notice.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,KAAK,EAAqB,KAAK,IAAI,EAAQ,KAAK,IAAI,EAAE,MAAM,eAAe,CAAA;AACzF,OAAO,EAAE,KAAK,IAAI,EAAW,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,KAAK,OAAO,EAAW,MAAM,uBAAuB,CAAA;AAG7D,8BAA8B;AAC9B,eAAO,MAAM,KAAK,+CAAuC,CAAA;AACzD,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAErC,eAAO,MAAM,MAAM,GAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IACxC;;;;;;;OAOG;IACH,MAAM,GAAG,CAAC,GAAG,KAAK,WACP;QACP,QAAQ,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AAE,MAAM,GAAG,MAAM,CAAA;QAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAA;QACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;QACpB,QAAQ,CAAC,OAAO,CAAC,EAAE;YAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAA;SAAE,CAAA;QACpE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;KAChC,eACY,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,KAC9C,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;CAsBxB,CAAA"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `sheet`: the place next to the page.
2
+ * `sheet`: a task or some detail, at the side of the window.
3
3
  *
4
4
  * @since 0.4.0
5
5
  */
@@ -8,14 +8,14 @@ import { type Child, type Kind, type Node } from "../../Node.ts";
8
8
  import { type Actions } from "../control/control.ts";
9
9
  export declare const sheet: <Msg>(h: Html.H<Msg>) => {
10
10
  /**
11
- * The place next to the page: a task, some detail, or the app's
12
- * navigation. It isn't a layer over the page. The window moves over to
13
- * it, so the page slides out by exactly as much as the sheet slides in,
14
- * and back again when it closes; nothing is dimmed. It is at the end of
15
- * the page, or with `side: "start"` at its start. On a narrow screen it
16
- * is above the page: it comes down out of the navigator's top bar and
17
- * fills the window down to its tabs, and its button is across the
18
- * bottom, always in view. It keeps the focus inside, gives it back when it
11
+ * A task, some detail, or the app's navigation, at the side of the
12
+ * window. It comes in front of the page, and the page turns away from
13
+ * it on the navigator, as a door turns on its post, and back again when
14
+ * it closes. A page with no navigator slides out by exactly as much as
15
+ * the sheet slides in. It is at the end of the page, or with
16
+ * `side: "start"` at its start. On a narrow screen it fills the window
17
+ * between the navigator's top bar and its tabs, and its button is at
18
+ * its top, beside its title, as on a wide one. It keeps the focus inside, gives it back when it
19
19
  * closes, and asks to close on Escape, on a press outside it, and by its
20
20
  * button. The Model decides: it is open while `open` is true. With
21
21
  * `actions`, what ends the task is across its bottom, edge to edge, as the
@@ -1,14 +1,15 @@
1
- /**
2
- * `toasts`: what just happened, said at the bottom of the window.
3
- *
4
- * @since 0.4.0
5
- */
6
1
  import type { Html } from "effect/ui/html";
7
2
  import { type Child, type Node } from "../../Node.ts";
8
3
  export declare const toasts: <Msg>(h: Html.H<Msg>) => {
9
4
  /**
10
- * What just happened, said at the bottom of the window. Its children
11
- * are `s.notice`s the Model holds. Make it the last child of the page.
5
+ * What just happened, said in the top corner of the window, at the end
6
+ * of the line: under a bar along the top, and against the window's edge.
7
+ * Its children are `s.notice`s the Model holds, one under another with
8
+ * only a hairline between them. A toast turns in on the window's edge, as
9
+ * a small door does, and turns out the same way when the Model takes it
10
+ * away. They are over everything else in the window, always: over a
11
+ * sheet, over a dialog, and over whatever is turning. Make it the last
12
+ * child of the page.
12
13
  */
13
14
  toasts: <R = never>(options: {
14
15
  readonly label: string;
@@ -1 +1 @@
1
- {"version":3,"file":"toasts.d.ts","sourceRoot":"","sources":["../../../src/ui/toasts/toasts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,KAAK,EAA2B,KAAK,IAAI,EAAE,MAAM,eAAe,CAAA;AAG9E,eAAO,MAAM,MAAM,GAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IACxC;;;OAGG;IACH,MAAM,GAAG,CAAC,GAAG,KAAK,WACP;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,eACtB,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,KACjD,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;CAQxB,CAAA"}
1
+ {"version":3,"file":"toasts.d.ts","sourceRoot":"","sources":["../../../src/ui/toasts/toasts.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,KAAK,EAA2B,KAAK,IAAI,EAAE,MAAM,eAAe,CAAA;AAwI9E,eAAO,MAAM,MAAM,GAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IACxC;;;;;;;;;OASG;IACH,MAAM,GAAG,CAAC,GAAG,KAAK,WACP;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,eACtB,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,KACjD,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;CAWxB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nmnmcc/standard",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "A design language for interfaces on effect/ui: every page built with it is Swiss Style by construction. The language, and interactive components in it.",
5
5
  "license": "MIT",
6
6
  "author": "NMNM.CC",
@@ -1,4 +1,4 @@
1
- /* page: the root of a page. The reset, the type, the ground, and how the window moves in a change of view. */
1
+ /* page: the root of a page. The reset, the type, the ground, and how a view turns in a change of view. */
2
2
 
3
3
  @layer standard.reset {
4
4
  :where(html):has(.page) {
@@ -143,30 +143,69 @@
143
143
  }
144
144
 
145
145
  /*
146
- * The app is one canvas, and the screen a window onto it. In a change of view
147
- * the window moves, and that is all that happens: what was in the window
148
- * and what is in it now are one rigid surface, edge to edge, that slides
149
- * the other way by one whole window. Along both axes at once when the new
150
- * place is diagonal from the old one.
146
+ * A change of view is a revolving door turning by a quarter of a turn, on
147
+ * the edge of the window the navigator is at. When the history goes on,
148
+ * the view that comes in turns in from in front of the window, where it
149
+ * stands out towards whoever looks at it, and the view that is left
150
+ * turns on the same way, back from the window, until it stands away from
151
+ * it. When the history goes back the door turns the other way: the view
152
+ * that is left turns out to the front, and the one before it comes back
153
+ * from behind. It is one movement, the same for every change of view:
154
+ * there is no across, no up or down, and nothing at an angle.
151
155
  *
152
- * What moves is a snapshot of the window itself, so it is right wherever
153
- * the page was scrolled to. A thing with its own view-transition name is
154
- * not in that snapshot: it stays where it is, as a navigator does. If its
155
- * place is not the same after the change, it moves there in the same time
156
- * and on the same curve as the window, so everything that moves, moves
157
- * together.
156
+ * What turns is a snapshot of the window itself, so it is right wherever
157
+ * the page was scrolled to, and whatever was in front of the page goes
158
+ * with it. A thing with its own view-transition name is not in that
159
+ * snapshot: it stays where it is, as a navigator does. The view that is
160
+ * in front of the window, coming in or going out, is over everything. The
161
+ * view that is behind it, turning away or coming back, is under
162
+ * everything. So the navigator is between the two. Of each snapshot only
163
+ * the part that is not the navigator's is drawn, which the navigator
164
+ * says, and behind them all is the page's ground. If the place of a named
165
+ * thing is not the same after the change, it moves there in the same time
166
+ * and on the same curve.
167
+ *
168
+ * The navigator says where its post is. A page with no navigator turns on
169
+ * the edge of the window where it starts.
158
170
  */
159
- /* The fallbacks are lengths: a bare 0 inside `calc()` is a number, and would make the whole declaration invalid. */
160
- @keyframes leave {
171
+ /* In from the front, and out to the front. */
172
+ @keyframes turn-in {
173
+ from {
174
+ transform: var(--s-turn, perspective(150vmax) rotateY(-90deg));
175
+ }
176
+ }
177
+ @keyframes turn-out {
178
+ to {
179
+ transform: var(--s-turn, perspective(150vmax) rotateY(-90deg));
180
+ }
181
+ }
182
+ /* On to the back, and back from it. */
183
+ @keyframes turn-away {
161
184
  to {
162
- translate: var(--s-travel-x, 0px) var(--s-travel-y, 0px);
185
+ transform: var(--s-turn-away, perspective(150vmax) rotateY(90deg));
163
186
  }
164
187
  }
165
- @keyframes enter {
188
+ @keyframes turn-back {
166
189
  from {
167
- translate: calc(-1 * var(--s-travel-x, 0px)) calc(-1 * var(--s-travel-y, 0px));
190
+ transform: var(--s-turn-away, perspective(150vmax) rotateY(90deg));
191
+ }
192
+ }
193
+
194
+ /* Behind the views that turn is the page's ground, in the scheme the page is in. */
195
+ :root:has(.page) {
196
+ --s-ground: oklch(0.985 0.003 95);
197
+ }
198
+ :root:has(.page.scheme-dark) {
199
+ --s-ground: oklch(0.16 0 0);
200
+ }
201
+ @media (prefers-color-scheme: dark) {
202
+ :root:has(.page:not(.scheme-light)) {
203
+ --s-ground: oklch(0.16 0 0);
168
204
  }
169
205
  }
206
+ ::view-transition {
207
+ background: var(--s-ground, Canvas);
208
+ }
170
209
 
171
210
  /* Nothing fades: for a thing with a name, the new one is what is seen, from the first frame. */
172
211
  ::view-transition-new(*) {
@@ -177,7 +216,7 @@
177
216
  display: none;
178
217
  }
179
218
 
180
- /* A named thing whose place changes moves there with the window: `--s-travel` and `--s-glide`. */
219
+ /* A named thing whose place changes moves there in the time a view takes to turn: `--s-travel` and `--s-glide`. */
181
220
  ::view-transition-group(*) {
182
221
  animation-duration: 260ms;
183
222
  animation-timing-function: cubic-bezier(0.6, 0, 0.2, 1);
@@ -191,49 +230,48 @@
191
230
 
192
231
  /* The durations and the curve are `--s-travel` and `--s-glide`, which do not reach the `::view-transition` pseudo-elements. */
193
232
  @media (prefers-reduced-motion: no-preference) {
194
- :root:active-view-transition-type(forward, back, down, up)::view-transition-old(root) {
233
+ /* Both views are there, and both turn. */
234
+ :root:active-view-transition-type(in, out)::view-transition-old(root) {
195
235
  display: block;
196
236
  mix-blend-mode: normal;
197
- animation: leave 260ms cubic-bezier(0.6, 0, 0.2, 1) both;
198
237
  }
199
238
 
200
- :root:active-view-transition-type(forward, back, down, up)::view-transition-new(root) {
201
- animation: enter 260ms cubic-bezier(0.6, 0, 0.2, 1) both;
239
+ :root:active-view-transition-type(in, out)::view-transition-old(root),
240
+ :root:active-view-transition-type(in, out)::view-transition-new(root) {
241
+ transform-origin: var(--s-post-x, 0px) var(--s-post-y, 50%);
242
+ clip-path: var(--s-clear, none);
202
243
  }
203
244
 
204
245
  /*
205
- * The arrow of a navigator's button that goes back says where on the
206
- * canvas the page before this one is, so it belongs to the page and not
207
- * to the window: it leaves with the page that is left, and the next
208
- * page's arrow comes in with that page, the same way and edge to edge.
209
- * Its button is the window it is seen through, and is one whole step.
246
+ * The two views are not kept together in a layer of their own: each has
247
+ * its own place among the things that stay, one over them all and one
248
+ * under them all.
210
249
  */
211
- :root:active-view-transition-type(forward, back, down, up)::view-transition-group(s-ui-navigator-back) {
212
- overflow: clip;
213
- }
214
-
215
- :root:active-view-transition-type(forward, back, down, up)::view-transition-old(s-ui-navigator-back) {
216
- display: block;
217
- mix-blend-mode: normal;
218
- animation: leave 260ms cubic-bezier(0.6, 0, 0.2, 1) both;
250
+ :root:active-view-transition-type(in, out)::view-transition-group(root) {
251
+ animation: none;
219
252
  }
220
-
221
- :root:active-view-transition-type(forward, back, down, up)::view-transition-new(s-ui-navigator-back) {
222
- animation: enter 260ms cubic-bezier(0.6, 0, 0.2, 1) both;
253
+ :root:active-view-transition-type(in, out)::view-transition-image-pair(root) {
254
+ isolation: auto;
223
255
  }
224
256
 
225
- /* One whole window, across or down. */
226
- :root:active-view-transition-type(forward) {
227
- --s-travel-x: -100%;
257
+ /* In: the new view turns in from the front, over the old one, which turns on to the back. */
258
+ :root:active-view-transition-type(in)::view-transition-new(root) {
259
+ z-index: 1;
260
+ animation: turn-in 260ms cubic-bezier(0.6, 0, 0.2, 1) both;
228
261
  }
229
- :root:active-view-transition-type(back) {
230
- --s-travel-x: 100%;
262
+ :root:active-view-transition-type(in)::view-transition-old(root) {
263
+ z-index: -1;
264
+ animation: turn-away 260ms cubic-bezier(0.6, 0, 0.2, 1) both;
231
265
  }
232
- :root:active-view-transition-type(down) {
233
- --s-travel-y: -100%;
266
+
267
+ /* Out: the old view turns out to the front, off the new one, which comes back from behind. */
268
+ :root:active-view-transition-type(out)::view-transition-old(root) {
269
+ z-index: 1;
270
+ animation: turn-out 260ms cubic-bezier(0.6, 0, 0.2, 1) both;
234
271
  }
235
- :root:active-view-transition-type(up) {
236
- --s-travel-y: 100%;
272
+ :root:active-view-transition-type(out)::view-transition-new(root) {
273
+ z-index: -1;
274
+ animation: turn-back 260ms cubic-bezier(0.6, 0, 0.2, 1) both;
237
275
  }
238
276
  }
239
277
 
@@ -1,9 +1,11 @@
1
1
  declare const styles: {
2
- readonly "enter": string;
3
- readonly "leave": string;
4
2
  readonly "page": string;
5
3
  readonly "scheme-dark": string;
6
4
  readonly "scheme-light": string;
5
+ readonly "turn-away": string;
6
+ readonly "turn-back": string;
7
+ readonly "turn-in": string;
8
+ readonly "turn-out": string;
7
9
  };
8
10
  export = styles;
9
11
 
@@ -3,17 +3,98 @@
3
3
  *
4
4
  * @since 0.4.0
5
5
  */
6
+ import { Effect, Queue, Stream } from "effect"
7
+ import { Component, Mount } from "effect/ui"
6
8
  import type { Html } from "effect/ui/html"
7
9
  import { type Child, contents as inner, type Kind, node, type Node } from "../../Node.ts"
8
10
  import { accent, on } from "../tokens/classes.ts"
9
11
  import styles from "./page.module.css"
10
12
  import type { Colour, Scheme } from "../tokens/tokens.ts"
11
13
 
14
+ /** How many times as long a movement takes while Shift is held down. */
15
+ const slowness = 10
16
+
17
+ /**
18
+ * Makes every movement take ten times as long for as long as Shift is held
19
+ * down, so that it can be looked at: a transition, an animation, a change
20
+ * of view. It is the browser's own clock for each of them that is slowed,
21
+ * so one that is on its way when the key goes down is slowed from where it
22
+ * is, and one that starts while the key is down is slowed from its start.
23
+ * When the key comes up, or the window is left, they all go on at their own
24
+ * speed.
25
+ *
26
+ * A browser opens a link in a new window when it is pressed with Shift
27
+ * down. Then nothing would move in this one. So a link of the app pressed
28
+ * with only Shift down is followed here, as it is without Shift. A link
29
+ * that goes somewhere else is left to the browser, and so is one pressed
30
+ * with another of the keys that change what a press does.
31
+ */
32
+ const SlowWithShift = Mount.make("SlowWithShift", { args: {} }, () =>
33
+ Stream.callback<void>((queue) =>
34
+ Effect.acquireRelease(
35
+ Effect.sync(() => {
36
+ const slowed = new Set<Animation>()
37
+ let frame: number | undefined
38
+ // Looked for again on every frame: a movement can start at any time.
39
+ const slow = () => {
40
+ for (const animation of document.getAnimations()) {
41
+ if (slowed.has(animation)) continue
42
+ slowed.add(animation)
43
+ animation.updatePlaybackRate(animation.playbackRate / slowness)
44
+ }
45
+ frame = requestAnimationFrame(slow)
46
+ }
47
+ const release = () => {
48
+ if (frame === undefined) return
49
+ cancelAnimationFrame(frame)
50
+ frame = undefined
51
+ for (const animation of slowed) animation.updatePlaybackRate(animation.playbackRate * slowness)
52
+ slowed.clear()
53
+ Queue.offerUnsafe(queue, undefined)
54
+ }
55
+ const down = (event: KeyboardEvent) => {
56
+ if (event.key === "Shift" && frame === undefined) slow()
57
+ }
58
+ const up = (event: KeyboardEvent) => {
59
+ if (event.key === "Shift") release()
60
+ }
61
+ const follow = (event: MouseEvent) => {
62
+ if (!event.shiftKey || event.ctrlKey || event.metaKey || event.altKey || event.button !== 0) return
63
+ const link = event.target instanceof Element ? event.target.closest("a[href]") : null
64
+ if (!(link instanceof HTMLAnchorElement)) return
65
+ // One of the app's: at this origin, opened in this window, and not a file to keep.
66
+ if (link.origin !== location.origin || link.hasAttribute("download")) return
67
+ if (link.target !== "" && link.target !== "_self") return
68
+ event.preventDefault()
69
+ event.stopImmediatePropagation()
70
+ // Pressed again by the script, which has no Shift down: the router takes it as any other press.
71
+ link.click()
72
+ }
73
+ window.addEventListener("click", follow, { capture: true })
74
+ window.addEventListener("keydown", down, { capture: true, passive: true })
75
+ window.addEventListener("keyup", up, { capture: true, passive: true })
76
+ window.addEventListener("blur", release, { passive: true })
77
+ return () => {
78
+ release()
79
+ window.removeEventListener("click", follow, { capture: true })
80
+ window.removeEventListener("keydown", down, { capture: true })
81
+ window.removeEventListener("keyup", up, { capture: true })
82
+ window.removeEventListener("blur", release)
83
+ }
84
+ }),
85
+ (stop) => Effect.sync(stop)
86
+ )
87
+ ).pipe(Stream.runDrain, Effect.as(Component.noop))
88
+ )
89
+
12
90
  export const page = <Msg>(h: Html.H<Msg>) => ({
13
91
  /**
14
92
  * The root of a page: sets the type, the ground and the accent colour, and
15
93
  * its width is what the columns collapse against. `scheme` sets the light
16
- * or the dark scheme; left out, it follows the reader's system.
94
+ * or the dark scheme; left out, it follows the reader's system. While
95
+ * Shift is held down, every movement in the window takes ten times as
96
+ * long, so that it can be looked at, and a link of the app is followed
97
+ * in this window, not opened in a new one.
17
98
  */
18
99
  page: <R = never>(
19
100
  options: { readonly accent?: Colour; readonly scheme?: Scheme },
@@ -27,6 +108,7 @@ export const page = <Msg>(h: Html.H<Msg>) => ({
27
108
  options.scheme === "light" && styles["scheme-light"],
28
109
  options.scheme === "dark" && styles["scheme-dark"]
29
110
  )
111
+ .onMount(SlowWithShift({}))
30
112
  .children(inner(children))
31
113
  )
32
114
  })