@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,194 @@
1
+ /* sheet: the place next to the page, which the window moves over to. */
2
+
3
+ @layer standard.ui {
4
+ .sheet {
5
+ inset-block: 0;
6
+ inset-inline: auto 0;
7
+ inline-size: min(28rem, 100vi);
8
+ block-size: 100dvb;
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
+ --s-bg: color-mix(in oklch, var(--s-ink) 4%, var(--s-paper));
11
+ --s-fg: var(--s-ink);
12
+ --s-mark: var(--s-accent);
13
+ --s-on-mark: var(--s-on-accent);
14
+ --s-dark: var(--s-night);
15
+ --s-flat: 0;
16
+ translate: 100% 0;
17
+
18
+ @starting-style {
19
+ &[open] {
20
+ translate: 100% 0;
21
+ }
22
+ }
23
+
24
+ /*
25
+ * What ends the task, across its bottom: out to its edges, through its
26
+ * padding, and in view whatever the sheet is scrolled to. The sheet is a
27
+ * tint of its text, so they step on towards the text.
28
+ */
29
+ & > .sheet-actions {
30
+ --s-ui-step: var(--s-fg);
31
+
32
+ position: sticky;
33
+ inset-block-end: calc(-3 * var(--s-unit));
34
+ margin: 0 calc(-3 * var(--s-unit)) calc(-3 * var(--s-unit));
35
+ }
36
+
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
+ @media (width >= 48rem) {
39
+ &[open]:has(> .sheet-actions) {
40
+ display: flex;
41
+ flex-direction: column;
42
+
43
+ & > *,
44
+ & > :global(.s-ui-modal-body) > * {
45
+ flex: none;
46
+ }
47
+
48
+ & > .sheet-actions {
49
+ margin-block-start: auto;
50
+ }
51
+ }
52
+ }
53
+
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.
61
+ */
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));
65
+ inset-inline: 0;
66
+ inline-size: 100%;
67
+ block-size: auto;
68
+ padding: 0;
69
+ overflow: hidden;
70
+ translate: 0 -100%;
71
+ /* Cut off at the bar it comes out of: the cut moves up the sheet as fast as the sheet moves down. */
72
+ clip-path: inset(100% 0 0 0);
73
+ transition:
74
+ translate var(--s-travel) var(--s-glide),
75
+ clip-path var(--s-travel) var(--s-glide),
76
+ display var(--s-travel) allow-discrete,
77
+ overlay var(--s-travel) allow-discrete;
78
+
79
+ &[open] {
80
+ grid-template-rows: auto minmax(0, 1fr) auto auto;
81
+ align-content: stretch;
82
+ row-gap: 0;
83
+ clip-path: inset(0);
84
+ }
85
+
86
+ @starting-style {
87
+ &[open] {
88
+ translate: 0 -100%;
89
+ clip-path: inset(100% 0 0 0);
90
+ }
91
+ }
92
+
93
+ /* The title, what scrolls, its actions and the button are its rows. */
94
+ & > .sheet-actions {
95
+ position: static;
96
+ grid-row: 3;
97
+ margin: 0;
98
+ }
99
+
100
+ & > :global(.s-ui-modal-head) {
101
+ display: contents;
102
+ }
103
+
104
+ & > :global(.s-ui-modal-head) > :global(.s-ui-modal-title) {
105
+ padding: calc(3 * var(--s-unit));
106
+ }
107
+
108
+ & > :global(.s-ui-modal-body) {
109
+ display: grid;
110
+ grid-template-columns: minmax(0, 1fr);
111
+ align-content: start;
112
+ row-gap: calc(3 * var(--s-unit));
113
+ padding: 0 calc(3 * var(--s-unit)) calc(3 * var(--s-unit));
114
+ overflow-y: auto;
115
+ overscroll-behavior: contain;
116
+ }
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
+ }
137
+ }
138
+
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. */
140
+ :global(.s-page) > * {
141
+ transition: translate var(--s-travel) var(--s-glide);
142
+ }
143
+ :global(.s-page):has(.sheet[open]) > :not(dialog, :global(.s-ui-toasts)) {
144
+ translate: calc(-1 * min(28rem, 100vi)) 0;
145
+ }
146
+
147
+ /* A sheet can be on the other side: where a page starts, which is the right place for its table of contents. */
148
+ @media (width >= 48rem) {
149
+ .sheet.side-start {
150
+ inset-inline: 0 auto;
151
+ translate: -100% 0;
152
+
153
+ &[open] {
154
+ translate: 0 0;
155
+ }
156
+
157
+ @starting-style {
158
+ &[open] {
159
+ translate: -100% 0;
160
+ }
161
+ }
162
+ }
163
+
164
+ :global(.s-page):has(.sheet.side-start[open]) > :not(dialog, :global(.s-ui-toasts)) {
165
+ translate: min(28rem, 100vi) 0;
166
+ }
167
+ }
168
+
169
+ @media (width < 48rem) {
170
+ /* 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)) {
172
+ translate: 0 round(up, 100dvb - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px), 1px);
173
+ }
174
+
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;
178
+ }
179
+
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
+ );
187
+ }
188
+
189
+ /* Where the page has gone to is not somewhere to scroll to. */
190
+ :global(.s-page):has(.sheet[open]) {
191
+ overflow: clip;
192
+ }
193
+ }
194
+ }
@@ -0,0 +1,7 @@
1
+ declare const styles: {
2
+ readonly "sheet": string;
3
+ readonly "sheet-actions": string;
4
+ readonly "side-start": string;
5
+ };
6
+ export = styles;
7
+
@@ -0,0 +1,47 @@
1
+ /**
2
+ * `sheet`: the place next to the page.
3
+ *
4
+ * @since 0.4.0
5
+ */
6
+ import type { Html } from "effect/ui/html"
7
+ import { type Child, type Kind, node, type Node } from "../../Node.ts"
8
+ import { type Actions, actions } from "../control/control.ts"
9
+ import { modal } from "../modal/modal.ts"
10
+ import styles from "./sheet.module.css"
11
+
12
+ export const sheet = <Msg>(h: Html.H<Msg>) => ({
13
+ /**
14
+ * The place next to the page: a task, some detail, or the app's
15
+ * navigation. It isn't a layer over the page. The window moves over to
16
+ * it, so the page slides out by exactly as much as the sheet slides in,
17
+ * and back again when it closes; nothing is dimmed. It is at the end of
18
+ * the page, or with `side: "start"` at its start. On a narrow screen it
19
+ * is above the page: it comes down out of the navigator's top bar and
20
+ * fills the window down to its tabs, and its button is across the
21
+ * bottom, always in view. It keeps the focus inside, gives it back when it
22
+ * closes, and asks to close on Escape, on a press outside it, and by its
23
+ * button. The Model decides: it is open while `open` is true. With
24
+ * `actions`, what ends the task is across its bottom, edge to edge, as the
25
+ * answers of a `dialog` are, and in view whatever it is scrolled to.
26
+ */
27
+ sheet: <R = never>(
28
+ options: {
29
+ readonly open: boolean
30
+ readonly title: string
31
+ readonly close: { readonly label: string; readonly onPress: Msg }
32
+ readonly side?: "start" | "end"
33
+ readonly actions?: Actions<Msg>
34
+ },
35
+ ...children: ReadonlyArray<Child<Kind, Msg, R>>
36
+ ): Node<"block", Msg, R> =>
37
+ node(
38
+ modal(
39
+ h,
40
+ "sheet",
41
+ [styles.sheet, options.side === "start" && styles["side-start"]],
42
+ options,
43
+ children,
44
+ (options.actions ?? []).length > 0 && actions(h, styles["sheet-actions"], options.actions ?? [])
45
+ )
46
+ )
47
+ })
@@ -0,0 +1,44 @@
1
+ /* skeleton: where content will be, while it loads. */
2
+
3
+ @layer standard.ui {
4
+ .skeleton {
5
+ display: grid;
6
+ row-gap: var(--s-unit);
7
+
8
+ & > span {
9
+ position: relative;
10
+ block-size: calc(2 * var(--s-unit));
11
+ background: color-mix(in oklch, var(--s-fg) 14%, transparent);
12
+ overflow: clip;
13
+
14
+ &:last-child:not(:first-child) {
15
+ inline-size: 60%;
16
+ }
17
+
18
+ /* Waiting is shown by a block that runs along the line, not by a pulse. */
19
+ &::after {
20
+ content: "";
21
+ position: absolute;
22
+ inset-block: 0;
23
+ inline-size: 30%;
24
+ background: color-mix(in oklch, var(--s-fg) 14%, transparent);
25
+ animation: skeleton-run 0.8s var(--s-glide) infinite;
26
+ }
27
+ }
28
+ }
29
+ }
30
+
31
+ @keyframes skeleton-run {
32
+ from {
33
+ inset-inline-start: -30%;
34
+ }
35
+ to {
36
+ inset-inline-start: 100%;
37
+ }
38
+ }
39
+
40
+ @media (prefers-reduced-motion: reduce) {
41
+ .skeleton > span::after {
42
+ animation: none;
43
+ }
44
+ }
@@ -0,0 +1,6 @@
1
+ declare const styles: {
2
+ readonly "skeleton": string;
3
+ readonly "skeleton-run": string;
4
+ };
5
+ export = styles;
6
+
@@ -0,0 +1,20 @@
1
+ /**
2
+ * `skeleton`: where content will be, while it loads.
3
+ *
4
+ * @since 0.4.0
5
+ */
6
+ import type { Html } from "effect/ui/html"
7
+ import { node, type Node } from "../../Node.ts"
8
+ import styles from "./skeleton.module.css"
9
+
10
+ export const skeleton = <Msg>(h: Html.H<Msg>) => ({
11
+ /** Where content will be, while it loads. */
12
+ skeleton: (options: { readonly label: string; readonly lines?: 1 | 2 | 3 | 4 }): Node<"block", Msg> =>
13
+ node(
14
+ h.div
15
+ .class(styles.skeleton)
16
+ .attr("role", "status")
17
+ .attr("aria-label", options.label)
18
+ .children(Array.from({ length: options.lines ?? 3 }, () => h.span))
19
+ )
20
+ })
@@ -0,0 +1,56 @@
1
+ /* slider: a number picked along a track. */
2
+
3
+ @layer standard.ui {
4
+ .slider {
5
+ inline-size: 100%;
6
+ block-size: var(--s-target);
7
+ appearance: none;
8
+ background: transparent;
9
+ cursor: pointer;
10
+ touch-action: pan-y;
11
+
12
+ &::-webkit-slider-runnable-track {
13
+ block-size: calc(var(--s-unit) / 2);
14
+ background: currentColor;
15
+ }
16
+
17
+ &::-moz-range-track {
18
+ block-size: calc(var(--s-unit) / 2);
19
+ background: currentColor;
20
+ }
21
+
22
+ &::-webkit-slider-thumb {
23
+ appearance: none;
24
+ inline-size: calc(3 * var(--s-unit));
25
+ block-size: calc(3 * var(--s-unit));
26
+ margin-block-start: calc(-1.25 * var(--s-unit));
27
+ background: var(--s-mark);
28
+ transition: scale var(--s-quick) var(--s-ease);
29
+ }
30
+
31
+ &::-moz-range-thumb {
32
+ inline-size: calc(3 * var(--s-unit));
33
+ block-size: calc(3 * var(--s-unit));
34
+ border: 0;
35
+ border-radius: 0;
36
+ background: var(--s-mark);
37
+ }
38
+
39
+ &:active::-webkit-slider-thumb {
40
+ scale: 1.2;
41
+ }
42
+ &:disabled {
43
+ color: var(--s-muted);
44
+ cursor: not-allowed;
45
+ }
46
+ }
47
+
48
+ .slider-head {
49
+ display: flex;
50
+ justify-content: space-between;
51
+ align-items: baseline;
52
+ column-gap: var(--s-gutter);
53
+ inline-size: 100%;
54
+ font-variant-numeric: tabular-nums;
55
+ }
56
+ }
@@ -0,0 +1,6 @@
1
+ declare const styles: {
2
+ readonly "slider": string;
3
+ readonly "slider-head": string;
4
+ };
5
+ export = styles;
6
+
@@ -0,0 +1,48 @@
1
+ /**
2
+ * `slider`: a number picked along a track.
3
+ *
4
+ * @since 0.4.0
5
+ */
6
+ import type { Html } from "effect/ui/html"
7
+ import { node, type Node } from "../../Node.ts"
8
+ import control from "../control/control.module.css"
9
+ import styles from "./slider.module.css"
10
+
11
+ export const slider = <Msg>(h: Html.H<Msg>) => ({
12
+ /** A number picked along a track, by dragging, by the arrow keys, or by a press on the track. */
13
+ slider: (options: {
14
+ readonly name: string
15
+ readonly label: string
16
+ readonly value: number
17
+ readonly min: number
18
+ readonly max: number
19
+ readonly step?: number
20
+ readonly onInput: (value: number) => Msg
21
+ /** The value as it is shown beside the label. */
22
+ readonly shown?: string
23
+ readonly disabled?: boolean
24
+ }): Node<"block", Msg> => {
25
+ const id = h.id(`s-ui-${options.name}`)
26
+ return node(
27
+ h.div.class(control.field).children(
28
+ h.div
29
+ .class(styles["slider-head"])
30
+ .children(
31
+ h.label.class(control.legend).attr("for", id).children(options.label),
32
+ h.span.children(options.shown ?? String(options.value))
33
+ ),
34
+ h.input
35
+ .class(styles.slider)
36
+ .attr("id", id)
37
+ .attr("name", options.name)
38
+ .attr("type", "range")
39
+ .attr("min", String(options.min))
40
+ .attr("max", String(options.max))
41
+ .attr("step", String(options.step ?? 1))
42
+ .disabled(options.disabled === true)
43
+ .value(String(options.value))
44
+ .on("input", ({ value }) => options.onInput(Number(value)))
45
+ )
46
+ )
47
+ }
48
+ })
@@ -0,0 +1,32 @@
1
+ /* stepper: a small whole number, set one step at a time. */
2
+
3
+ @layer standard.ui {
4
+ .stepper {
5
+ display: inline-flex;
6
+ justify-self: start;
7
+ align-items: stretch;
8
+ }
9
+
10
+ /* Each button is a square block. One that can't go further is muted. */
11
+ .step {
12
+ display: grid;
13
+ place-items: center;
14
+ inline-size: var(--s-target);
15
+ background: color-mix(in oklch, var(--s-fg) calc(10% + var(--s-ui-press)), transparent);
16
+ color: var(--s-fg);
17
+
18
+ &:disabled {
19
+ color: var(--s-muted);
20
+ }
21
+ }
22
+
23
+ /* The number keeps its width as it changes, so the buttons stay under the finger. */
24
+ .stepper-value {
25
+ display: grid;
26
+ place-items: center;
27
+ min-inline-size: var(--s-target);
28
+ padding-inline: var(--s-unit);
29
+ font-weight: 700;
30
+ font-variant-numeric: tabular-nums;
31
+ }
32
+ }
@@ -0,0 +1,7 @@
1
+ declare const styles: {
2
+ readonly "step": string;
3
+ readonly "stepper": string;
4
+ readonly "stepper-value": string;
5
+ };
6
+ export = styles;
7
+
@@ -0,0 +1,62 @@
1
+ /**
2
+ * `stepper`: a small whole number, set one step at a time.
3
+ *
4
+ * @since 0.4.0
5
+ */
6
+ import type { Html } from "effect/ui/html"
7
+ import { node, type Node } from "../../Node.ts"
8
+ import { iconOf } from "../../standard/icon/icon.ts"
9
+ import control from "../control/control.module.css"
10
+ import styles from "./stepper.module.css"
11
+
12
+ export const stepper = <Msg>(h: Html.H<Msg>) => ({
13
+ /**
14
+ * A small number between two buttons: one takes a step off it, the other
15
+ * adds one. For how many of a thing. A number picked from a wide range
16
+ * is a `slider`'s.
17
+ */
18
+ stepper: (options: {
19
+ /** What is counted. It is not shown: the number stands beside the thing it counts. */
20
+ readonly label: string
21
+ readonly value: number
22
+ /** The least it can be. 0 by default. */
23
+ readonly min?: number
24
+ /** The most it can be. No limit by default. */
25
+ readonly max?: number
26
+ readonly step?: number
27
+ readonly onChange: (value: number) => Msg
28
+ /** The names of the two buttons, such as “One less” and “One more”. */
29
+ readonly less: string
30
+ readonly more: string
31
+ /** The value as it is shown between the buttons. */
32
+ readonly shown?: string
33
+ readonly disabled?: boolean
34
+ }): Node<"block", Msg> => {
35
+ const step = options.step ?? 1
36
+ const min = options.min ?? 0
37
+ const max = options.max ?? Infinity
38
+ const button = (to: number, icon: "remove" | "add", label: string) =>
39
+ h.button
40
+ .class(control.control, styles.step)
41
+ .attr("type", "button")
42
+ .attr("aria-label", label)
43
+ .disabled(options.disabled === true || to < min || to > max)
44
+ .on("click", options.onChange(to))
45
+ .children(iconOf(h, icon))
46
+ return node(
47
+ h.div
48
+ .class(styles.stepper)
49
+ .attr("role", "group")
50
+ .attr("aria-label", options.label)
51
+ .children(
52
+ button(options.value - step, "remove", options.less),
53
+ // Said when it changes: the press that changed it was on a button that says nothing new.
54
+ h.output
55
+ .class(styles["stepper-value"])
56
+ .attr("aria-live", "polite")
57
+ .children(options.shown ?? String(options.value)),
58
+ button(options.value + step, "add", options.more)
59
+ )
60
+ )
61
+ }
62
+ })
@@ -0,0 +1,38 @@
1
+ /* tabs: which view is shown, by native radio buttons. */
2
+
3
+ @layer standard.ui {
4
+ /* Which view is shown. The row scrolls under a finger when it doesn't fit. */
5
+ .tabs {
6
+ display: flex;
7
+ overflow-x: auto;
8
+ overscroll-behavior-inline: contain;
9
+ scroll-snap-type: inline proximity;
10
+ scrollbar-width: none;
11
+ }
12
+
13
+ .tab {
14
+ position: relative;
15
+ flex: none;
16
+ display: grid;
17
+ align-content: start;
18
+ padding: var(--s-unit) calc(2 * var(--s-unit));
19
+ background: color-mix(in oklch, var(--s-fg) var(--s-ui-press), transparent);
20
+ /* A view that can be shown is in the text's colour; only one that can't be is muted. */
21
+ color: var(--s-fg);
22
+ font-size: 1.5rem;
23
+ line-height: 2rem;
24
+ font-weight: 700;
25
+ letter-spacing: -0.015em;
26
+ white-space: nowrap;
27
+ scroll-snap-align: start;
28
+
29
+ &:has(:checked) {
30
+ background: var(--s-mark);
31
+ color: var(--s-on-mark);
32
+ }
33
+
34
+ &:has(:disabled) {
35
+ color: var(--s-muted);
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,6 @@
1
+ declare const styles: {
2
+ readonly "tab": string;
3
+ readonly "tabs": string;
4
+ };
5
+ export = styles;
6
+
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `tabs`: which of several views is shown.
3
+ *
4
+ * @since 0.4.0
5
+ */
6
+ import type { Html } from "effect/ui/html"
7
+ import { node, type Node } from "../../Node.ts"
8
+ import { type Item, radios } from "../control/control.ts"
9
+ import styles from "./tabs.module.css"
10
+
11
+ export const tabs = <Msg>(h: Html.H<Msg>) => ({
12
+ /**
13
+ * Which of several views is shown. The arrow keys move between them, and
14
+ * the row scrolls under a finger when it doesn't fit.
15
+ */
16
+ tabs: <A extends string>(options: {
17
+ readonly name: string
18
+ readonly label: string
19
+ readonly value: A
20
+ readonly onChange: (value: A) => Msg
21
+ readonly items: ReadonlyArray<Item<A>>
22
+ }): Node<"block", Msg> =>
23
+ node(radios(h, { group: styles.tabs, item: styles.tab }, options).attr("aria-label", options.label))
24
+ })
@@ -0,0 +1,23 @@
1
+ /* tag: a word that says what state or kind a thing is. */
2
+
3
+ @layer standard.ui {
4
+ /* With no colour it is still a block: a step from the ground towards the text. */
5
+ :where(.tag) {
6
+ --s-line: color-mix(in oklch, var(--s-fg) 16%, transparent);
7
+ --s-on-line: currentColor;
8
+ }
9
+
10
+ .tag {
11
+ display: inline-block;
12
+ padding: calc(var(--s-unit) / 4) calc(0.6em + var(--s-unit) / 4);
13
+ background: var(--s-line);
14
+ color: var(--s-on-line);
15
+ font-size: 0.75rem;
16
+ line-height: 1.25rem;
17
+ font-weight: 700;
18
+ letter-spacing: 0.08em;
19
+ text-transform: uppercase;
20
+ vertical-align: 0.1em;
21
+ white-space: nowrap;
22
+ }
23
+ }
@@ -0,0 +1,5 @@
1
+ declare const styles: {
2
+ readonly "tag": string;
3
+ };
4
+ export = styles;
5
+
@@ -0,0 +1,17 @@
1
+ /**
2
+ * `tag`: a word that says what state or kind a thing is.
3
+ *
4
+ * @since 0.4.0
5
+ */
6
+ import type { Html } from "effect/ui/html"
7
+ import { node, type Node } from "../../Node.ts"
8
+ import type { Colour } from "../../standard/tokens/tokens.ts"
9
+ import { line } from "../control/control.ts"
10
+ import { type Icon, leading } from "../../standard/icon/icon.ts"
11
+ import styles from "./tag.module.css"
12
+
13
+ export const tag = <Msg>(h: Html.H<Msg>) => ({
14
+ /** A word that says what state or kind a thing is. */
15
+ tag: (options: { readonly colour?: Colour; readonly icon?: Icon }, label: string): Node<"inline", Msg> =>
16
+ node(h.span.class(styles.tag, line(options.colour)).children(leading(h, options.icon), label))
17
+ })