@nmnmcc/standard 0.0.0-stage → 0.4.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 (260) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +516 -2
  3. package/dist/Extend.d.ts +15 -0
  4. package/dist/Extend.d.ts.map +1 -0
  5. package/dist/Extend.js +1 -0
  6. package/dist/Node.d.ts +71 -0
  7. package/dist/Node.d.ts.map +1 -0
  8. package/dist/Palette-BIJ96BEh.js +84 -0
  9. package/dist/Palette.d.ts +8 -0
  10. package/dist/Palette.d.ts.map +1 -0
  11. package/dist/Palette.js +1 -0
  12. package/dist/Standard-BPpzr5SM.js +488 -0
  13. package/dist/Standard.d.ts +249 -0
  14. package/dist/Standard.d.ts.map +1 -0
  15. package/dist/Standard.js +1 -0
  16. package/dist/Ui-B9xQqqNT.js +468 -0
  17. package/dist/Ui.d.ts +500 -0
  18. package/dist/Ui.d.ts.map +1 -0
  19. package/dist/Ui.js +1 -0
  20. package/dist/index.d.ts +25 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +4 -0
  23. package/dist/rolldown-runtime-BMBA7GOT.js +10 -0
  24. package/dist/standard/button/button.d.ts +21 -0
  25. package/dist/standard/button/button.d.ts.map +1 -0
  26. package/dist/standard/colour/colour.d.ts +93 -0
  27. package/dist/standard/colour/colour.d.ts.map +1 -0
  28. package/dist/standard/field/field.d.ts +91 -0
  29. package/dist/standard/field/field.d.ts.map +1 -0
  30. package/dist/standard/form/form.d.ts +16 -0
  31. package/dist/standard/form/form.d.ts.map +1 -0
  32. package/dist/standard/icon/icon.d.ts +31 -0
  33. package/dist/standard/icon/icon.d.ts.map +1 -0
  34. package/dist/standard/image/image.d.ts +21 -0
  35. package/dist/standard/image/image.d.ts.map +1 -0
  36. package/dist/standard/layout/layout.d.ts +73 -0
  37. package/dist/standard/layout/layout.d.ts.map +1 -0
  38. package/dist/standard/list/list.d.ts +26 -0
  39. package/dist/standard/list/list.d.ts.map +1 -0
  40. package/dist/standard/page/page.d.ts +20 -0
  41. package/dist/standard/page/page.d.ts.map +1 -0
  42. package/dist/standard/table/table.d.ts +18 -0
  43. package/dist/standard/table/table.d.ts.map +1 -0
  44. package/dist/standard/text/text.d.ts +39 -0
  45. package/dist/standard/text/text.d.ts.map +1 -0
  46. package/dist/standard/tokens/classes.d.ts +16 -0
  47. package/dist/standard/tokens/classes.d.ts.map +1 -0
  48. package/dist/standard/tokens/tokens.d.ts +162 -0
  49. package/dist/standard/tokens/tokens.d.ts.map +1 -0
  50. package/dist/standard.css +2 -0
  51. package/dist/ui/arrow/arrow.d.ts +18 -0
  52. package/dist/ui/arrow/arrow.d.ts.map +1 -0
  53. package/dist/ui/avatar/avatar.d.ts +15 -0
  54. package/dist/ui/avatar/avatar.d.ts.map +1 -0
  55. package/dist/ui/board/board.d.ts +34 -0
  56. package/dist/ui/board/board.d.ts.map +1 -0
  57. package/dist/ui/bullet/bullet.d.ts +15 -0
  58. package/dist/ui/bullet/bullet.d.ts.map +1 -0
  59. package/dist/ui/card/card.d.ts +24 -0
  60. package/dist/ui/card/card.d.ts.map +1 -0
  61. package/dist/ui/carousel/carousel.d.ts +17 -0
  62. package/dist/ui/carousel/carousel.d.ts.map +1 -0
  63. package/dist/ui/check/check.d.ts +20 -0
  64. package/dist/ui/check/check.d.ts.map +1 -0
  65. package/dist/ui/choice/choice.d.ts +19 -0
  66. package/dist/ui/choice/choice.d.ts.map +1 -0
  67. package/dist/ui/control/control.d.ts +57 -0
  68. package/dist/ui/control/control.d.ts.map +1 -0
  69. package/dist/ui/dialog/dialog.d.ts +30 -0
  70. package/dist/ui/dialog/dialog.d.ts.map +1 -0
  71. package/dist/ui/disclosure/disclosure.d.ts +20 -0
  72. package/dist/ui/disclosure/disclosure.d.ts.map +1 -0
  73. package/dist/ui/flap/flap.d.ts +18 -0
  74. package/dist/ui/flap/flap.d.ts.map +1 -0
  75. package/dist/ui/item/item.d.ts +21 -0
  76. package/dist/ui/item/item.d.ts.map +1 -0
  77. package/dist/ui/key/key.d.ts +12 -0
  78. package/dist/ui/key/key.d.ts.map +1 -0
  79. package/dist/ui/menu/menu.d.ts +26 -0
  80. package/dist/ui/menu/menu.d.ts.map +1 -0
  81. package/dist/ui/modal/modal.d.ts +22 -0
  82. package/dist/ui/modal/modal.d.ts.map +1 -0
  83. package/dist/ui/navigator/navigator.d.ts +137 -0
  84. package/dist/ui/navigator/navigator.d.ts.map +1 -0
  85. package/dist/ui/notice/notice.d.ts +34 -0
  86. package/dist/ui/notice/notice.d.ts.map +1 -0
  87. package/dist/ui/options/options.d.ts +19 -0
  88. package/dist/ui/options/options.d.ts.map +1 -0
  89. package/dist/ui/pager/pager.d.ts +29 -0
  90. package/dist/ui/pager/pager.d.ts.map +1 -0
  91. package/dist/ui/pagination/pagination.d.ts +14 -0
  92. package/dist/ui/pagination/pagination.d.ts.map +1 -0
  93. package/dist/ui/popover/popover.d.ts +20 -0
  94. package/dist/ui/popover/popover.d.ts.map +1 -0
  95. package/dist/ui/progress/progress.d.ts +17 -0
  96. package/dist/ui/progress/progress.d.ts.map +1 -0
  97. package/dist/ui/route/route.d.ts +27 -0
  98. package/dist/ui/route/route.d.ts.map +1 -0
  99. package/dist/ui/sheet/sheet.d.ts +35 -0
  100. package/dist/ui/sheet/sheet.d.ts.map +1 -0
  101. package/dist/ui/skeleton/skeleton.d.ts +15 -0
  102. package/dist/ui/skeleton/skeleton.d.ts.map +1 -0
  103. package/dist/ui/slider/slider.d.ts +23 -0
  104. package/dist/ui/slider/slider.d.ts.map +1 -0
  105. package/dist/ui/stepper/stepper.d.ts +32 -0
  106. package/dist/ui/stepper/stepper.d.ts.map +1 -0
  107. package/dist/ui/tabs/tabs.d.ts +22 -0
  108. package/dist/ui/tabs/tabs.d.ts.map +1 -0
  109. package/dist/ui/tag/tag.d.ts +17 -0
  110. package/dist/ui/tag/tag.d.ts.map +1 -0
  111. package/dist/ui/tile/tile.d.ts +38 -0
  112. package/dist/ui/tile/tile.d.ts.map +1 -0
  113. package/dist/ui/toasts/toasts.d.ts +17 -0
  114. package/dist/ui/toasts/toasts.d.ts.map +1 -0
  115. package/dist/ui/toggle/toggle.d.ts +17 -0
  116. package/dist/ui/toggle/toggle.d.ts.map +1 -0
  117. package/dist/ui/trail/trail.d.ts +22 -0
  118. package/dist/ui/trail/trail.d.ts.map +1 -0
  119. package/package.json +70 -3
  120. package/src/Extend.ts +14 -0
  121. package/src/Node.ts +44 -0
  122. package/src/Palette.ts +7 -0
  123. package/src/Standard.ts +109 -0
  124. package/src/Ui.ts +156 -0
  125. package/src/index.ts +27 -0
  126. package/src/standard/button/button.module.css +43 -0
  127. package/src/standard/button/button.module.d.css.ts +6 -0
  128. package/src/standard/button/button.ts +38 -0
  129. package/src/standard/colour/colour.ts +197 -0
  130. package/src/standard/field/field.module.css +222 -0
  131. package/src/standard/field/field.module.d.css.ts +13 -0
  132. package/src/standard/field/field.ts +266 -0
  133. package/src/standard/form/form.ts +25 -0
  134. package/src/standard/icon/icon.module.css +349 -0
  135. package/src/standard/icon/icon.module.d.css.ts +112 -0
  136. package/src/standard/icon/icon.ts +148 -0
  137. package/src/standard/image/image.module.css +42 -0
  138. package/src/standard/image/image.module.d.css.ts +12 -0
  139. package/src/standard/image/image.ts +39 -0
  140. package/src/standard/layout/layout.module.css +224 -0
  141. package/src/standard/layout/layout.module.d.css.ts +41 -0
  142. package/src/standard/layout/layout.ts +133 -0
  143. package/src/standard/list/list.module.css +71 -0
  144. package/src/standard/list/list.module.d.css.ts +10 -0
  145. package/src/standard/list/list.ts +53 -0
  146. package/src/standard/page/page.module.css +244 -0
  147. package/src/standard/page/page.module.d.css.ts +9 -0
  148. package/src/standard/page/page.ts +32 -0
  149. package/src/standard/table/table.module.css +40 -0
  150. package/src/standard/table/table.module.d.css.ts +6 -0
  151. package/src/standard/table/table.ts +36 -0
  152. package/src/standard/text/text.module.css +149 -0
  153. package/src/standard/text/text.module.d.css.ts +19 -0
  154. package/src/standard/text/text.ts +77 -0
  155. package/src/standard/tokens/classes.ts +31 -0
  156. package/src/standard/tokens/tokens.module.css +294 -0
  157. package/src/standard/tokens/tokens.module.d.css.ts +40 -0
  158. package/src/standard/tokens/tokens.ts +339 -0
  159. package/src/ui/arrow/arrow.module.css +38 -0
  160. package/src/ui/arrow/arrow.module.d.css.ts +13 -0
  161. package/src/ui/arrow/arrow.ts +35 -0
  162. package/src/ui/avatar/avatar.module.css +25 -0
  163. package/src/ui/avatar/avatar.module.d.css.ts +5 -0
  164. package/src/ui/avatar/avatar.ts +28 -0
  165. package/src/ui/board/board.module.css +94 -0
  166. package/src/ui/board/board.module.d.css.ts +10 -0
  167. package/src/ui/board/board.ts +84 -0
  168. package/src/ui/bullet/bullet.module.css +28 -0
  169. package/src/ui/bullet/bullet.module.d.css.ts +5 -0
  170. package/src/ui/bullet/bullet.ts +16 -0
  171. package/src/ui/card/card.module.css +80 -0
  172. package/src/ui/card/card.module.d.css.ts +6 -0
  173. package/src/ui/card/card.ts +42 -0
  174. package/src/ui/carousel/carousel.module.css +24 -0
  175. package/src/ui/carousel/carousel.module.d.css.ts +5 -0
  176. package/src/ui/carousel/carousel.ts +30 -0
  177. package/src/ui/check/check.module.css +53 -0
  178. package/src/ui/check/check.module.d.css.ts +8 -0
  179. package/src/ui/check/check.ts +46 -0
  180. package/src/ui/choice/choice.module.css +32 -0
  181. package/src/ui/choice/choice.module.d.css.ts +6 -0
  182. package/src/ui/choice/choice.ts +31 -0
  183. package/src/ui/control/control.module.css +127 -0
  184. package/src/ui/control/control.module.d.css.ts +12 -0
  185. package/src/ui/control/control.ts +97 -0
  186. package/src/ui/dialog/dialog.module.css +42 -0
  187. package/src/ui/dialog/dialog.module.d.css.ts +6 -0
  188. package/src/ui/dialog/dialog.ts +44 -0
  189. package/src/ui/disclosure/disclosure.module.css +57 -0
  190. package/src/ui/disclosure/disclosure.module.d.css.ts +7 -0
  191. package/src/ui/disclosure/disclosure.ts +32 -0
  192. package/src/ui/flap/flap.module.css +161 -0
  193. package/src/ui/flap/flap.module.d.css.ts +48 -0
  194. package/src/ui/flap/flap.ts +78 -0
  195. package/src/ui/item/item.module.css +39 -0
  196. package/src/ui/item/item.module.d.css.ts +7 -0
  197. package/src/ui/item/item.ts +33 -0
  198. package/src/ui/key/key.module.css +15 -0
  199. package/src/ui/key/key.module.d.css.ts +5 -0
  200. package/src/ui/key/key.ts +13 -0
  201. package/src/ui/menu/menu.module.css +11 -0
  202. package/src/ui/menu/menu.module.d.css.ts +5 -0
  203. package/src/ui/menu/menu.ts +48 -0
  204. package/src/ui/modal/modal.module.css +66 -0
  205. package/src/ui/modal/modal.module.d.css.ts +8 -0
  206. package/src/ui/modal/modal.ts +55 -0
  207. package/src/ui/navigator/navigator.module.css +658 -0
  208. package/src/ui/navigator/navigator.module.d.css.ts +39 -0
  209. package/src/ui/navigator/navigator.ts +337 -0
  210. package/src/ui/notice/notice.module.css +80 -0
  211. package/src/ui/notice/notice.module.d.css.ts +10 -0
  212. package/src/ui/notice/notice.ts +57 -0
  213. package/src/ui/options/options.module.css +30 -0
  214. package/src/ui/options/options.module.d.css.ts +6 -0
  215. package/src/ui/options/options.ts +31 -0
  216. package/src/ui/pager/pager.module.css +38 -0
  217. package/src/ui/pager/pager.module.d.css.ts +8 -0
  218. package/src/ui/pager/pager.ts +48 -0
  219. package/src/ui/pagination/pagination.module.css +38 -0
  220. package/src/ui/pagination/pagination.module.d.css.ts +7 -0
  221. package/src/ui/pagination/pagination.ts +52 -0
  222. package/src/ui/popover/popover.module.css +94 -0
  223. package/src/ui/popover/popover.module.d.css.ts +8 -0
  224. package/src/ui/popover/popover.ts +139 -0
  225. package/src/ui/progress/progress.module.css +69 -0
  226. package/src/ui/progress/progress.module.d.css.ts +6 -0
  227. package/src/ui/progress/progress.ts +26 -0
  228. package/src/ui/route/route.module.css +116 -0
  229. package/src/ui/route/route.module.d.css.ts +11 -0
  230. package/src/ui/route/route.ts +58 -0
  231. package/src/ui/sheet/sheet.module.css +194 -0
  232. package/src/ui/sheet/sheet.module.d.css.ts +7 -0
  233. package/src/ui/sheet/sheet.ts +47 -0
  234. package/src/ui/skeleton/skeleton.module.css +44 -0
  235. package/src/ui/skeleton/skeleton.module.d.css.ts +6 -0
  236. package/src/ui/skeleton/skeleton.ts +20 -0
  237. package/src/ui/slider/slider.module.css +56 -0
  238. package/src/ui/slider/slider.module.d.css.ts +6 -0
  239. package/src/ui/slider/slider.ts +48 -0
  240. package/src/ui/stepper/stepper.module.css +32 -0
  241. package/src/ui/stepper/stepper.module.d.css.ts +7 -0
  242. package/src/ui/stepper/stepper.ts +62 -0
  243. package/src/ui/tabs/tabs.module.css +38 -0
  244. package/src/ui/tabs/tabs.module.d.css.ts +6 -0
  245. package/src/ui/tabs/tabs.ts +24 -0
  246. package/src/ui/tag/tag.module.css +23 -0
  247. package/src/ui/tag/tag.module.d.css.ts +5 -0
  248. package/src/ui/tag/tag.ts +17 -0
  249. package/src/ui/tile/tile.module.css +137 -0
  250. package/src/ui/tile/tile.module.d.css.ts +13 -0
  251. package/src/ui/tile/tile.ts +69 -0
  252. package/src/ui/toasts/toasts.module.css +38 -0
  253. package/src/ui/toasts/toasts.module.d.css.ts +6 -0
  254. package/src/ui/toasts/toasts.ts +26 -0
  255. package/src/ui/toggle/toggle.module.css +46 -0
  256. package/src/ui/toggle/toggle.module.d.css.ts +6 -0
  257. package/src/ui/toggle/toggle.ts +29 -0
  258. package/src/ui/trail/trail.module.css +42 -0
  259. package/src/ui/trail/trail.module.d.css.ts +5 -0
  260. package/src/ui/trail/trail.ts +28 -0
@@ -0,0 +1,294 @@
1
+ /*
2
+ * The tokens: the colours, the grounds and the distances, each a class that sets a custom property.
3
+ *
4
+ * Every stylesheet of the package is a CSS Module: the builders import its class
5
+ * names, typed, and emit nothing else. A class of the language is published
6
+ * as `s-<name>`, one of the components as `s-ui-<name>`.
7
+ */
8
+
9
+ /* The order of the layers, said once, before any of them. */
10
+ @layer standard.reset, standard.tokens, standard.layout, standard.type, standard.controls, standard.ui;
11
+
12
+ /* Registered so that they do not inherit: a column's span or gap is the column's own, not its children's. */
13
+ @property --s-span {
14
+ syntax: "<integer>";
15
+ inherits: false;
16
+ initial-value: 12;
17
+ }
18
+ @property --s-start {
19
+ syntax: "<integer>";
20
+ inherits: false;
21
+ initial-value: 1;
22
+ }
23
+ @property --s-gap {
24
+ syntax: "<length>";
25
+ inherits: false;
26
+ initial-value: 0px;
27
+ }
28
+ @property --s-pad {
29
+ syntax: "<length>";
30
+ inherits: false;
31
+ initial-value: 0px;
32
+ }
33
+ @property --s-align {
34
+ syntax: "start | end | baseline | stretch";
35
+ inherits: false;
36
+ initial-value: stretch;
37
+ }
38
+ /* A colour of the palette: a block of it, what is written on the block, and the colour as text on the white and on the black. */
39
+ @property --s-accent {
40
+ syntax: "<color>";
41
+ inherits: true;
42
+ initial-value: #e02421;
43
+ }
44
+ @property --s-on-accent {
45
+ syntax: "<color>";
46
+ inherits: true;
47
+ initial-value: #fbfaf8;
48
+ }
49
+ @property --s-accent-soft {
50
+ syntax: "<color>";
51
+ inherits: true;
52
+ initial-value: #fbfaf8;
53
+ }
54
+ @property --s-accent-on-white {
55
+ syntax: "<color>";
56
+ inherits: true;
57
+ initial-value: #c2000c;
58
+ }
59
+ @property --s-accent-on-black {
60
+ syntax: "<color>";
61
+ inherits: true;
62
+ initial-value: #fc463c;
63
+ }
64
+ /* What the ground is: 1 where it is dark, and 1 where it is a block of colour. What can be read on a ground is worked out from these. And 1 in the dark scheme. */
65
+ @property --s-night {
66
+ syntax: "<number>";
67
+ inherits: true;
68
+ initial-value: 0;
69
+ }
70
+ @property --s-dark {
71
+ syntax: "<number>";
72
+ inherits: true;
73
+ initial-value: 0;
74
+ }
75
+ @property --s-flat {
76
+ syntax: "<number>";
77
+ inherits: true;
78
+ initial-value: 0;
79
+ }
80
+
81
+ @layer standard.tokens {
82
+ /*
83
+ * The palette. No value here was picked by eye: each line is what
84
+ * `colour.ts` works out from a hue, and the tests keep the two in step.
85
+ * A block (`--s-accent`) has all the chroma its lightness allows; what
86
+ * is written on it (`--s-on-accent`, and `--s-accent-soft` for muted
87
+ * text) can be read; and so can the colour as text on the white
88
+ * and on the black, which are paper and ink in the light scheme and swap
89
+ * places in the dark.
90
+ */
91
+ .accent-red {
92
+ --s-accent: #e02421;
93
+ --s-on-accent: var(--s-white);
94
+ --s-accent-soft: #fbfaf8;
95
+ --s-accent-on-white: #c2000c;
96
+ --s-accent-on-black: #fc463c;
97
+ }
98
+ .accent-orange {
99
+ --s-accent: #fe8400;
100
+ --s-on-accent: var(--s-black);
101
+ --s-accent-soft: #3a2517;
102
+ --s-accent-on-white: #954b00;
103
+ --s-accent-on-black: #fe8400;
104
+ }
105
+ .accent-yellow {
106
+ --s-accent: #fedd00;
107
+ --s-on-accent: var(--s-black);
108
+ --s-accent-soft: #584f20;
109
+ --s-accent-on-white: #6e5f00;
110
+ --s-accent-on-black: #fedd00;
111
+ }
112
+ .accent-green {
113
+ --s-accent: #00e26a;
114
+ --s-on-accent: var(--s-black);
115
+ --s-accent-soft: #1f482a;
116
+ --s-accent-on-white: #006f30;
117
+ --s-accent-on-black: #00e26a;
118
+ }
119
+ .accent-teal {
120
+ --s-accent: #00f4fe;
121
+ --s-on-accent: var(--s-black);
122
+ --s-accent-soft: #235658;
123
+ --s-accent-on-white: #006a6f;
124
+ --s-accent-on-black: #00f3fd;
125
+ }
126
+ .accent-blue {
127
+ --s-accent: #236af5;
128
+ --s-on-accent: var(--s-white);
129
+ --s-accent-soft: #fbfaf8;
130
+ --s-accent-on-white: #0953dc;
131
+ --s-accent-on-black: #4785ff;
132
+ }
133
+ .accent-purple {
134
+ --s-accent: #9a4ae0;
135
+ --s-on-accent: var(--s-white);
136
+ --s-accent-soft: #fbfaf8;
137
+ --s-accent-on-white: #8531c9;
138
+ --s-accent-on-black: #b264fb;
139
+ }
140
+ .accent-grey {
141
+ --s-accent: #747474;
142
+ --s-on-accent: var(--s-white);
143
+ --s-accent-soft: #fbfaf8;
144
+ --s-accent-on-white: #5f5f5f;
145
+ --s-accent-on-black: #8a8a8a;
146
+ }
147
+
148
+ /*
149
+ * The grounds. Paper is what the page is printed on and ink what it is
150
+ * printed in: light and dark in the light, dark and light in the dark.
151
+ * Each ground says what is printed on it (`--s-fg`), the colour as a
152
+ * block and what is written on that (`--s-mark`, `--s-on-mark`), and
153
+ * whether it is dark, and whether it is a block of colour.
154
+ */
155
+ .tone-paper {
156
+ --s-bg: var(--s-paper);
157
+ --s-fg: var(--s-ink);
158
+ --s-mark: var(--s-accent);
159
+ --s-on-mark: var(--s-on-accent);
160
+ --s-dark: var(--s-night);
161
+ --s-flat: 0;
162
+ }
163
+ .tone-ink {
164
+ --s-bg: var(--s-ink);
165
+ --s-fg: var(--s-paper);
166
+ --s-mark: var(--s-accent);
167
+ --s-on-mark: var(--s-on-accent);
168
+ --s-dark: calc(1 - var(--s-night));
169
+ --s-flat: 0;
170
+ }
171
+ .tone-accent {
172
+ --s-bg: var(--s-accent);
173
+ --s-fg: var(--s-on-accent);
174
+ --s-mark: var(--s-on-accent);
175
+ --s-on-mark: var(--s-accent);
176
+ --s-flat: 1;
177
+ }
178
+
179
+ /*
180
+ * What can be read on a ground, wherever one is set: the colour as text
181
+ * (`--s-read`) and muted text (`--s-muted`). On a dark ground,
182
+ * the ones for the black; on a light one, the ones for the white; on a
183
+ * block of colour, what the block carries. A `color-mix` at 0% or at
184
+ * 100% picks one of two colours whole: nothing here is a blend.
185
+ *
186
+ * And the colour that says something is wrong (`--s-wrong`): the red, as
187
+ * text, whatever the accent is. An error set in the accent would be green
188
+ * on a green page, and green says the opposite.
189
+ */
190
+ :global(.s-page),
191
+ .tone-paper,
192
+ .tone-ink,
193
+ .tone-accent,
194
+ :global(.s-section)[class*="accent-"],
195
+ :global(.s-ui-notice),
196
+ :global(.s-ui-sheet) {
197
+ --s-read: color-mix(
198
+ in srgb,
199
+ var(--s-fg) calc(var(--s-flat) * 100%),
200
+ color-mix(in srgb, var(--s-accent-on-black) calc(var(--s-dark) * 100%), var(--s-accent-on-white))
201
+ );
202
+ --s-muted: color-mix(
203
+ in srgb,
204
+ var(--s-accent-soft) calc(var(--s-flat) * 100%),
205
+ color-mix(in srgb, var(--s-soft-on-black) calc(var(--s-dark) * 100%), var(--s-soft-on-white))
206
+ );
207
+ --s-wrong: color-mix(
208
+ in srgb,
209
+ var(--s-fg) calc(var(--s-flat) * 100%),
210
+ color-mix(in srgb, var(--s-wrong-on-black) calc(var(--s-dark) * 100%), var(--s-wrong-on-white))
211
+ );
212
+ }
213
+
214
+ /* A region whose text is there to be taken: read closely, quoted, copied. What is pressed in it still isn't. */
215
+ .selectable {
216
+ user-select: text;
217
+ -webkit-user-select: text;
218
+ }
219
+
220
+ .gap-0 {
221
+ --s-gap: 0px;
222
+ }
223
+ .gap-1 {
224
+ --s-gap: calc(1 * var(--s-unit));
225
+ }
226
+ .gap-2 {
227
+ --s-gap: calc(2 * var(--s-unit));
228
+ }
229
+ .gap-3 {
230
+ --s-gap: calc(3 * var(--s-unit));
231
+ }
232
+ .gap-4 {
233
+ --s-gap: calc(4 * var(--s-unit));
234
+ }
235
+ .gap-6 {
236
+ --s-gap: calc(6 * var(--s-unit));
237
+ }
238
+ .gap-8 {
239
+ --s-gap: calc(8 * var(--s-unit));
240
+ }
241
+ .gap-12 {
242
+ --s-gap: calc(12 * var(--s-unit));
243
+ }
244
+ .gap-16 {
245
+ --s-gap: calc(16 * var(--s-unit));
246
+ }
247
+ .gap-24 {
248
+ --s-gap: calc(24 * var(--s-unit));
249
+ }
250
+
251
+ .pad-0 {
252
+ --s-pad: 0px;
253
+ }
254
+ .pad-1 {
255
+ --s-pad: calc(1 * var(--s-unit));
256
+ }
257
+ .pad-2 {
258
+ --s-pad: calc(2 * var(--s-unit));
259
+ }
260
+ .pad-3 {
261
+ --s-pad: calc(3 * var(--s-unit));
262
+ }
263
+ .pad-4 {
264
+ --s-pad: calc(4 * var(--s-unit));
265
+ }
266
+ .pad-6 {
267
+ --s-pad: calc(6 * var(--s-unit));
268
+ }
269
+ .pad-8 {
270
+ --s-pad: calc(8 * var(--s-unit));
271
+ }
272
+ .pad-12 {
273
+ --s-pad: calc(12 * var(--s-unit));
274
+ }
275
+ .pad-16 {
276
+ --s-pad: calc(16 * var(--s-unit));
277
+ }
278
+ .pad-24 {
279
+ --s-pad: calc(24 * var(--s-unit));
280
+ }
281
+
282
+ .align-start {
283
+ --s-align: start;
284
+ }
285
+ .align-end {
286
+ --s-align: end;
287
+ }
288
+ .align-baseline {
289
+ --s-align: baseline;
290
+ }
291
+ .align-stretch {
292
+ --s-align: stretch;
293
+ }
294
+ }
@@ -0,0 +1,40 @@
1
+ declare const styles: {
2
+ readonly "accent-blue": string;
3
+ readonly "accent-green": string;
4
+ readonly "accent-grey": string;
5
+ readonly "accent-orange": string;
6
+ readonly "accent-purple": string;
7
+ readonly "accent-red": string;
8
+ readonly "accent-teal": string;
9
+ readonly "accent-yellow": string;
10
+ readonly "align-baseline": string;
11
+ readonly "align-end": string;
12
+ readonly "align-start": string;
13
+ readonly "align-stretch": string;
14
+ readonly "gap-0": string;
15
+ readonly "gap-1": string;
16
+ readonly "gap-12": string;
17
+ readonly "gap-16": string;
18
+ readonly "gap-2": string;
19
+ readonly "gap-24": string;
20
+ readonly "gap-3": string;
21
+ readonly "gap-4": string;
22
+ readonly "gap-6": string;
23
+ readonly "gap-8": string;
24
+ readonly "pad-0": string;
25
+ readonly "pad-1": string;
26
+ readonly "pad-12": string;
27
+ readonly "pad-16": string;
28
+ readonly "pad-2": string;
29
+ readonly "pad-24": string;
30
+ readonly "pad-3": string;
31
+ readonly "pad-4": string;
32
+ readonly "pad-6": string;
33
+ readonly "pad-8": string;
34
+ readonly "selectable": string;
35
+ readonly "tone-accent": string;
36
+ readonly "tone-ink": string;
37
+ readonly "tone-paper": string;
38
+ };
39
+ export = styles;
40
+
@@ -0,0 +1,339 @@
1
+ /**
2
+ * The tokens: every visual choice a builder takes is one of these.
3
+ *
4
+ * @since 0.4.0
5
+ */
6
+ import { Schema } from "effect"
7
+
8
+ /** How many of the twelve columns something takes, or the column it starts at. */
9
+ export const Span = Schema.Literals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
10
+ export type Span = typeof Span.Type
11
+
12
+ /** A distance, in units of half a baseline (8px at the default size). */
13
+ export const Space = Schema.Literals([0, 1, 2, 3, 4, 6, 8, 12, 16, 24])
14
+ export type Space = typeof Space.Type
15
+
16
+ /**
17
+ * The colours. Swiss Style does not limit how much colour is used: it asks
18
+ * that colour be flat and mean something. Any region can pick its own.
19
+ */
20
+ export const Colour = Schema.Literals(["red", "orange", "yellow", "green", "teal", "blue", "purple", "grey"])
21
+ export type Colour = typeof Colour.Type
22
+
23
+ /**
24
+ * Whether a page is in the light or the dark scheme. In the light it is
25
+ * ink on paper; in the dark the two swap places, and everything set in
26
+ * them follows. `auto` is the scheme the reader has chosen in their system
27
+ * settings.
28
+ */
29
+ export const Scheme = Schema.Literals(["auto", "light", "dark"])
30
+ export type Scheme = typeof Scheme.Type
31
+
32
+ /** The ground a region is set on. Paper is what the page is printed on, and ink what it is printed in. */
33
+ export const Tone = Schema.Literals(["paper", "ink", "accent"])
34
+ export type Tone = typeof Tone.Type
35
+
36
+ /** The steps of the type scale. */
37
+ export const Role = Schema.Literals(["display", "title", "heading", "lead", "body", "caption", "label"])
38
+ export type Role = typeof Role.Type
39
+
40
+ /** How a run of text differs from the text around it. */
41
+ export const Emphasis = Schema.Literals(["strong", "muted", "accent"])
42
+ export type Emphasis = typeof Emphasis.Type
43
+
44
+ /** Where things sit on the cross axis of their layout. Never the centre. */
45
+ export const Align = Schema.Literals(["start", "end", "baseline", "stretch"])
46
+ export type Align = typeof Align.Type
47
+
48
+ /** The aspect ratio of an image. */
49
+ export const Ratio = Schema.Literals(["1/1", "4/3", "3/2", "16/9", "3/4", "2/3"])
50
+ export type Ratio = typeof Ratio.Type
51
+
52
+ /**
53
+ * The way the window moves over the canvas in a change of view, for
54
+ * `$.viewTransition(travel)` in `update`: `forward` and `back` along the
55
+ * line of reading, `down` and `up` along the page, and one of each for a
56
+ * diagonal. `Standard.travel` works it out from the route table.
57
+ */
58
+ export const Travel = Schema.Literals(["forward", "back", "down", "up"])
59
+ export type Travel = typeof Travel.Type
60
+
61
+ /** A route table, as `Route.union` of `effect/ui` makes it: all that `travel` and `canvas` read of one. */
62
+ export interface Routes {
63
+ readonly routes: {
64
+ readonly [tag: string]: { readonly path: string; readonly params: { readonly [name: string]: unknown } }
65
+ }
66
+ readonly catchAll: string | undefined
67
+ readonly Type: { readonly _tag: string }
68
+ }
69
+
70
+ /** The segments of a route's path: `"/read/topics/:id"` is `["read", "topics", ":id"]`, and `"/"` is none. */
71
+ const segmentsOf = (path: string): ReadonlyArray<string> => path.split("/").filter((segment) => segment !== "")
72
+
73
+ const signOf = (n: number): -1 | 0 | 1 => (n > 0 ? 1 : n < 0 ? -1 : 0)
74
+
75
+ /** The order a list of them would be read in: `"B9"` before `"B10"`, and `"2026-11-24"` before `"2026-12-02"`. */
76
+ const reading = new Intl.Collator("en", { numeric: true })
77
+
78
+ /** Which of two values of a param comes first: numbers as numbers, anything else as it would be listed. */
79
+ const inOrder = (from: unknown, to: unknown): -1 | 0 | 1 =>
80
+ typeof from === "number" && typeof to === "number"
81
+ ? signOf(to - from)
82
+ : signOf(reading.compare(String(to), String(from)))
83
+
84
+ /**
85
+ * The way from one route to another, for `$.viewTransition(...)`. An app is
86
+ * one canvas without edges, and the screen is a window onto it: every route
87
+ * has a place there, and a change of route is the window moving from one
88
+ * place to another. What is in the window then slides the other way, as
89
+ * what is seen through a window does when the window moves, and whatever
90
+ * has its own view-transition name, such as a navigator, stays where it is.
91
+ *
92
+ * The place of a route is not for the app to say. The route table says it,
93
+ * and so the addresses of an app have to be written the way its canvas is
94
+ * drawn: `/section/page`, and under a page whatever is under it.
95
+ *
96
+ * - The first segment is the section, and sections lie along the line of
97
+ * reading in the order the table first names them: from `/read/…` to
98
+ * `/settings/…` is `forward`.
99
+ * - The second segment is the page, and the pages of a section lie down
100
+ * the page in the order the table declares them: from `/read/latest` to
101
+ * `/read/archive` is `down`. Every section starts at the top, so from the
102
+ * second page of one to the fifth of another is `forward` and `down`,
103
+ * and to the first of another `forward` and `up`.
104
+ * - Each segment after that is a step `forward` from the page it is under:
105
+ * `/read/topics/:id` is straight along from `/read/topics`. Params that
106
+ * follow one another are one step between them: `/read/latest/:date/:id`
107
+ * is as far along as `/read/topics/:id`.
108
+ * - A param takes as many places as its `Schema.Literals` has literals, in
109
+ * the order they are given. A param of any other Schema takes one place,
110
+ * and two of its values are in the order a list of them would be read
111
+ * in: numbers as numbers, `"B9"` before `"B10"`, `"2026-11-24"` before
112
+ * `"2026-12-02"`. So an address that should lie in the order of its date
113
+ * has the date in it.
114
+ *
115
+ * No way at all when the places are the same.
116
+ *
117
+ * **Example** (Moving the window in `update`)
118
+ *
119
+ * ```ts
120
+ * Navigated: ($, { route }) =>
121
+ * $.evolve({ route }).viewTransition(Standard.travel(AppRoute, $.model.route, route))
122
+ * ```
123
+ *
124
+ * @since 0.4.0
125
+ */
126
+ export const travel = <R extends Routes>(routes: R, from: R["Type"], to: R["Type"]): ReadonlyArray<Travel> => {
127
+ const table = Object.keys(routes.routes).map((tag, order) => ({
128
+ tag,
129
+ order,
130
+ path: segmentsOf(routes.routes[tag]!.path)
131
+ }))
132
+ const a = table.find((route) => route.tag === from._tag)
133
+ const b = table.find((route) => route.tag === to._tag)
134
+ if (a === undefined || b === undefined) return []
135
+
136
+ /** The literals of a param, if its Schema has them, and its value in an address. */
137
+ const literalsOf = (tag: string, segment: string) =>
138
+ (routes.routes[tag]?.params[segment.slice(1)] as { readonly literals?: ReadonlyArray<unknown> } | undefined)
139
+ ?.literals
140
+ const valueOf = (route: R["Type"], segment: string) =>
141
+ (route as { readonly params?: Record<string, unknown> }).params?.[segment === "*" ? "*" : segment.slice(1)]
142
+ const isParam = (segment: string | undefined): segment is string =>
143
+ segment !== undefined && (segment.startsWith(":") || segment === "*")
144
+
145
+ /**
146
+ * How far along a level an address is, counted from the first: among the
147
+ * routes that are with it down to that level, each new segment takes the
148
+ * next place, or as many places as it has literals.
149
+ */
150
+ const placeAt = (level: number, route: (typeof table)[number], address: R["Type"]): number => {
151
+ const places = new Map<string, number>()
152
+ let next = 0
153
+ for (const other of table) {
154
+ if (!other.path.slice(0, level).every((segment, index) => segment === route.path[index])) continue
155
+ if (other.path.length < level) continue
156
+ const segment = other.path[level] ?? ""
157
+ if (places.has(segment)) continue
158
+ places.set(segment, next)
159
+ next += isParam(segment) ? (literalsOf(other.tag, segment)?.length ?? 1) : 1
160
+ }
161
+ const segment = route.path[level] ?? ""
162
+ const literals = isParam(segment) ? literalsOf(route.tag, segment) : undefined
163
+ return (
164
+ (places.get(segment) ?? 0) +
165
+ (literals === undefined ? 0 : Math.max(0, literals.indexOf(valueOf(address, segment))))
166
+ )
167
+ }
168
+
169
+ /** How many steps under its page a route is: one for each segment after the page, and params that follow one another are one step between them. */
170
+ const stepsUnder = (path: ReadonlyArray<string>): number =>
171
+ path.filter((segment, index) => index >= 2 && !(index > 2 && isParam(segment) && isParam(path[index - 1]))).length
172
+
173
+ /** Which way two addresses lie at a level: by their places there, and at one place by the values of its param. */
174
+ const wayAt = (level: number): -1 | 0 | 1 => {
175
+ const way = signOf(placeAt(level, b, to) - placeAt(level, a, from))
176
+ const segment = a.path[level]
177
+ return way !== 0 ||
178
+ !isParam(segment) ||
179
+ segment !== b.path[level] ||
180
+ !together(level) ||
181
+ literalsOf(a.tag, segment) !== undefined
182
+ ? way
183
+ : inOrder(valueOf(from, segment), valueOf(to, segment))
184
+ }
185
+
186
+ /** Whether the two are the same down to a level: only then are their places at the next one in one list. */
187
+ const together = (level: number): boolean =>
188
+ a.path.length >= level &&
189
+ b.path.length >= level &&
190
+ a.path.slice(0, level).every((segment, index) => segment === b.path[index])
191
+
192
+ // Along the line: by section, and in one section by how far under its page each is.
193
+ const across = wayAt(0) || signOf(stepsUnder(b.path) - stepsUnder(a.path))
194
+ // Down the page: by the page, each section counted from its top, and under one page by what is under it.
195
+ const down = (): -1 | 0 | 1 => {
196
+ const way = wayAt(1)
197
+ if (way !== 0 || !together(2)) return way
198
+ for (let level = 2; level < Math.min(a.path.length, b.path.length); level++) {
199
+ const under = wayAt(level)
200
+ if (under !== 0 || !together(level + 1)) return under
201
+ }
202
+ return 0
203
+ }
204
+
205
+ const along: ReadonlyArray<Travel> = across > 0 ? ["forward"] : across < 0 ? ["back"] : []
206
+ const way = down()
207
+ return [...along, ...(way > 0 ? ["down" as const] : way < 0 ? ["up" as const] : [])]
208
+ }
209
+
210
+ /**
211
+ * A place on a canvas that is drawn by hand: one address, as a route, or
212
+ * every address of a route, as its tag.
213
+ */
214
+ export type Spot<R extends Routes> = R["Type"]["_tag"] | R["Type"]
215
+
216
+ /** A page of a section, and with `under`, what is under it: each of those a step forward from it, and listed downwards. */
217
+ export type Page<R extends Routes> = Spot<R> | { readonly at: Spot<R>; readonly under: ReadonlyArray<Page<R>> }
218
+
219
+ /** A canvas drawn by hand: it says the way from one route to another, as `travel` does. */
220
+ export interface Canvas<R extends Routes> {
221
+ readonly travel: (from: R["Type"], to: R["Type"]) => ReadonlyArray<Travel>
222
+ }
223
+
224
+ /**
225
+ * The canvas of an app whose addresses are not written the way it is drawn.
226
+ * `travel` reads the canvas off the addresses, which is why they have to be
227
+ * `/section/page`. With this the addresses are whatever people expect, `/`
228
+ * and `/posts/:id` and `/settings`, and the canvas is said once, here: the
229
+ * sections along the line of reading, in each its pages from the top down,
230
+ * and under a page whatever is a step forward from it.
231
+ *
232
+ * A place is a route, for one address, or the tag of a route, for all its
233
+ * addresses. Those are then in the order of their params: the literals of
234
+ * a `Schema.Literals` as given, any other values as a list of them would
235
+ * be read. An address is at the place that names it, and failing that at
236
+ * the place of its tag.
237
+ *
238
+ * Every route but the catch-all has to be somewhere on it, or this throws:
239
+ * a page can't be left off the map. A canvas is cheap to draw, so one that
240
+ * depends on the Model, such as the posts there are, is drawn in `update`.
241
+ *
242
+ * **Example** (A blog)
243
+ *
244
+ * ```ts
245
+ * const Canvas = Standard.canvas(BlogRoute, [
246
+ * [{ at: "Latest", under: ["Post"] }, "Archive", { at: "Topics", under: ["Topic"] }],
247
+ * ["Saved", "Write"],
248
+ * ["Display"]
249
+ * ])
250
+ *
251
+ * Navigated: ($, { route }) =>
252
+ * $.evolve({ route }).viewTransition(Canvas.travel($.model.route, route))
253
+ * ```
254
+ *
255
+ * @since 0.4.0
256
+ */
257
+ export const canvas = <R extends Routes>(routes: R, sections: ReadonlyArray<ReadonlyArray<Page<R>>>): Canvas<R> => {
258
+ type Route = { readonly _tag: string; readonly params?: Record<string, unknown> }
259
+ interface Place {
260
+ readonly tag: string
261
+ /** The params of the one address it is, or none when it is every address of the route. */
262
+ readonly params: Record<string, unknown> | undefined
263
+ /** The section, the page in it, and then where it is under each thing it is under. */
264
+ readonly at: ReadonlyArray<number>
265
+ }
266
+ const places: Array<Place> = []
267
+ const draw = (page: Page<R>, at: ReadonlyArray<number>): void => {
268
+ const spot = (typeof page === "object" && "at" in page ? page.at : page) as string | Route
269
+ places.push(
270
+ typeof spot === "string"
271
+ ? { tag: spot, params: undefined, at }
272
+ : { tag: spot._tag, params: spot.params ?? {}, at }
273
+ )
274
+ if (typeof page === "object" && "under" in page)
275
+ (page.under as ReadonlyArray<Page<R>>).forEach((under, index) => draw(under, [...at, index]))
276
+ }
277
+ sections.forEach((pages, section) => pages.forEach((page, index) => draw(page, [section, index])))
278
+
279
+ const missing = Object.keys(routes.routes).filter(
280
+ (tag) => tag !== routes.catchAll && !places.some((place) => place.tag === tag)
281
+ )
282
+ if (missing.length > 0) throw new Error(`Standard.canvas: no place for ${missing.join(", ")}`)
283
+
284
+ const same = (params: Record<string, unknown>, route: Route): boolean =>
285
+ Object.keys(params).every((name) => params[name] === route.params?.[name])
286
+ const placeOf = (route: Route): Place | undefined =>
287
+ places.find((place) => place.tag === route._tag && place.params !== undefined && same(place.params, route)) ??
288
+ places.find((place) => place.tag === route._tag && place.params === undefined)
289
+
290
+ /** Which way two addresses of one route lie: by the first of their params that differs. */
291
+ const byParams = (from: Route, to: Route): -1 | 0 | 1 => {
292
+ for (const segment of segmentsOf(routes.routes[from._tag]?.path ?? "/")) {
293
+ const name = segment === "*" ? "*" : segment.startsWith(":") ? segment.slice(1) : undefined
294
+ if (name === undefined) continue
295
+ const literals = (
296
+ routes.routes[from._tag]?.params[name] as { readonly literals?: ReadonlyArray<unknown> } | undefined
297
+ )?.literals
298
+ const way =
299
+ literals === undefined
300
+ ? inOrder(from.params?.[name], to.params?.[name])
301
+ : signOf(literals.indexOf(to.params?.[name]) - literals.indexOf(from.params?.[name]))
302
+ if (way !== 0) return way
303
+ }
304
+ return 0
305
+ }
306
+
307
+ return {
308
+ travel: (from, to) => {
309
+ const a = placeOf(from)
310
+ const b = placeOf(to)
311
+ if (a === undefined || b === undefined) return []
312
+ // Along the line: by section, and in one section by how far under its page each is.
313
+ const across = signOf(b.at[0]! - a.at[0]!) || signOf(b.at.length - a.at.length)
314
+ // Down the page: by the page, each section counted from its top, and under one page by what is under it.
315
+ const down = (): -1 | 0 | 1 => {
316
+ const way = signOf(b.at[1]! - a.at[1]!)
317
+ if (way !== 0 || (across !== 0 && b.at[0] !== a.at[0])) return way
318
+ for (let level = 2; level < Math.min(a.at.length, b.at.length); level++) {
319
+ const under = signOf(b.at[level]! - a.at[level]!)
320
+ if (under !== 0) return under
321
+ }
322
+ return a === b ? byParams(from, to) : 0
323
+ }
324
+ const way = down()
325
+ return [
326
+ ...(across > 0 ? ["forward" as const] : across < 0 ? ["back" as const] : []),
327
+ ...(way > 0 ? ["down" as const] : way < 0 ? ["up" as const] : [])
328
+ ]
329
+ }
330
+ }
331
+ }
332
+
333
+ /** The width of page something is shown at: every column side by side, or all of them collapsed into one. */
334
+ export const Only = Schema.Literals(["wide", "narrow"])
335
+ export type Only = typeof Only.Type
336
+
337
+ /** The landmark a region is. */
338
+ export const Landmark = Schema.Literals(["section", "header", "main", "footer", "nav", "article", "aside"])
339
+ export type Landmark = typeof Landmark.Type