@mystravil/hardpoint 0.0.0-stage → 0.2.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 (126) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/LICENSE +25 -0
  3. package/README.md +64 -3
  4. package/dist/base.css +625 -0
  5. package/dist/components/AppShell.svelte +698 -0
  6. package/dist/components/AppShell.svelte.d.ts +77 -0
  7. package/dist/components/Button.svelte +174 -0
  8. package/dist/components/Button.svelte.d.ts +20 -0
  9. package/dist/components/Checkbox.svelte +235 -0
  10. package/dist/components/Checkbox.svelte.d.ts +23 -0
  11. package/dist/components/CheckboxGroup.svelte +207 -0
  12. package/dist/components/CheckboxGroup.svelte.d.ts +44 -0
  13. package/dist/components/Combobox.svelte +901 -0
  14. package/dist/components/Combobox.svelte.d.ts +72 -0
  15. package/dist/components/Dialog.svelte +359 -0
  16. package/dist/components/Dialog.svelte.d.ts +43 -0
  17. package/dist/components/Disclosure.svelte +201 -0
  18. package/dist/components/Disclosure.svelte.d.ts +27 -0
  19. package/dist/components/EmptyState.svelte +88 -0
  20. package/dist/components/EmptyState.svelte.d.ts +22 -0
  21. package/dist/components/ErrorState.svelte +135 -0
  22. package/dist/components/ErrorState.svelte.d.ts +26 -0
  23. package/dist/components/ImageViewer.svelte +764 -0
  24. package/dist/components/ImageViewer.svelte.d.ts +55 -0
  25. package/dist/components/KeyValueList.svelte +114 -0
  26. package/dist/components/KeyValueList.svelte.d.ts +43 -0
  27. package/dist/components/ListDetail.svelte +218 -0
  28. package/dist/components/ListDetail.svelte.d.ts +37 -0
  29. package/dist/components/LoadRegion.svelte +219 -0
  30. package/dist/components/LoadRegion.svelte.d.ts +27 -0
  31. package/dist/components/MediaFrame.svelte +110 -0
  32. package/dist/components/MediaFrame.svelte.d.ts +20 -0
  33. package/dist/components/MediaImage.svelte +256 -0
  34. package/dist/components/MediaImage.svelte.d.ts +16 -0
  35. package/dist/components/Menu.svelte +258 -0
  36. package/dist/components/Menu.svelte.d.ts +36 -0
  37. package/dist/components/MenuCheckboxItem.svelte +119 -0
  38. package/dist/components/MenuCheckboxItem.svelte.d.ts +15 -0
  39. package/dist/components/MenuGroup.svelte +50 -0
  40. package/dist/components/MenuGroup.svelte.d.ts +15 -0
  41. package/dist/components/MenuItem.svelte +94 -0
  42. package/dist/components/MenuItem.svelte.d.ts +19 -0
  43. package/dist/components/MenuRadioGroup.svelte +62 -0
  44. package/dist/components/MenuRadioGroup.svelte.d.ts +20 -0
  45. package/dist/components/MenuRadioItem.svelte +110 -0
  46. package/dist/components/MenuRadioItem.svelte.d.ts +17 -0
  47. package/dist/components/MenuSeparator.svelte +28 -0
  48. package/dist/components/MenuSeparator.svelte.d.ts +6 -0
  49. package/dist/components/Meter.svelte +283 -0
  50. package/dist/components/Meter.svelte.d.ts +66 -0
  51. package/dist/components/NativeSelect.svelte +135 -0
  52. package/dist/components/NativeSelect.svelte.d.ts +52 -0
  53. package/dist/components/Notice.svelte +262 -0
  54. package/dist/components/Notice.svelte.d.ts +30 -0
  55. package/dist/components/Pagination.svelte +132 -0
  56. package/dist/components/Pagination.svelte.d.ts +18 -0
  57. package/dist/components/Popover.svelte +222 -0
  58. package/dist/components/Popover.svelte.d.ts +35 -0
  59. package/dist/components/Progress.svelte +157 -0
  60. package/dist/components/Progress.svelte.d.ts +34 -0
  61. package/dist/components/RadioGroup.svelte +440 -0
  62. package/dist/components/RadioGroup.svelte.d.ts +50 -0
  63. package/dist/components/Select.svelte +471 -0
  64. package/dist/components/Select.svelte.d.ts +48 -0
  65. package/dist/components/Skeleton.svelte +149 -0
  66. package/dist/components/Skeleton.svelte.d.ts +24 -0
  67. package/dist/components/Spinner.svelte +118 -0
  68. package/dist/components/Spinner.svelte.d.ts +13 -0
  69. package/dist/components/Stat.svelte +253 -0
  70. package/dist/components/Stat.svelte.d.ts +46 -0
  71. package/dist/components/Steps.svelte +189 -0
  72. package/dist/components/Steps.svelte.d.ts +31 -0
  73. package/dist/components/Switch.svelte +222 -0
  74. package/dist/components/Switch.svelte.d.ts +18 -0
  75. package/dist/components/Table.svelte +504 -0
  76. package/dist/components/Table.svelte.d.ts +92 -0
  77. package/dist/components/Tabs.svelte +246 -0
  78. package/dist/components/Tabs.svelte.d.ts +44 -0
  79. package/dist/components/Tag.svelte +40 -0
  80. package/dist/components/Tag.svelte.d.ts +15 -0
  81. package/dist/components/TextArea.svelte +272 -0
  82. package/dist/components/TextArea.svelte.d.ts +28 -0
  83. package/dist/components/TextField.svelte +256 -0
  84. package/dist/components/TextField.svelte.d.ts +32 -0
  85. package/dist/components/Timeline.svelte +156 -0
  86. package/dist/components/Timeline.svelte.d.ts +30 -0
  87. package/dist/components/Toaster.svelte +411 -0
  88. package/dist/components/Toaster.svelte.d.ts +11 -0
  89. package/dist/components/Tooltip.svelte +200 -0
  90. package/dist/components/Tooltip.svelte.d.ts +38 -0
  91. package/dist/components/TooltipGroup.svelte +46 -0
  92. package/dist/components/TooltipGroup.svelte.d.ts +29 -0
  93. package/dist/components/internal/Scrim.svelte +52 -0
  94. package/dist/components/internal/Scrim.svelte.d.ts +15 -0
  95. package/dist/components/internal/Sheet.svelte +263 -0
  96. package/dist/components/internal/Sheet.svelte.d.ts +36 -0
  97. package/dist/components/internal/fade-in.d.ts +10 -0
  98. package/dist/components/internal/fade-in.js +20 -0
  99. package/dist/components/internal/groups.d.ts +14 -0
  100. package/dist/components/internal/groups.js +23 -0
  101. package/dist/components/internal/resolve.d.ts +8 -0
  102. package/dist/components/internal/resolve.js +247 -0
  103. package/dist/components/internal/swipe-dismiss.d.ts +47 -0
  104. package/dist/components/internal/swipe-dismiss.js +220 -0
  105. package/dist/components/internal/visual-viewport.svelte.d.ts +35 -0
  106. package/dist/components/internal/visual-viewport.svelte.js +79 -0
  107. package/dist/components/toast.svelte.d.ts +57 -0
  108. package/dist/components/toast.svelte.js +84 -0
  109. package/dist/fonts/OFL-geist-pixel.txt +92 -0
  110. package/dist/fonts/OFL.txt +93 -0
  111. package/dist/fonts/geist-latin-variable.woff2 +0 -0
  112. package/dist/fonts/geist-mono-latin-variable.woff2 +0 -0
  113. package/dist/fonts/geist-pixel-square.woff2 +0 -0
  114. package/dist/fonts.css +71 -0
  115. package/dist/index.d.ts +45 -0
  116. package/dist/index.js +45 -0
  117. package/dist/motion/Motion.svelte +15 -0
  118. package/dist/motion/Motion.svelte.d.ts +9 -0
  119. package/dist/motion/context.d.ts +18 -0
  120. package/dist/motion/context.js +26 -0
  121. package/dist/motion/index.d.ts +3 -0
  122. package/dist/motion/index.js +3 -0
  123. package/dist/motion/transitions.d.ts +31 -0
  124. package/dist/motion/transitions.js +112 -0
  125. package/dist/tokens.css +283 -0
  126. package/package.json +76 -6
@@ -0,0 +1,77 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ /**
4
+ * One place the app's navigation leads to. The same list serves every
5
+ * navigation form: the bottom bar or the drawer on compact widths, the
6
+ * rail and the sidebar from 600px.
7
+ */
8
+ export type AppShellDestination = {
9
+ /** Where the link goes. A plain `<a href>`, so any router handles it. */
10
+ href: string;
11
+ /**
12
+ * A short fixed label, set in caps. About six letters fit five across a
13
+ * 320px phone and the 80px rail; a longer label ends in an ellipsis.
14
+ */
15
+ label: string;
16
+ /**
17
+ * A glyph beside or above the label: an inline `<svg>` drawn in
18
+ * `currentColor` with `aria-hidden="true"`. It fills a 20px square, so
19
+ * give it a `viewBox` and no `width` or `height`.
20
+ */
21
+ icon?: Snippet;
22
+ };
23
+ /**
24
+ * The navigation below 600px: a bottom bar of the destinations, or a
25
+ * drawer that a menu button at the left of the header opens.
26
+ */
27
+ export type AppShellCompactNav = 'bar' | 'drawer';
28
+ /**
29
+ * The navigation from 900px: a sidebar of rows, or the rail that every
30
+ * width from 600 to 899px shows.
31
+ */
32
+ export type AppShellWideNav = 'sidebar' | 'rail';
33
+ export type AppShellProps = Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'children'> & {
34
+ /** The view title: a fixed string the app defines, set in caps in the header. */
35
+ title: string;
36
+ /**
37
+ * The left of the header: the app's wordmark, usually a link home. Give
38
+ * a link here at least `--hit-target` height.
39
+ */
40
+ brand?: Snippet;
41
+ /**
42
+ * Page controls: filters or the row of page actions. At the right of the
43
+ * header row from 1200px; below that, their own row under the header.
44
+ */
45
+ controls?: Snippet;
46
+ /**
47
+ * Three to five destinations: the bottom bar or the drawer below 600px,
48
+ * the rail from 600px, the sidebar or the rail from 900px.
49
+ */
50
+ destinations?: AppShellDestination[];
51
+ /**
52
+ * The `href` of the current destination; it gets `aria-current="page"`.
53
+ * The app decides which destination a nested page belongs to.
54
+ */
55
+ current?: string;
56
+ /** Below 600px: `bar` (default) or `drawer`. */
57
+ compactNav?: AppShellCompactNav;
58
+ /** From 900px: `sidebar` (default) or `rail`. */
59
+ wideNav?: AppShellWideNav;
60
+ /** Whether the drawer is open. It closes when the window reaches 600px. */
61
+ drawerOpen?: boolean;
62
+ /** The accessible name of the navigation. */
63
+ navLabel?: string;
64
+ /** The menu button's accessible name and the drawer's caps title. */
65
+ menuLabel?: string;
66
+ /** The accessible name of the drawer's close button. */
67
+ closeLabel?: string;
68
+ /** The id of `<main>`, the skip link's target. */
69
+ mainId?: string;
70
+ /** The skip link's text, shown on keyboard focus. */
71
+ skipLabel?: string;
72
+ /** The view's content, rendered inside `<main>`. */
73
+ children: Snippet;
74
+ };
75
+ declare const AppShell: import("svelte").Component<AppShellProps, {}, "drawerOpen">;
76
+ type AppShell = ReturnType<typeof AppShell>;
77
+ export default AppShell;
@@ -0,0 +1,174 @@
1
+ <script lang="ts" module>
2
+ import { Button as BitsButton } from 'bits-ui';
3
+
4
+ export type ButtonVariant = 'primary' | 'secondary' | 'tertiary';
5
+
6
+ export type ButtonProps = BitsButton.RootProps & {
7
+ /**
8
+ * `primary`: solid titanium block, for the view's one group of solid
9
+ * blocks. `secondary` (default): outlined. `tertiary`: caps label only.
10
+ */
11
+ variant?: ButtonVariant;
12
+ /** Ends the label in a small ▸: the button opens another view. */
13
+ opens?: boolean;
14
+ /**
15
+ * A square, icon-only button (height and width are `--control-height`).
16
+ * It has no visible label, so it needs an accessible name: pass
17
+ * `aria-label`.
18
+ */
19
+ icon?: boolean;
20
+ };
21
+ </script>
22
+
23
+ <script lang="ts">
24
+ let {
25
+ variant = 'secondary',
26
+ opens = false,
27
+ icon = false,
28
+ class: className,
29
+ ref = $bindable(null),
30
+ children,
31
+ ...rest
32
+ }: ButtonProps = $props();
33
+ </script>
34
+
35
+ <!--
36
+ An <a> when `href` is set, a <button> otherwise (Bits UI Button.Root). A
37
+ disabled link renders without href, with aria-disabled="true" and
38
+ tabindex -1; a disabled <button> is not focusable.
39
+ -->
40
+ <BitsButton.Root
41
+ bind:ref
42
+ class={['hp-button', 'hp-label', className]}
43
+ data-variant={variant}
44
+ data-opens={opens || undefined}
45
+ data-icon={icon || undefined}
46
+ {...rest}
47
+ >
48
+ {@render children?.()}
49
+ </BitsButton.Root>
50
+
51
+ <style>
52
+ /* Bits UI renders the element, so the root class reaches it from the
53
+ outside: the rules are :global, keyed on .hp-button and its data-*. */
54
+ :global(.hp-button) {
55
+ display: inline-flex;
56
+ align-items: center;
57
+ justify-content: space-between;
58
+ gap: var(--space-4);
59
+ box-sizing: border-box;
60
+ height: var(--control-height);
61
+ /* The visible box is the hit area: 36px fine, 44px coarse, and never
62
+ narrower than --hit-target for a short label. */
63
+ min-width: var(--hit-target);
64
+ padding: 0 var(--space-3);
65
+ border: 0;
66
+ background: transparent;
67
+ color: var(--text);
68
+ font-family: var(--sans);
69
+ text-decoration: none;
70
+ white-space: nowrap;
71
+ cursor: pointer;
72
+ -webkit-tap-highlight-color: transparent;
73
+ }
74
+
75
+ /* ---- Variants ---------------------------------------------------- */
76
+
77
+ /* Solid titanium block with a black label. */
78
+ :global(.hp-button[data-variant='primary']) {
79
+ background: var(--accent);
80
+ color: var(--canvas);
81
+ }
82
+ /* Outlined: a 3:1 boundary, titanium label, black fill. */
83
+ :global(.hp-button[data-variant='secondary']) {
84
+ border: 1px solid var(--border-control);
85
+ background: var(--canvas);
86
+ }
87
+ /* The label alone. */
88
+ :global(.hp-button[data-variant='tertiary']) {
89
+ background: transparent;
90
+ }
91
+
92
+ /* ---- Opens another view: a small ▸ drawn in CSS ------------------ */
93
+
94
+ :global(.hp-button[data-opens]::after) {
95
+ content: '';
96
+ flex: none;
97
+ width: 6px;
98
+ height: 8px;
99
+ background: currentColor;
100
+ clip-path: polygon(0 0, 100% 50%, 0 100%);
101
+ }
102
+
103
+ /* ---- Icon only: a square ----------------------------------------- */
104
+
105
+ :global(.hp-button[data-icon]) {
106
+ justify-content: center;
107
+ width: var(--control-height);
108
+ padding: 0;
109
+ }
110
+ /* The icon is the consumer's inline <svg>; it draws in currentColor. */
111
+ :global(.hp-button svg) {
112
+ flex: none;
113
+ }
114
+ :global(.hp-button[data-icon] svg) {
115
+ width: var(--space-4);
116
+ height: var(--space-4);
117
+ }
118
+
119
+ /* ---- Hover: fine pointers only ----------------------------------- */
120
+
121
+ @media (hover: hover) and (pointer: fine) {
122
+ :global(.hp-button) {
123
+ transition:
124
+ background-color var(--dur-hover) var(--settle),
125
+ color var(--dur-hover) var(--settle);
126
+ }
127
+ :global(.hp-button:active:not(:disabled):not([aria-disabled='true'])) {
128
+ transition-duration: var(--dur-press);
129
+ }
130
+ :global(.hp-button[data-variant='primary']:hover:not(:disabled):not([aria-disabled='true'])) {
131
+ background: var(--muted);
132
+ }
133
+ :global(.hp-button[data-variant='secondary']:hover:not(:disabled):not([aria-disabled='true'])),
134
+ :global(.hp-button[data-variant='tertiary']:hover:not(:disabled):not([aria-disabled='true'])) {
135
+ background: var(--surface-hover);
136
+ }
137
+ /* The tint alone barely shows (1.03:1), so the label also underlines. */
138
+ :global(.hp-button[data-variant='tertiary']:hover:not(:disabled):not([aria-disabled='true'])) {
139
+ text-decoration: underline;
140
+ text-decoration-thickness: 1px;
141
+ text-underline-offset: 0.3em;
142
+ }
143
+ }
144
+
145
+ /* ---- Press: after hover, so it wins while the pointer is down ----- */
146
+
147
+ :global(.hp-button[data-variant='primary']:active:not(:disabled):not([aria-disabled='true'])) {
148
+ background: var(--muted);
149
+ }
150
+ /* One step past the hover tint, so a press reads on a phone too. */
151
+ :global(.hp-button[data-variant='secondary']:active:not(:disabled):not([aria-disabled='true'])),
152
+ :global(.hp-button[data-variant='tertiary']:active:not(:disabled):not([aria-disabled='true'])) {
153
+ background: var(--surface-raised);
154
+ }
155
+
156
+ /* ---- Disabled: muted ink. A <button> is not focusable; a link has
157
+ no href. -------------------------------------------------------- */
158
+
159
+ :global(.hp-button:disabled),
160
+ :global(.hp-button[aria-disabled='true']) {
161
+ color: var(--muted);
162
+ cursor: not-allowed;
163
+ }
164
+ :global(.hp-button[data-variant='primary']:disabled),
165
+ :global(.hp-button[data-variant='primary'][aria-disabled='true']) {
166
+ /* --muted is 4.9:1 on the band. */
167
+ background: var(--surface-band);
168
+ }
169
+ :global(.hp-button[data-variant='secondary']:disabled),
170
+ :global(.hp-button[data-variant='secondary'][aria-disabled='true']) {
171
+ /* An off control needs no 3:1 boundary. */
172
+ border-color: var(--border);
173
+ }
174
+ </style>
@@ -0,0 +1,20 @@
1
+ import { Button as BitsButton } from 'bits-ui';
2
+ export type ButtonVariant = 'primary' | 'secondary' | 'tertiary';
3
+ export type ButtonProps = BitsButton.RootProps & {
4
+ /**
5
+ * `primary`: solid titanium block, for the view's one group of solid
6
+ * blocks. `secondary` (default): outlined. `tertiary`: caps label only.
7
+ */
8
+ variant?: ButtonVariant;
9
+ /** Ends the label in a small ▸: the button opens another view. */
10
+ opens?: boolean;
11
+ /**
12
+ * A square, icon-only button (height and width are `--control-height`).
13
+ * It has no visible label, so it needs an accessible name: pass
14
+ * `aria-label`.
15
+ */
16
+ icon?: boolean;
17
+ };
18
+ declare const Button: import("svelte").Component<ButtonProps, {}, "ref">;
19
+ type Button = ReturnType<typeof Button>;
20
+ export default Button;
@@ -0,0 +1,235 @@
1
+ <script lang="ts" module>
2
+ import { Checkbox as BitsCheckbox } from 'bits-ui';
3
+
4
+ /** Attributes and handlers not listed here go to the checkbox button. */
5
+ export type CheckboxProps = Omit<BitsCheckbox.RootProps, 'child' | 'children' | 'ref'> & {
6
+ /**
7
+ * The text beside the box, as written (never caps). Pressing it, or
8
+ * anywhere on the box's row, toggles the box. Without it, give the box
9
+ * an accessible name with `aria-label`.
10
+ */
11
+ label?: string;
12
+ /**
13
+ * A Tag after the label, such as "Recommended": a short fixed string the
14
+ * app defines, set in caps. It is part of the box's accessible name and
15
+ * shows only with a `label`.
16
+ */
17
+ tag?: string;
18
+ /** A second line in `--muted` under the label, read out as the box's description. */
19
+ hint?: string;
20
+ /** The checkbox button. */
21
+ ref?: HTMLElement | null;
22
+ };
23
+ </script>
24
+
25
+ <script lang="ts">
26
+ import Tag from './Tag.svelte';
27
+
28
+ const uid = $props.id();
29
+
30
+ let {
31
+ checked = $bindable(false),
32
+ indeterminate = $bindable(false),
33
+ label,
34
+ tag,
35
+ hint,
36
+ id = uid,
37
+ ref = $bindable(null),
38
+ class: className,
39
+ 'aria-describedby': describedBy,
40
+ ...rest
41
+ }: CheckboxProps = $props();
42
+
43
+ const hintId = $derived(`${id}-hint`);
44
+ const describedByIds = $derived([hint ? hintId : null, describedBy].filter(Boolean).join(' ') || undefined);
45
+ </script>
46
+
47
+ <!--
48
+ A Bits UI Checkbox: a <button role="checkbox"> with aria-checked true,
49
+ false or mixed, and its state in data-state (checked, unchecked,
50
+ indeterminate) and data-disabled. Pressing the box or anywhere on its row
51
+ (the label, the tag, the hint) toggles it; an indeterminate box becomes
52
+ checked. Inside a CheckboxGroup, give it a `value`. Attributes, handlers
53
+ and `class` go to the button.
54
+ -->
55
+ <div class="hp-checkbox">
56
+ <span class="control">
57
+ <BitsCheckbox.Root bind:checked bind:indeterminate bind:ref {id} aria-describedby={describedByIds} {...rest}>
58
+ {#snippet child({ props })}
59
+ <button {...props} class={['box', className]}>
60
+ <svg class="mark mixed" viewBox="0 0 12 12" aria-hidden="true"><path d="M2 6h8" /></svg>
61
+ <svg class="mark check" viewBox="0 0 12 12" aria-hidden="true"><path d="M1.5 6.5l3 3 6-6" /></svg>
62
+ </button>
63
+ {/snippet}
64
+ </BitsCheckbox.Root>
65
+ </span>
66
+ {#if label}
67
+ <label class="hp-dense" class:tagged={!!tag} for={id}
68
+ >{label}{#if tag}{' '}<Tag as="span">{tag}</Tag>{/if}</label
69
+ >
70
+ {/if}
71
+ {#if hint}
72
+ <p class="hint hp-caption" id={hintId}>{hint}</p>
73
+ {/if}
74
+ </div>
75
+
76
+ <style>
77
+ /* The box, then the label as written. The first line is one hit-target
78
+ band (24px fine, 44px coarse): the box sits centred in it and the
79
+ label's first line too, so a label that wraps keeps the box beside its
80
+ first line. The hint runs under the label, aligned with its text.
81
+ The root is as wide as its content (without a label, as the box), and
82
+ with a label all of it is the target: the label's ::after covers the
83
+ root, so a press on the hint, the tag or the space between them is a
84
+ press on the label. The box sits above that cover with its own hit
85
+ area. */
86
+ .hp-checkbox {
87
+ /* The label's line height, as .hp-dense sets it. */
88
+ --_line: 24px;
89
+ position: relative;
90
+ display: grid;
91
+ grid-template-columns: auto;
92
+ justify-content: start;
93
+ align-items: start;
94
+ width: fit-content;
95
+ max-width: 100%;
96
+ }
97
+ .hp-checkbox:has(> label) {
98
+ grid-template-columns: auto minmax(0, 1fr);
99
+ column-gap: var(--space-3);
100
+ }
101
+ @media (pointer: fine) {
102
+ .hp-checkbox {
103
+ --_line: 20px;
104
+ }
105
+ }
106
+
107
+ .control {
108
+ position: relative;
109
+ z-index: 1;
110
+ display: flex;
111
+ align-items: center;
112
+ height: var(--hit-target);
113
+ }
114
+
115
+ /* A black box with a 3:1 boundary. Checked or indeterminate, the edge and
116
+ the mark turn titanium; the box stays black, because selection is never
117
+ a fill. Focus is base.css's contour 4px outside, so it never looks like
118
+ the checked edge. */
119
+ .box {
120
+ position: relative;
121
+ display: grid;
122
+ place-items: center;
123
+ box-sizing: border-box;
124
+ width: 20px;
125
+ height: 20px;
126
+ margin: 0;
127
+ padding: 0;
128
+ border: 1px solid var(--border-control);
129
+ background: var(--canvas);
130
+ color: var(--accent);
131
+ cursor: pointer;
132
+ -webkit-tap-highlight-color: transparent;
133
+ }
134
+ /* The hit area: at least --hit-target square, centred on the box. */
135
+ .box::before {
136
+ content: '';
137
+ position: absolute;
138
+ top: 50%;
139
+ left: 50%;
140
+ width: max(100%, var(--hit-target));
141
+ height: max(100%, var(--hit-target));
142
+ translate: -50% -50%;
143
+ }
144
+ .box[data-state='checked'],
145
+ .box[data-state='indeterminate'] {
146
+ border-color: var(--accent);
147
+ }
148
+
149
+ /* Both marks are always there, each at opacity 0 until its state comes.
150
+ The mark a change brings fades in from 0 at its place over --dur-mark
151
+ (BRIEF, short motion); the mark it takes away goes at once. A CSS
152
+ transition never runs on an element's first style, so a box that
153
+ renders checked or mixed shows its mark at once. 0ms is a snap.
154
+ Opacity only: nothing moves, so reduced motion keeps it. */
155
+ .mark {
156
+ grid-area: 1 / 1;
157
+ width: 12px;
158
+ height: 12px;
159
+ fill: none;
160
+ stroke: currentColor;
161
+ stroke-width: 2px;
162
+ opacity: 0;
163
+ }
164
+ .box[data-state='indeterminate'] .mixed,
165
+ .box[data-state='checked'] .check {
166
+ opacity: 1;
167
+ transition: opacity var(--dur-mark) var(--settle);
168
+ }
169
+
170
+ label {
171
+ justify-self: start;
172
+ padding: calc((var(--hit-target) - var(--_line)) / 2) 0;
173
+ cursor: pointer;
174
+ -webkit-tap-highlight-color: transparent;
175
+ }
176
+ label::after {
177
+ content: '';
178
+ position: absolute;
179
+ inset: 0;
180
+ }
181
+ /* The tag sits after the label when both fit on one line; otherwise it
182
+ wraps under the label whole. */
183
+ .tagged {
184
+ display: flex;
185
+ flex-wrap: wrap;
186
+ align-items: center;
187
+ gap: var(--space-1) var(--space-2);
188
+ }
189
+
190
+ /* Under the label's text; without a label, under the box. */
191
+ .hint {
192
+ grid-column: -2;
193
+ color: var(--muted);
194
+ }
195
+
196
+ /* ---- Hover: fine pointers only, over any part of the row ----------- */
197
+
198
+ @media (hover: hover) and (pointer: fine) {
199
+ .box {
200
+ transition:
201
+ background-color var(--dur-hover) var(--settle),
202
+ border-color var(--dur-hover) var(--settle);
203
+ }
204
+ .hp-checkbox:has(> label:hover, .box:hover) .box:not(:disabled) {
205
+ background-color: var(--surface-hover);
206
+ }
207
+ .hp-checkbox:has(> label:hover, .box:hover) .box[data-state='unchecked']:not(:disabled) {
208
+ border-color: var(--muted);
209
+ }
210
+ .hp-checkbox:has(> label:active, .box:active) .box:not(:disabled) {
211
+ transition-duration: var(--dur-press);
212
+ }
213
+ }
214
+
215
+ /* ---- Press: one step past hover, so it reads on a phone too -------- */
216
+
217
+ .hp-checkbox:has(> label:active, .box:active) .box:not(:disabled) {
218
+ background-color: var(--surface-raised);
219
+ }
220
+
221
+ /* ---- Disabled: the quieter --border and muted ink, the tag too ----- */
222
+
223
+ .box:disabled {
224
+ border-color: var(--border);
225
+ color: var(--muted);
226
+ cursor: not-allowed;
227
+ }
228
+ .hp-checkbox:has(.box:disabled) label {
229
+ color: var(--muted);
230
+ cursor: not-allowed;
231
+ }
232
+ .hp-checkbox:has(.box:disabled) label > :global(.hp-tag) {
233
+ background: var(--muted);
234
+ }
235
+ </style>
@@ -0,0 +1,23 @@
1
+ import { Checkbox as BitsCheckbox } from 'bits-ui';
2
+ /** Attributes and handlers not listed here go to the checkbox button. */
3
+ export type CheckboxProps = Omit<BitsCheckbox.RootProps, 'child' | 'children' | 'ref'> & {
4
+ /**
5
+ * The text beside the box, as written (never caps). Pressing it, or
6
+ * anywhere on the box's row, toggles the box. Without it, give the box
7
+ * an accessible name with `aria-label`.
8
+ */
9
+ label?: string;
10
+ /**
11
+ * A Tag after the label, such as "Recommended": a short fixed string the
12
+ * app defines, set in caps. It is part of the box's accessible name and
13
+ * shows only with a `label`.
14
+ */
15
+ tag?: string;
16
+ /** A second line in `--muted` under the label, read out as the box's description. */
17
+ hint?: string;
18
+ /** The checkbox button. */
19
+ ref?: HTMLElement | null;
20
+ };
21
+ declare const Checkbox: import("svelte").Component<CheckboxProps, {}, "ref" | "checked" | "indeterminate">;
22
+ type Checkbox = ReturnType<typeof Checkbox>;
23
+ export default Checkbox;