@xerios/design-system 0.0.0-stage → 0.1.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 (214) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +403 -2
  3. package/dist/components/AnchorHeading.svelte +79 -0
  4. package/dist/components/AnchorHeading.svelte.d.ts +28 -0
  5. package/dist/components/Breadcrumbs.svelte +216 -0
  6. package/dist/components/Breadcrumbs.svelte.d.ts +37 -0
  7. package/dist/components/Button.svelte +178 -0
  8. package/dist/components/Button.svelte.d.ts +58 -0
  9. package/dist/components/Canvas.svelte +248 -0
  10. package/dist/components/Canvas.svelte.d.ts +91 -0
  11. package/dist/components/Collapsible.svelte +139 -0
  12. package/dist/components/Collapsible.svelte.d.ts +52 -0
  13. package/dist/components/CollapsibleAdvanced.svelte +174 -0
  14. package/dist/components/CollapsibleAdvanced.svelte.d.ts +43 -0
  15. package/dist/components/DashOutline.svelte +47 -0
  16. package/dist/components/DashOutline.svelte.d.ts +6 -0
  17. package/dist/components/Dialogs.svelte +123 -0
  18. package/dist/components/Dialogs.svelte.d.ts +6 -0
  19. package/dist/components/Drawer.svelte +231 -0
  20. package/dist/components/Drawer.svelte.d.ts +62 -0
  21. package/dist/components/ErrorMessage.svelte +140 -0
  22. package/dist/components/ErrorMessage.svelte.d.ts +41 -0
  23. package/dist/components/Icon.svelte +94 -0
  24. package/dist/components/Icon.svelte.d.ts +33 -0
  25. package/dist/components/InfoTip.svelte +183 -0
  26. package/dist/components/InfoTip.svelte.d.ts +28 -0
  27. package/dist/components/Md.svelte +28 -0
  28. package/dist/components/Md.svelte.d.ts +11 -0
  29. package/dist/components/Modal.svelte +91 -0
  30. package/dist/components/Modal.svelte.d.ts +41 -0
  31. package/dist/components/Notice.svelte +50 -0
  32. package/dist/components/Notice.svelte.d.ts +30 -0
  33. package/dist/components/Popover.svelte +212 -0
  34. package/dist/components/Popover.svelte.d.ts +70 -0
  35. package/dist/components/Shimmer.svelte +27 -0
  36. package/dist/components/Shimmer.svelte.d.ts +22 -0
  37. package/dist/components/Splitter.svelte +152 -0
  38. package/dist/components/Splitter.svelte.d.ts +41 -0
  39. package/dist/components/Table.svelte +448 -0
  40. package/dist/components/Table.svelte.d.ts +268 -0
  41. package/dist/components/Toast.svelte +273 -0
  42. package/dist/components/Toast.svelte.d.ts +31 -0
  43. package/dist/components/Tooltip.svelte +97 -0
  44. package/dist/components/Tooltip.svelte.d.ts +19 -0
  45. package/dist/components/WorkingBorder.svelte +105 -0
  46. package/dist/components/WorkingBorder.svelte.d.ts +26 -0
  47. package/dist/components/empty/Empty.svelte +55 -0
  48. package/dist/components/empty/Empty.svelte.d.ts +39 -0
  49. package/dist/components/empty/EmptyError.svelte +47 -0
  50. package/dist/components/empty/EmptyError.svelte.d.ts +28 -0
  51. package/dist/components/empty/index.d.ts +18 -0
  52. package/dist/components/empty/index.js +10 -0
  53. package/dist/components/filters/DateFilter.svelte +59 -0
  54. package/dist/components/filters/DateFilter.svelte.d.ts +23 -0
  55. package/dist/components/filters/FilterBar.svelte +342 -0
  56. package/dist/components/filters/FilterBar.svelte.d.ts +283 -0
  57. package/dist/components/filters/FilterChip.svelte +235 -0
  58. package/dist/components/filters/FilterChip.svelte.d.ts +68 -0
  59. package/dist/components/filters/OptionList.svelte +352 -0
  60. package/dist/components/filters/OptionList.svelte.d.ts +91 -0
  61. package/dist/components/filters/Panel.svelte +123 -0
  62. package/dist/components/filters/Panel.svelte.d.ts +25 -0
  63. package/dist/components/filters/index.d.ts +288 -0
  64. package/dist/components/filters/index.js +12 -0
  65. package/dist/components/icons.d.ts +54 -0
  66. package/dist/components/icons.js +58 -0
  67. package/dist/components/inputs/ButtonGroup.svelte +104 -0
  68. package/dist/components/inputs/ButtonGroup.svelte.d.ts +40 -0
  69. package/dist/components/inputs/Calendar.svelte +535 -0
  70. package/dist/components/inputs/Calendar.svelte.d.ts +45 -0
  71. package/dist/components/inputs/DateField.svelte +247 -0
  72. package/dist/components/inputs/DateField.svelte.d.ts +74 -0
  73. package/dist/components/inputs/DateInput.svelte +118 -0
  74. package/dist/components/inputs/DateInput.svelte.d.ts +43 -0
  75. package/dist/components/inputs/DatePicker.svelte +102 -0
  76. package/dist/components/inputs/DatePicker.svelte.d.ts +67 -0
  77. package/dist/components/inputs/DateRangePicker.svelte +208 -0
  78. package/dist/components/inputs/DateRangePicker.svelte.d.ts +76 -0
  79. package/dist/components/inputs/DateRangeSelect.svelte +548 -0
  80. package/dist/components/inputs/DateRangeSelect.svelte.d.ts +70 -0
  81. package/dist/components/inputs/FieldLabel.svelte +43 -0
  82. package/dist/components/inputs/FieldLabel.svelte.d.ts +28 -0
  83. package/dist/components/inputs/ListSearch.svelte +142 -0
  84. package/dist/components/inputs/ListSearch.svelte.d.ts +35 -0
  85. package/dist/components/inputs/RadioGroup.svelte +153 -0
  86. package/dist/components/inputs/RadioGroup.svelte.d.ts +49 -0
  87. package/dist/components/inputs/RangeShortcuts.svelte +90 -0
  88. package/dist/components/inputs/RangeShortcuts.svelte.d.ts +31 -0
  89. package/dist/components/inputs/RangeSlider.svelte +225 -0
  90. package/dist/components/inputs/RangeSlider.svelte.d.ts +37 -0
  91. package/dist/components/inputs/SearchField.svelte +24 -0
  92. package/dist/components/inputs/SearchField.svelte.d.ts +41 -0
  93. package/dist/components/inputs/Segmented.svelte +76 -0
  94. package/dist/components/inputs/Segmented.svelte.d.ts +43 -0
  95. package/dist/components/inputs/Select.svelte +552 -0
  96. package/dist/components/inputs/Select.svelte.d.ts +100 -0
  97. package/dist/components/inputs/Slider.svelte +177 -0
  98. package/dist/components/inputs/Slider.svelte.d.ts +33 -0
  99. package/dist/components/inputs/SliderTicks.svelte +62 -0
  100. package/dist/components/inputs/SliderTicks.svelte.d.ts +23 -0
  101. package/dist/components/inputs/Switch.svelte +120 -0
  102. package/dist/components/inputs/Switch.svelte.d.ts +31 -0
  103. package/dist/components/inputs/TagInput.svelte +296 -0
  104. package/dist/components/inputs/TagInput.svelte.d.ts +61 -0
  105. package/dist/components/inputs/TextArea.svelte +86 -0
  106. package/dist/components/inputs/TextArea.svelte.d.ts +56 -0
  107. package/dist/components/inputs/TextField.svelte +170 -0
  108. package/dist/components/inputs/TextField.svelte.d.ts +80 -0
  109. package/dist/components/menu/ContextMenu.svelte +25 -0
  110. package/dist/components/menu/ContextMenu.svelte.d.ts +26 -0
  111. package/dist/components/menu/MenuButton.svelte +46 -0
  112. package/dist/components/menu/MenuButton.svelte.d.ts +16 -0
  113. package/dist/components/menu/MenuList.svelte +319 -0
  114. package/dist/components/menu/MenuList.svelte.d.ts +30 -0
  115. package/dist/components/metadata/Metadata.svelte +38 -0
  116. package/dist/components/metadata/Metadata.svelte.d.ts +31 -0
  117. package/dist/components/metadata/MetadataRow.svelte +84 -0
  118. package/dist/components/metadata/MetadataRow.svelte.d.ts +26 -0
  119. package/dist/components/metadata/index.d.ts +8 -0
  120. package/dist/components/metadata/index.js +13 -0
  121. package/dist/components/side-menu/SideMenu.svelte +138 -0
  122. package/dist/components/side-menu/SideMenu.svelte.d.ts +25 -0
  123. package/dist/components/side-menu/SideMenuGroup.svelte +108 -0
  124. package/dist/components/side-menu/SideMenuGroup.svelte.d.ts +31 -0
  125. package/dist/components/side-menu/SideMenuItem.svelte +221 -0
  126. package/dist/components/side-menu/SideMenuItem.svelte.d.ts +46 -0
  127. package/dist/components/side-menu/context.d.ts +1 -0
  128. package/dist/components/side-menu/context.js +3 -0
  129. package/dist/components/side-menu/index.d.ts +62 -0
  130. package/dist/components/side-menu/index.js +15 -0
  131. package/dist/components/tiles/Tile.svelte +419 -0
  132. package/dist/components/tiles/Tile.svelte.d.ts +58 -0
  133. package/dist/components/tiles/TileGroup.svelte +135 -0
  134. package/dist/components/tiles/TileGroup.svelte.d.ts +45 -0
  135. package/dist/components/tiles/context.d.ts +35 -0
  136. package/dist/components/tiles/context.js +14 -0
  137. package/dist/components/tiles/index.d.ts +6 -0
  138. package/dist/components/tiles/index.js +13 -0
  139. package/dist/components/upload/FileCard.svelte +301 -0
  140. package/dist/components/upload/FileCard.svelte.d.ts +127 -0
  141. package/dist/components/upload/Thumb.svelte +274 -0
  142. package/dist/components/upload/Thumb.svelte.d.ts +101 -0
  143. package/dist/components/upload/UploadFile.svelte +123 -0
  144. package/dist/components/upload/UploadFile.svelte.d.ts +48 -0
  145. package/dist/components/upload/UploadFiles.svelte +177 -0
  146. package/dist/components/upload/UploadFiles.svelte.d.ts +50 -0
  147. package/dist/components/upload/UploadFolder.svelte +153 -0
  148. package/dist/components/upload/UploadFolder.svelte.d.ts +63 -0
  149. package/dist/components/upload/UploadImage.svelte +137 -0
  150. package/dist/components/upload/UploadImage.svelte.d.ts +52 -0
  151. package/dist/components/upload/UploadImages.svelte +172 -0
  152. package/dist/components/upload/UploadImages.svelte.d.ts +52 -0
  153. package/dist/components/upload/UploadZone.svelte +130 -0
  154. package/dist/components/upload/UploadZone.svelte.d.ts +41 -0
  155. package/dist/components/upload/common.d.ts +31 -0
  156. package/dist/components/upload/common.js +103 -0
  157. package/dist/components/upload/context.d.ts +18 -0
  158. package/dist/components/upload/context.js +10 -0
  159. package/dist/components/upload/index.d.ts +16 -0
  160. package/dist/components/upload/index.js +18 -0
  161. package/dist/css/atoms.css +892 -0
  162. package/dist/css/base.css +333 -0
  163. package/dist/css/effects.css +430 -0
  164. package/dist/css/index.css +10 -0
  165. package/dist/css/tokens.css +296 -0
  166. package/dist/fonts.d.ts +1 -0
  167. package/dist/fonts.js +7 -0
  168. package/dist/index.d.ts +68 -0
  169. package/dist/index.js +77 -0
  170. package/dist/lib/announce.d.ts +8 -0
  171. package/dist/lib/announce.js +48 -0
  172. package/dist/lib/controls.d.ts +10 -0
  173. package/dist/lib/controls.js +42 -0
  174. package/dist/lib/dates.d.ts +104 -0
  175. package/dist/lib/dates.js +235 -0
  176. package/dist/lib/dialogs.svelte.d.ts +8 -0
  177. package/dist/lib/dialogs.svelte.js +45 -0
  178. package/dist/lib/dom.d.ts +34 -0
  179. package/dist/lib/dom.js +90 -0
  180. package/dist/lib/field-errors.svelte.d.ts +40 -0
  181. package/dist/lib/field-errors.svelte.js +89 -0
  182. package/dist/lib/files.d.ts +74 -0
  183. package/dist/lib/files.js +215 -0
  184. package/dist/lib/inline-md.d.ts +1 -0
  185. package/dist/lib/inline-md.js +36 -0
  186. package/dist/lib/invalid.d.ts +4 -0
  187. package/dist/lib/invalid.js +35 -0
  188. package/dist/lib/list-search.d.ts +9 -0
  189. package/dist/lib/list-search.js +27 -0
  190. package/dist/lib/menu.svelte.d.ts +39 -0
  191. package/dist/lib/menu.svelte.js +98 -0
  192. package/dist/lib/morph.svelte.d.ts +17 -0
  193. package/dist/lib/morph.svelte.js +46 -0
  194. package/dist/lib/motion.d.ts +115 -0
  195. package/dist/lib/motion.js +174 -0
  196. package/dist/lib/observe.d.ts +36 -0
  197. package/dist/lib/observe.js +142 -0
  198. package/dist/lib/reveal.d.ts +7 -0
  199. package/dist/lib/reveal.js +28 -0
  200. package/dist/lib/roving.d.ts +16 -0
  201. package/dist/lib/roving.js +35 -0
  202. package/dist/lib/runs.d.ts +18 -0
  203. package/dist/lib/runs.js +25 -0
  204. package/dist/lib/scroll-fade.d.ts +4 -0
  205. package/dist/lib/scroll-fade.js +71 -0
  206. package/dist/lib/spotlight.d.ts +4 -0
  207. package/dist/lib/spotlight.js +109 -0
  208. package/dist/lib/ticks.d.ts +12 -0
  209. package/dist/lib/ticks.js +24 -0
  210. package/dist/lib/tooltip.d.ts +4 -0
  211. package/dist/lib/tooltip.js +110 -0
  212. package/dist/lib/validity.d.ts +16 -0
  213. package/dist/lib/validity.js +36 -0
  214. package/package.json +69 -3
@@ -0,0 +1,46 @@
1
+ export default SideMenuItem;
2
+ type SideMenuItem = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props & Omit<HTMLAnchorAttributes & HTMLButtonAttributes, keyof Props>>): void;
5
+ };
6
+ declare const SideMenuItem: import("svelte").Component<{
7
+ label: string;
8
+ href?: string | undefined;
9
+ icon?: string | undefined;
10
+ current?: boolean | "step" | "page" | "location" | "date" | "time" | undefined;
11
+ count?: string | number | null | undefined;
12
+ trailing?: import("svelte").Snippet<[]> | undefined;
13
+ /**
14
+ * bindable
15
+ */
16
+ open?: boolean | undefined;
17
+ ontoggle?: ((open: boolean) => void) | undefined;
18
+ children?: import("svelte").Snippet<[]> | undefined;
19
+ } & Omit<import("svelte/elements").HTMLAnchorAttributes & import("svelte/elements").HTMLButtonAttributes, keyof {
20
+ label: string;
21
+ href?: string | undefined;
22
+ icon?: string | undefined;
23
+ current?: boolean | "step" | "page" | "location" | "date" | "time" | undefined;
24
+ count?: string | number | null | undefined;
25
+ trailing?: import("svelte").Snippet<[]> | undefined;
26
+ /**
27
+ * bindable
28
+ */
29
+ open?: boolean | undefined;
30
+ ontoggle?: ((open: boolean) => void) | undefined;
31
+ children?: import("svelte").Snippet<[]> | undefined;
32
+ }>, {}, "open">;
33
+ type Props = {
34
+ label: string;
35
+ href?: string | undefined;
36
+ icon?: string | undefined;
37
+ current?: boolean | "step" | "page" | "location" | "date" | "time" | undefined;
38
+ count?: string | number | null | undefined;
39
+ trailing?: import("svelte").Snippet<[]> | undefined;
40
+ /**
41
+ * bindable
42
+ */
43
+ open?: boolean | undefined;
44
+ ontoggle?: ((open: boolean) => void) | undefined;
45
+ children?: import("svelte").Snippet<[]> | undefined;
46
+ };
@@ -0,0 +1 @@
1
+ export const DEPTH: unique symbol;
@@ -0,0 +1,3 @@
1
+ // How deep a SideMenu.Item sits: 0 for a group's own rows, one more for each item it is nested in. Each level starts at
2
+ // its parent's label column.
3
+ export const DEPTH = Symbol('side-menu-depth')
@@ -0,0 +1,62 @@
1
+ declare const _default: import("svelte").Component<{
2
+ label?: string | undefined;
3
+ header?: import("svelte").Snippet<[]> | undefined;
4
+ actions?: import("svelte").Snippet<[]> | undefined;
5
+ footer?: import("svelte").Snippet<[]> | undefined;
6
+ children: import("svelte").Snippet;
7
+ } & Omit<import("svelte/elements").HTMLAttributes<HTMLElement>, keyof {
8
+ label?: string | undefined;
9
+ header?: import("svelte").Snippet<[]> | undefined;
10
+ actions?: import("svelte").Snippet<[]> | undefined;
11
+ footer?: import("svelte").Snippet<[]> | undefined;
12
+ children: import("svelte").Snippet;
13
+ }>, {}, ""> & {
14
+ Group: import("svelte").Component<{
15
+ title?: string | undefined;
16
+ /**
17
+ * bindable
18
+ */
19
+ open?: boolean | undefined;
20
+ ontoggle?: ((open: boolean) => void) | undefined;
21
+ children: import("svelte").Snippet;
22
+ } & Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, keyof {
23
+ title?: string | undefined;
24
+ /**
25
+ * bindable
26
+ */
27
+ open?: boolean | undefined;
28
+ ontoggle?: ((open: boolean) => void) | undefined;
29
+ children: import("svelte").Snippet;
30
+ }>, {}, "open">;
31
+ Item: import("svelte").Component<{
32
+ label: string;
33
+ href?: string | undefined;
34
+ icon?: string | undefined;
35
+ current?: boolean | "step" | "page" | "location" | "date" | "time" | undefined;
36
+ count?: string | number | null | undefined;
37
+ trailing?: import("svelte").Snippet<[]> | undefined;
38
+ /**
39
+ * bindable
40
+ */
41
+ open?: boolean | undefined;
42
+ ontoggle?: ((open: boolean) => void) | undefined;
43
+ children?: import("svelte").Snippet<[]> | undefined;
44
+ } & Omit<import("svelte/elements").HTMLAnchorAttributes & import("svelte/elements").HTMLButtonAttributes, keyof {
45
+ label: string;
46
+ href?: string | undefined;
47
+ icon?: string | undefined;
48
+ current?: boolean | "step" | "page" | "location" | "date" | "time" | undefined;
49
+ count?: string | number | null | undefined;
50
+ trailing?: import("svelte").Snippet<[]> | undefined;
51
+ /**
52
+ * bindable
53
+ */
54
+ open?: boolean | undefined;
55
+ ontoggle?: ((open: boolean) => void) | undefined;
56
+ children?: import("svelte").Snippet<[]> | undefined;
57
+ }>, {}, "open">;
58
+ };
59
+ export default _default;
60
+ import SideMenuGroup from './SideMenuGroup.svelte';
61
+ import SideMenuItem from './SideMenuItem.svelte';
62
+ export { SideMenuGroup, SideMenuItem };
@@ -0,0 +1,15 @@
1
+ // The side menu as one import: <SideMenu> is the column, <SideMenu.Group> a run of rows (with a heading that folds it,
2
+ // or none), <SideMenu.Item> one row (a link, or a button), which can hold more items under it.
3
+ //
4
+ // import SideMenu from '@xerios/design-system/components/side-menu/index.js'
5
+ // <SideMenu label="Sections">
6
+ // <SideMenu.Group>
7
+ // <SideMenu.Item href="/inbox" icon="inbox" label="Inbox" count={3} />
8
+ // </SideMenu.Group>
9
+ // </SideMenu>
10
+ import SideMenu from './SideMenu.svelte'
11
+ import SideMenuGroup from './SideMenuGroup.svelte'
12
+ import SideMenuItem from './SideMenuItem.svelte'
13
+
14
+ export default Object.assign(SideMenu, { Group: SideMenuGroup, Item: SideMenuItem })
15
+ export { SideMenuGroup, SideMenuItem }
@@ -0,0 +1,419 @@
1
+ <script>
2
+ /**
3
+ * A tile: a bordered box with a title, an optional icon and any content under it, that is an action (a link or a
4
+ * button), a choice (a checkbox on its own, or an option of a TileGroup), or just content. The whole tile answers the
5
+ * pointer, not only its title: the title is the control itself (so it is the control's name, and its content the
6
+ * description), stretched over the tile. Content can be more than text (lists, chips, a figure, even its own buttons
7
+ * or fields, which stay usable on top of the tile). A checkbox is the exception: only its top row (icon, title, check
8
+ * mark and the padding round them) toggles it, so working with what is under it can't toggle it by accident; with no
9
+ * content, the whole tile does.
10
+ *
11
+ * <Tile title="Deploy guide" icon="rocket" href="/docs/deploy" cta="Read the guide">From a fresh repo to a live site.</Tile>
12
+ * <Tile title="Run checks" icon="flask" onclick={run}>Lint, types and tests.</Tile>
13
+ * <Tile title="Nightly backups" bind:checked={backups}>Kept for 30 days.</Tile>
14
+ * <TileGroup label="Plan" bind:value={plan}>
15
+ * <Tile value="free" title="Free">Up to 3 projects.</Tile>
16
+ * <Tile value="pro" title="Pro">Unlimited projects.</Tile>
17
+ * </TileGroup>
18
+ *
19
+ * What it is, the first that applies:
20
+ * inside a TileGroup and given a `value` → one of the group's options (a radio, or a checkbox when the group is `multiple`)
21
+ * `checked` given (a boolean, bindable) → a checkbox on its own
22
+ * `href` → a link; `onclick` → a button
23
+ * none of these → content only, not interactive
24
+ *
25
+ * title: the tile's name, one line at the top.
26
+ * icon: a registered icon name, before the title.
27
+ * value: its value as an option of the TileGroup around it.
28
+ * checked: bindable; makes it a checkbox on its own.
29
+ * href, target, rel: a link. An external address (http or https) opens in a new tab unless `target` says otherwise.
30
+ * onclick(event): a button; on a link or a choice it runs after the press is handled.
31
+ * cta: a short call to action at the foot (actions only), with the arrow.
32
+ * arrow: an arrow at the foot that nudges on hover (default: on links; ↗ for an external one). Actions only.
33
+ * horizontal: icon, text and arrow or check mark in one row, for a list of tiles rather than a grid.
34
+ * disabled: out of reach, faded.
35
+ * Children: the content under the title. Other attributes, the class and attachments go to the tile's box.
36
+ * Keyboard: Tab reaches it (an option of a one-choice group: the chosen one only, then arrows move and choose);
37
+ * Enter follows a link or presses a button; Space toggles a checkbox or presses a button.
38
+ *
39
+ * @typedef {object} Props
40
+ * @property {string} title
41
+ * @property {string} [icon]
42
+ * @property {string} [value]
43
+ * @property {boolean} [checked]
44
+ * @property {string} [href]
45
+ * @property {string} [target]
46
+ * @property {string} [rel]
47
+ * @property {(event: MouseEvent) => void} [onclick]
48
+ * @property {string} [cta]
49
+ * @property {boolean} [arrow]
50
+ * @property {boolean} [horizontal]
51
+ * @property {boolean} [disabled]
52
+ * @property {import('svelte').Snippet} [children]
53
+ */
54
+ import { getContext } from 'svelte'
55
+ import Icon from '../Icon.svelte'
56
+ import { TILE_GROUP } from './context.js'
57
+
58
+ /** @type {Props & Omit<import('svelte/elements').HTMLAttributes<HTMLDivElement>, keyof Props>} */
59
+ let {
60
+ title,
61
+ icon,
62
+ value,
63
+ checked = $bindable(),
64
+ href,
65
+ target,
66
+ rel,
67
+ onclick,
68
+ cta = '',
69
+ arrow,
70
+ horizontal = false,
71
+ disabled = false,
72
+ children,
73
+ class: className,
74
+ ...rest
75
+ } = $props()
76
+ const uid = $props.id()
77
+
78
+ /** @type {import('./context.js').TileGroupContext | undefined} */
79
+ const group = getContext(TILE_GROUP)
80
+
81
+ const option = $derived(group !== undefined && value !== undefined)
82
+ const kind = $derived(option ? (group?.multiple ? 'checkbox' : 'radio') : checked !== undefined ? 'checkbox' : href ? 'link' : onclick ? 'button' : 'static')
83
+ const choice = $derived(kind === 'radio' || kind === 'checkbox')
84
+ const on = $derived(choice && (option ? !!group?.isChosen(/** @type {string} */ (value)) : !!checked))
85
+ const off = $derived(disabled || (option && !!group?.disabled))
86
+ const external = $derived(!!href && /^https?:\/\//i.test(href))
87
+ const linkTarget = $derived(target ?? (external ? '_blank' : undefined))
88
+ const showArrow = $derived(!choice && (arrow ?? kind === 'link'))
89
+ const body = $derived(children ? `${uid}-body` : undefined)
90
+
91
+ // An option that can be reached joins the group's list, so the group knows which comes first.
92
+ $effect(() => {
93
+ if (option && !off) return group?.register(/** @type {string} */ (value))
94
+ })
95
+
96
+ /** @param {MouseEvent} e */
97
+ function press(e) {
98
+ if (option) group?.choose(/** @type {string} */ (value))
99
+ else if (kind === 'checkbox') checked = !checked
100
+ onclick?.(e)
101
+ }
102
+ </script>
103
+
104
+ <!-- The state classes go in the class array, not class: directives: next to the spread, Svelte's server output passes a
105
+ $derived's getter to a shorthand class:name (always truthy) instead of its value. -->
106
+ <div class={['tile', className, { horizontal, interactive: kind !== 'static', checkbox: kind === 'checkbox', on, off }]} {...rest}>
107
+ {#if kind === 'checkbox'}
108
+ <!-- Its top row is the control: icon, title and check mark in one button, laid on the tile's columns. -->
109
+ <button type="button" class="hit head" role="checkbox" aria-checked={on} disabled={off} aria-describedby={body} onclick={press}>
110
+ {#if icon}<span class="lead" aria-hidden="true"><Icon name={icon} /></span>{/if}
111
+ <span class="title">{title}</span>
112
+ <span class="mark" aria-hidden="true"><Icon name="checkBold" size="sm" /></span>
113
+ </button>
114
+ {:else if icon}
115
+ <span class="lead" aria-hidden="true"><Icon name={icon} /></span>
116
+ {/if}
117
+ {#if kind === 'link'}
118
+ <a
119
+ class="hit title"
120
+ href={off ? undefined : href}
121
+ role={off ? 'link' : undefined}
122
+ aria-disabled={off || undefined}
123
+ target={linkTarget}
124
+ rel={rel ?? (external ? 'noopener noreferrer' : undefined)}
125
+ aria-describedby={body}
126
+ {onclick}
127
+ >{title}{#if linkTarget === '_blank'}<span class="sr-only"> (opens in a new tab)</span>{/if}</a
128
+ >
129
+ {:else if kind === 'static'}
130
+ <span class="title">{title}</span>
131
+ {:else if kind !== 'checkbox'}
132
+ <button
133
+ type="button"
134
+ class="hit title"
135
+ role={kind === 'radio' ? 'radio' : undefined}
136
+ aria-checked={kind === 'radio' ? on : undefined}
137
+ tabindex={option ? group?.tabStop(/** @type {string} */ (value)) : undefined}
138
+ disabled={off}
139
+ aria-describedby={body}
140
+ onclick={press}>{title}</button
141
+ >
142
+ {/if}
143
+ {#if kind === 'radio'}<span class="mark radio" aria-hidden="true"></span>{/if}
144
+ {#if children}<div class="body" id={body}>{@render children()}</div>{/if}
145
+ {#if !choice && (cta || showArrow)}
146
+ <div class="foot">
147
+ {#if cta}<span>{cta}</span>{/if}
148
+ {#if showArrow}<span class="arrow" aria-hidden="true"><Icon name={external ? 'external' : 'arrowRight'} size="sm" /></span>{/if}
149
+ </div>
150
+ {/if}
151
+ </div>
152
+
153
+ <style>
154
+ /* A grid: icon, title and check mark across the top, the content under them, the foot at the bottom (pushed there when
155
+ the tile is stretched to its row). Spacing is margins, not gaps, so a part that is left out leaves no gap. */
156
+ .tile {
157
+ position: relative;
158
+ isolation: isolate;
159
+ display: grid;
160
+ grid-template-columns: auto minmax(0, 1fr) auto;
161
+ grid-template-rows: auto 1fr auto;
162
+ grid-template-areas:
163
+ 'lead title end'
164
+ 'body body body'
165
+ 'foot foot foot';
166
+ align-items: start;
167
+ min-width: 0;
168
+ --tile-pad-y: var(--space-4);
169
+ --tile-pad-x: var(--space-4);
170
+ padding: var(--tile-pad-y) var(--tile-pad-x);
171
+ border: 1px solid var(--line);
172
+ border-radius: var(--r-lg);
173
+ background: var(--surface);
174
+ color: var(--fg);
175
+ text-align: start;
176
+ transition:
177
+ border-color var(--dur) var(--ease-out),
178
+ translate var(--dur-fast) var(--ease-out);
179
+ }
180
+ /* The hover, pressed and chosen fills: translucent, laid over the surface under the content. */
181
+ .tile::before {
182
+ content: '';
183
+ position: absolute;
184
+ inset: 0;
185
+ z-index: -1;
186
+ border-radius: calc(var(--r-lg) - 1px);
187
+ pointer-events: none;
188
+ transition: background-color var(--dur) var(--ease-out);
189
+ }
190
+ /* Tiles you can press are raised like a button (its faint fill and relief); content-only tiles stay flat. */
191
+ .interactive {
192
+ background: var(--control-1);
193
+ box-shadow: var(--shadow-btn);
194
+ }
195
+ /* A checkbox lights up only while its top row, the part that toggles it, is under the pointer. */
196
+ .interactive:hover:not(.off, .on, .checkbox),
197
+ .checkbox:not(.off, .on):has(> .head:hover) {
198
+ border-color: var(--line-strong);
199
+ }
200
+ .interactive:hover:not(.off, .on, .checkbox)::before,
201
+ .checkbox:not(.off, .on):has(> .head:hover)::before {
202
+ background: var(--control-2);
203
+ }
204
+ .interactive:not(.off):has(> .hit:active) {
205
+ translate: 0 1px;
206
+ }
207
+ .interactive:not(.off):has(> .hit:active)::before {
208
+ background: var(--control-3);
209
+ }
210
+ .on {
211
+ border-color: var(--accent);
212
+ }
213
+ .on::before {
214
+ background: var(--accent-soft);
215
+ }
216
+ .off {
217
+ opacity: 0.5;
218
+ }
219
+
220
+ /* The control: plain text in the tile, with its ::after stretched over the whole tile (it has no position of its own,
221
+ so the tile is what the ::after is placed in). Its focus ring is drawn round the tile instead. */
222
+ .hit {
223
+ margin: 0;
224
+ padding: 0;
225
+ border: 0;
226
+ background: none;
227
+ font: inherit;
228
+ color: inherit;
229
+ text-align: inherit;
230
+ text-decoration: none;
231
+ cursor: pointer;
232
+ }
233
+ .hit::after {
234
+ content: '';
235
+ position: absolute;
236
+ inset: -1px;
237
+ border-radius: var(--r-lg);
238
+ }
239
+ .hit:focus-visible {
240
+ outline: none;
241
+ }
242
+ .tile:has(> .hit:focus-visible) {
243
+ outline: 2px solid var(--accent);
244
+ outline-offset: 2px;
245
+ }
246
+ .off .hit {
247
+ cursor: default;
248
+ }
249
+
250
+ /* A checkbox's top row: one button holding icon, title and check mark, laid on the tile's own columns (subgrid) so the
251
+ content under it lines up as in any tile. Its hit area reaches out through the padding at the top and sides and a
252
+ little below; the content under it is outside the control. With no content it fills the tile, as other tiles do. */
253
+ .head {
254
+ position: relative;
255
+ grid-area: 1 / 1 / 2 / -1;
256
+ display: grid;
257
+ grid-template-columns: subgrid;
258
+ align-items: start;
259
+ }
260
+ .head > .lead {
261
+ grid-area: 1 / 1;
262
+ }
263
+ .head > .title {
264
+ grid-area: 1 / 2;
265
+ }
266
+ .head > .mark {
267
+ grid-area: 1 / 3;
268
+ }
269
+ .head::after {
270
+ inset: calc(-1px - var(--tile-pad-y)) calc(-1px - var(--tile-pad-x)) calc(var(--space-1) * -1);
271
+ border-radius: var(--r-lg) var(--r-lg) 0 0;
272
+ }
273
+ .head:last-child {
274
+ grid-row: 1 / -1;
275
+ align-self: stretch;
276
+ }
277
+ .head:last-child::after {
278
+ bottom: calc(-1px - var(--tile-pad-y));
279
+ border-radius: var(--r-lg);
280
+ }
281
+
282
+ .lead {
283
+ grid-area: lead;
284
+ display: flex;
285
+ align-items: center;
286
+ height: 1lh;
287
+ margin-inline-end: var(--space-2);
288
+ color: var(--fg-2);
289
+ transition: color var(--dur) var(--ease-out);
290
+ }
291
+ .on .lead {
292
+ color: var(--accent);
293
+ }
294
+ .title {
295
+ grid-area: title;
296
+ min-width: 0;
297
+ color: var(--fg);
298
+ font-weight: var(--w-medium);
299
+ }
300
+
301
+ /* The check mark: a box (a ring for a radio) one line tall beside the title, filled with the brand colour when chosen. */
302
+ .mark {
303
+ grid-area: end;
304
+ display: grid;
305
+ place-items: center;
306
+ width: 16px;
307
+ height: 16px;
308
+ margin-block: calc((1lh - 16px) / 2);
309
+ margin-inline-start: var(--space-3);
310
+ border: 1px solid var(--faint);
311
+ border-radius: calc(var(--r-sm) - 2px);
312
+ background: var(--control-1);
313
+ color: var(--accent-ink);
314
+ transition:
315
+ background-color var(--dur) var(--ease-out),
316
+ border-color var(--dur) var(--ease-out);
317
+ }
318
+ .mark.radio {
319
+ border-radius: var(--r-pill);
320
+ }
321
+ .mark.radio::after {
322
+ content: '';
323
+ width: 6px;
324
+ height: 6px;
325
+ border-radius: var(--r-pill);
326
+ background: var(--accent-ink);
327
+ }
328
+ .mark :global(.icon),
329
+ .mark.radio::after {
330
+ opacity: 0;
331
+ scale: 0.5;
332
+ transition:
333
+ opacity var(--dur) var(--ease-out),
334
+ scale var(--dur) var(--ease-out);
335
+ }
336
+ .on .mark {
337
+ border-color: var(--brand);
338
+ background: var(--brand);
339
+ }
340
+ .on .mark :global(.icon),
341
+ .on .mark.radio::after {
342
+ opacity: 1;
343
+ scale: 1;
344
+ }
345
+
346
+ /* Content sits above the stretched control so its own controls can be used, but lets every other press fall through
347
+ to it. Only where the control is stretched over the whole tile: a plain tile's content, and a checkbox's (outside
348
+ its control), are ordinary text. */
349
+ .body {
350
+ grid-area: body;
351
+ min-width: 0;
352
+ margin-top: var(--space-2);
353
+ color: var(--muted);
354
+ font-size: 12px;
355
+ }
356
+ .interactive:not(.checkbox) .body {
357
+ position: relative;
358
+ z-index: 1;
359
+ pointer-events: none;
360
+ }
361
+ .interactive:not(.checkbox) .body :global(:is(a, button, input, select, textarea, label, summary, [tabindex], [contenteditable])) {
362
+ pointer-events: auto;
363
+ }
364
+
365
+ .foot {
366
+ grid-area: foot;
367
+ display: flex;
368
+ align-items: center;
369
+ justify-content: flex-end;
370
+ gap: var(--space-1);
371
+ margin-top: var(--space-3);
372
+ color: var(--muted);
373
+ font-size: 12px;
374
+ font-weight: var(--w-medium);
375
+ transition: color var(--dur) var(--ease-out);
376
+ }
377
+ .arrow {
378
+ display: inline-flex;
379
+ transition: translate var(--dur) var(--ease-out);
380
+ }
381
+ .interactive:hover:not(.off) .foot {
382
+ color: var(--accent);
383
+ }
384
+ .interactive:hover:not(.off) .arrow {
385
+ translate: 2px 0;
386
+ }
387
+
388
+ /* One row: the icon down the left, title over content in the middle, the check mark or the foot at the right. */
389
+ .horizontal {
390
+ grid-template-rows: auto 1fr;
391
+ grid-template-areas:
392
+ 'lead title end'
393
+ 'lead body end';
394
+ --tile-pad-y: var(--space-3);
395
+ }
396
+ .horizontal .body {
397
+ margin-top: var(--space-1);
398
+ }
399
+ .horizontal .foot {
400
+ grid-area: end;
401
+ align-self: center;
402
+ margin: 0 0 0 var(--space-3);
403
+ }
404
+
405
+ /* Forced colours drop the fills that mark a chosen tile and its check: draw them in system colours. */
406
+ @media (forced-colors: active) {
407
+ .on {
408
+ border-color: Highlight;
409
+ }
410
+ .on .mark {
411
+ border-color: Highlight;
412
+ background: Highlight;
413
+ color: HighlightText;
414
+ }
415
+ .mark.radio::after {
416
+ background: HighlightText;
417
+ }
418
+ }
419
+ </style>
@@ -0,0 +1,58 @@
1
+ export default Tile;
2
+ /**
3
+ * A tile: a bordered box with a title, an optional icon and any content under it, that is an action (a link or a
4
+ * button), a choice (a checkbox on its own, or an option of a TileGroup), or just content. The whole tile answers the
5
+ * pointer, not only its title: the title is the control itself (so it is the control's name, and its content the
6
+ * description), stretched over the tile. Content can be more than text (lists, chips, a figure, even its own buttons
7
+ * or fields, which stay usable on top of the tile). A checkbox is the exception: only its top row (icon, title, check
8
+ * mark and the padding round them) toggles it, so working with what is under it can't toggle it by accident; with no
9
+ * content, the whole tile does.
10
+ *
11
+ * <Tile title="Deploy guide" icon="rocket" href="/docs/deploy" cta="Read the guide">From a fresh repo to a live site.</Tile>
12
+ * <Tile title="Run checks" icon="flask" onclick={run}>Lint, types and tests.</Tile>
13
+ * <Tile title="Nightly backups" bind:checked={backups}>Kept for 30 days.</Tile>
14
+ * <TileGroup label="Plan" bind:value={plan}>
15
+ * <Tile value="free" title="Free">Up to 3 projects.</Tile>
16
+ * <Tile value="pro" title="Pro">Unlimited projects.</Tile>
17
+ * </TileGroup>
18
+ *
19
+ * What it is, the first that applies:
20
+ * inside a TileGroup and given a `value` → one of the group's options (a radio, or a checkbox when the group is `multiple`)
21
+ * `checked` given (a boolean, bindable) → a checkbox on its own
22
+ * `href` → a link; `onclick` → a button
23
+ * none of these → content only, not interactive
24
+ *
25
+ * title: the tile's name, one line at the top.
26
+ * icon: a registered icon name, before the title.
27
+ * value: its value as an option of the TileGroup around it.
28
+ * checked: bindable; makes it a checkbox on its own.
29
+ * href, target, rel: a link. An external address (http or https) opens in a new tab unless `target` says otherwise.
30
+ * onclick(event): a button; on a link or a choice it runs after the press is handled.
31
+ * cta: a short call to action at the foot (actions only), with the arrow.
32
+ * arrow: an arrow at the foot that nudges on hover (default: on links; ↗ for an external one). Actions only.
33
+ * horizontal: icon, text and arrow or check mark in one row, for a list of tiles rather than a grid.
34
+ * disabled: out of reach, faded.
35
+ * Children: the content under the title. Other attributes, the class and attachments go to the tile's box.
36
+ * Keyboard: Tab reaches it (an option of a one-choice group: the chosen one only, then arrows move and choose);
37
+ * Enter follows a link or presses a button; Space toggles a checkbox or presses a button.
38
+ */
39
+ export type Props = {
40
+ title: string;
41
+ icon?: string | undefined;
42
+ value?: string | undefined;
43
+ checked?: boolean | undefined;
44
+ href?: string | undefined;
45
+ target?: string | undefined;
46
+ rel?: string | undefined;
47
+ onclick?: ((event: MouseEvent) => void) | undefined;
48
+ cta?: string | undefined;
49
+ arrow?: boolean | undefined;
50
+ horizontal?: boolean | undefined;
51
+ disabled?: boolean | undefined;
52
+ children?: import("svelte").Snippet<[]> | undefined;
53
+ };
54
+ type Tile = {
55
+ $on?(type: string, callback: (e: any) => void): () => void;
56
+ $set?(props: Partial<Props & Omit<HTMLAttributes<HTMLDivElement>, keyof Props>>): void;
57
+ };
58
+ declare const Tile: import("svelte").Component<Props & Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, keyof Props>, {}, "checked">;