@kodentuzo/spotstrap 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 (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -2
  3. package/dist/js/index.d.ts +17 -0
  4. package/dist/js/spotstrap.js +3 -0
  5. package/dist/js/spotstrap.js.map +7 -0
  6. package/dist/recipes/index.d.ts +86 -0
  7. package/dist/recipes/index.js +211 -0
  8. package/dist/recipes/sizes.d.ts +21 -0
  9. package/dist/spotstrap.css +1694 -0
  10. package/dist/themes/kodentuzo.css +128 -0
  11. package/dist/themes/librelifts.css +128 -0
  12. package/dist/themes/librevitalis.css +128 -0
  13. package/dist/themes/neutral.css +128 -0
  14. package/dist/themes/sokobanko.css +135 -0
  15. package/dist/themes/spotcraft.css +128 -0
  16. package/dist/themes/tagtape.css +128 -0
  17. package/dist/themes/vinskiano.css +128 -0
  18. package/dist/tokens.json +2473 -0
  19. package/package.json +81 -4
  20. package/src/components/button.css +168 -0
  21. package/src/components/disclosure.css +235 -0
  22. package/src/components/field.css +173 -0
  23. package/src/components/menu.css +129 -0
  24. package/src/components/overlay.css +160 -0
  25. package/src/components/toggle.css +219 -0
  26. package/src/dark-class.css +19 -0
  27. package/src/js/index.ts +246 -0
  28. package/src/native.css +17 -0
  29. package/src/recipes/index.ts +262 -0
  30. package/src/recipes/sizes.ts +20 -0
  31. package/src/tailwind.css +67 -0
  32. package/src/themes/kodentuzo.css +136 -0
  33. package/src/themes/librelifts.css +136 -0
  34. package/src/themes/librevitalis.css +136 -0
  35. package/src/themes/neutral.css +137 -0
  36. package/src/themes/sokobanko.css +144 -0
  37. package/src/themes/spotcraft.css +136 -0
  38. package/src/themes/tagtape.css +136 -0
  39. package/src/themes/vinskiano.css +136 -0
  40. package/src/tokens.css +42 -0
@@ -0,0 +1,129 @@
1
+ /*
2
+ * Menu, and the option lists of Listbox and Combobox: `menu` holds `menu-item`s, with
3
+ * `menu-label` and `menu-separator` between groups. Rows are 44px (36px with `menu-compact`
4
+ * on the menu), so a menu is as easy to hit on a phone as a button.
5
+ *
6
+ * Highlight follows every library's attribute for it: `[data-highlighted]` (Zag, Radix,
7
+ * reka-ui, bits-ui), `[data-focus]`/`[data-active]` (Headless UI), `[data-focused]` (react-aria).
8
+ * A selected option, `[data-state="checked"]`, `[aria-selected="true"]` or `[data-selected]`,
9
+ * shows a check at the end.
10
+ */
11
+
12
+ @utility menu {
13
+ min-width: 12rem;
14
+ max-width: min(20rem, 100vw - 2rem);
15
+ max-height: min(24rem, 60vh);
16
+ margin: 0;
17
+ padding: 0.25rem;
18
+ overflow: auto;
19
+ overscroll-behavior: contain;
20
+ border: 1px solid var(--color-border);
21
+ border-radius: var(--radius-lg);
22
+ background-color: var(--color-popover);
23
+ color: var(--color-popover-foreground);
24
+ box-shadow: var(--shadow-lg);
25
+ outline: none;
26
+
27
+ &:where([popover]) {
28
+ inset: auto;
29
+ margin: 0.25rem 0;
30
+ position-area: block-end span-inline-end;
31
+ position-try-fallbacks: flip-block, flip-inline;
32
+ }
33
+
34
+ &[hidden] {
35
+ display: none;
36
+ }
37
+ }
38
+
39
+ @utility menu-compact {
40
+ --menu-row: var(--size-control-compact);
41
+ }
42
+
43
+ @utility menu-item {
44
+ position: relative;
45
+ display: flex;
46
+ width: 100%;
47
+ align-items: center;
48
+ gap: 0.75rem;
49
+ min-height: var(--menu-row, var(--size-control));
50
+ padding-inline: 0.75rem;
51
+ border: 0;
52
+ border-radius: var(--radius-md);
53
+ background: none;
54
+ color: inherit;
55
+ font: inherit;
56
+ font-size: var(--text-body);
57
+ line-height: var(--text-body--line-height);
58
+ text-align: start;
59
+ cursor: pointer;
60
+ user-select: none;
61
+ outline: none;
62
+ -webkit-tap-highlight-color: transparent;
63
+
64
+ &:is([data-highlighted], [data-focus], [data-active], [data-focused], :focus-visible) {
65
+ background-color: var(--color-accent);
66
+ color: var(--color-accent-foreground);
67
+ }
68
+
69
+ @media (hover: hover) {
70
+ &:hover:not([data-disabled], [aria-disabled="true"], :disabled) {
71
+ background-color: var(--color-accent);
72
+ color: var(--color-accent-foreground);
73
+ }
74
+ }
75
+
76
+ &:is(
77
+ [data-state="checked"],
78
+ [aria-selected="true"],
79
+ [aria-checked="true"],
80
+ [data-selected]
81
+ )::after {
82
+ content: "";
83
+ width: 0.375rem;
84
+ height: 0.6875rem;
85
+ margin-inline-start: auto;
86
+ margin-top: -0.125rem;
87
+ border: solid currentColor;
88
+ border-width: 0 2px 2px 0;
89
+ rotate: 45deg;
90
+ }
91
+
92
+ &:is([data-disabled], [aria-disabled="true"], :disabled) {
93
+ opacity: 0.5;
94
+ cursor: not-allowed;
95
+ }
96
+
97
+ &[hidden] {
98
+ display: none;
99
+ }
100
+ }
101
+
102
+ @utility menu-item-destructive {
103
+ color: var(--color-destructive);
104
+ }
105
+
106
+ @utility menu-label {
107
+ padding: 0.5rem 0.75rem 0.25rem;
108
+ font-size: var(--text-footnote);
109
+ line-height: var(--text-footnote--line-height);
110
+ font-weight: 600;
111
+ color: var(--color-muted-foreground);
112
+ }
113
+
114
+ @utility menu-separator {
115
+ height: 1px;
116
+ margin: 0.25rem -0.25rem;
117
+ border: 0;
118
+ background-color: var(--color-border);
119
+ }
120
+
121
+ @utility menu-empty {
122
+ padding: 0.75rem;
123
+ font-size: var(--text-subhead);
124
+ color: var(--color-muted-foreground);
125
+
126
+ &[hidden] {
127
+ display: none;
128
+ }
129
+ }
@@ -0,0 +1,160 @@
1
+ /*
2
+ * Dialog and popover, on the browser's own <dialog> and [popover], or on a headless library's
3
+ * content element. Open them without script with invoker buttons:
4
+ *
5
+ * <button class="btn" commandfor="confirm" command="show-modal">Delete…</button>
6
+ * <dialog class="dialog" id="confirm">…</dialog>
7
+ *
8
+ * <button class="btn" commandfor="info" command="toggle-popover">Info</button>
9
+ * <div class="popover" id="info" popover>…</div>
10
+ *
11
+ * On narrow screens a dialog becomes a sheet at the bottom, within thumb reach, and its
12
+ * actions stack full width with the first one (usually Cancel) at the bottom.
13
+ */
14
+
15
+ @utility dialog {
16
+ position: fixed;
17
+ inset: 0;
18
+ width: min(32rem, 100% - 2rem);
19
+ max-height: calc(100% - 2rem);
20
+ margin: auto;
21
+ padding: 1.5rem;
22
+ overflow: auto;
23
+ border: 1px solid var(--color-border);
24
+ border-radius: var(--radius-xl);
25
+ background-color: var(--color-popover);
26
+ color: var(--color-popover-foreground);
27
+ box-shadow: var(--shadow-xl);
28
+ opacity: 1;
29
+ scale: 1;
30
+ transition-property: opacity, scale, translate, display, overlay;
31
+ transition-duration: 200ms;
32
+ transition-behavior: allow-discrete;
33
+
34
+ /* A closed <dialog> stays hidden; open ones and libraries' mounted content lay out. */
35
+ &:is([open], :popover-open, :not(dialog, [popover])) {
36
+ display: grid;
37
+ gap: 1rem;
38
+ }
39
+
40
+ @starting-style {
41
+ &:is([open], :popover-open) {
42
+ opacity: 0;
43
+ scale: 0.96;
44
+ }
45
+ }
46
+
47
+ &:is([data-state="closed"], [data-closed], [data-exiting]) {
48
+ opacity: 0;
49
+ scale: 0.96;
50
+ }
51
+
52
+ &::backdrop {
53
+ background-color: oklch(0 0 0 / 40%);
54
+ transition-property: opacity, display, overlay;
55
+ transition-duration: 200ms;
56
+ transition-behavior: allow-discrete;
57
+ }
58
+
59
+ @starting-style {
60
+ &[open]::backdrop {
61
+ opacity: 0;
62
+ }
63
+ }
64
+
65
+ @media (max-width: 40rem) {
66
+ width: 100%;
67
+ max-width: none;
68
+ max-height: calc(100% - 2.75rem);
69
+ margin-bottom: 0;
70
+ padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
71
+ border-bottom-width: 0;
72
+ border-end-start-radius: 0;
73
+ border-end-end-radius: 0;
74
+
75
+ @starting-style {
76
+ &:is([open], :popover-open) {
77
+ scale: 1;
78
+ translate: 0 2rem;
79
+ }
80
+ }
81
+ }
82
+
83
+ @media (prefers-reduced-motion: reduce) {
84
+ transition-property: opacity, display, overlay;
85
+
86
+ @starting-style {
87
+ &:is([open], :popover-open) {
88
+ scale: 1;
89
+ translate: none;
90
+ }
91
+ }
92
+ }
93
+ }
94
+
95
+ @utility dialog-title {
96
+ margin: 0;
97
+ font-size: var(--text-title-3);
98
+ line-height: var(--text-title-3--line-height);
99
+ font-weight: 600;
100
+ }
101
+
102
+ @utility dialog-description {
103
+ margin: 0;
104
+ font-size: var(--text-body);
105
+ line-height: var(--text-body--line-height);
106
+ color: var(--color-muted-foreground);
107
+ }
108
+
109
+ @utility dialog-actions {
110
+ display: flex;
111
+ flex-wrap: wrap;
112
+ justify-content: flex-end;
113
+ gap: var(--gap-control);
114
+
115
+ @media (max-width: 40rem) {
116
+ flex-direction: column-reverse;
117
+
118
+ & > * {
119
+ width: 100%;
120
+ }
121
+ }
122
+ }
123
+
124
+ @utility popover {
125
+ width: max-content;
126
+ max-width: min(20rem, 100vw - 2rem);
127
+ padding: 0.75rem;
128
+ border: 1px solid var(--color-border);
129
+ border-radius: var(--radius-lg);
130
+ background-color: var(--color-popover);
131
+ color: var(--color-popover-foreground);
132
+ box-shadow: var(--shadow-lg);
133
+ font-size: var(--text-subhead);
134
+ line-height: var(--text-subhead--line-height);
135
+ opacity: 1;
136
+ transition-property: opacity, display, overlay;
137
+ transition-duration: 150ms;
138
+ transition-behavior: allow-discrete;
139
+
140
+ /* A native popover sits next to the button that opened it, and flips to stay on screen. */
141
+ &:where([popover]) {
142
+ inset: auto;
143
+ /* A percentage is of the area next to the button, so the popover fits it and only
144
+ flips when it runs out of room below. */
145
+ max-width: min(20rem, 100%);
146
+ margin: 0.25rem 0;
147
+ position-area: block-end span-inline-end;
148
+ position-try-fallbacks: flip-block, flip-inline;
149
+ }
150
+
151
+ @starting-style {
152
+ &:popover-open {
153
+ opacity: 0;
154
+ }
155
+ }
156
+
157
+ &:is([data-state="closed"], [data-closed], [data-exiting]) {
158
+ opacity: 0;
159
+ }
160
+ }
@@ -0,0 +1,219 @@
1
+ /*
2
+ * Checkbox, radio and switch, on native inputs or on a headless library's element.
3
+ *
4
+ * <label class="choice"><input type="checkbox" class="checkbox" /> Email me</label>
5
+ * <div class="radio-group" role="radiogroup">…choices with class="radio"…</div>
6
+ * <label class="choice"><input type="checkbox" role="switch" class="switch" /> Wi-Fi</label>
7
+ *
8
+ * The boxes look small but each has a 44 × 44 hit area, and a `choice` row is 44px tall.
9
+ * Marks are drawn with CSS, not images, so strict CSPs don't block them. Unchecked outlines
10
+ * use the muted text color: WCAG asks 3:1 for a control's edge, which `--color-input` isn't.
11
+ */
12
+
13
+ @utility choice {
14
+ display: flex;
15
+ align-items: center;
16
+ gap: 0.75rem;
17
+ min-height: var(--size-control);
18
+ font-size: var(--text-body);
19
+ line-height: var(--text-body--line-height);
20
+ cursor: pointer;
21
+ -webkit-tap-highlight-color: transparent;
22
+
23
+ /* Rows that follow each other keep 12px between targets (docs/guidelines.md). */
24
+ & + & {
25
+ margin-top: var(--gap-control);
26
+ }
27
+
28
+ &:has(:disabled),
29
+ &[data-disabled] {
30
+ opacity: 0.5;
31
+ cursor: not-allowed;
32
+ }
33
+ }
34
+
35
+ /* The rows space themselves (choice + choice), so the group adds no gap of its own. */
36
+ @utility radio-group {
37
+ display: grid;
38
+ }
39
+
40
+ @utility checkbox {
41
+ position: relative;
42
+ display: inline-grid;
43
+ place-items: center;
44
+ flex-shrink: 0;
45
+ width: 1.25rem;
46
+ height: 1.25rem;
47
+ margin: 0;
48
+ border: 1.5px solid var(--color-muted-foreground);
49
+ border-radius: min(var(--radius-sm), 0.375rem);
50
+ background-color: var(--color-background);
51
+ color: var(--color-primary-foreground);
52
+ appearance: none;
53
+ cursor: pointer;
54
+
55
+ &::after {
56
+ content: "";
57
+ position: absolute;
58
+ inset: 50% auto auto 50%;
59
+ width: var(--size-control);
60
+ height: var(--size-control);
61
+ translate: -50% -50%;
62
+ }
63
+
64
+ &:is(
65
+ :checked,
66
+ :indeterminate,
67
+ [aria-checked="true"],
68
+ [aria-checked="mixed"],
69
+ [data-state="checked"],
70
+ [data-state="indeterminate"],
71
+ [data-checked],
72
+ [data-selected],
73
+ [data-indeterminate]
74
+ ) {
75
+ border-color: var(--color-primary);
76
+ background-color: var(--color-primary);
77
+ }
78
+
79
+ /* The check: two borders of a rotated box. */
80
+ &:is(
81
+ :checked,
82
+ [aria-checked="true"],
83
+ [data-state="checked"],
84
+ [data-checked],
85
+ [data-selected]
86
+ ):not(:indeterminate, [data-indeterminate])::before {
87
+ content: "";
88
+ width: 0.375rem;
89
+ height: 0.6875rem;
90
+ margin-top: -0.125rem;
91
+ border: solid currentColor;
92
+ border-width: 0 2px 2px 0;
93
+ rotate: 45deg;
94
+ }
95
+
96
+ &:is(
97
+ :indeterminate,
98
+ [aria-checked="mixed"],
99
+ [data-state="indeterminate"],
100
+ [data-indeterminate]
101
+ )::before {
102
+ content: "";
103
+ width: 0.625rem;
104
+ height: 2px;
105
+ background-color: currentColor;
106
+ }
107
+
108
+ &:focus-visible,
109
+ &[data-focus-visible] {
110
+ outline: 3px solid color-mix(in oklab, var(--color-ring) 60%, transparent);
111
+ outline-offset: 2px;
112
+ }
113
+
114
+ &:user-invalid,
115
+ &[aria-invalid="true"],
116
+ &[data-invalid] {
117
+ border-color: var(--color-destructive);
118
+ }
119
+
120
+ &:disabled,
121
+ &[data-disabled] {
122
+ cursor: not-allowed;
123
+ }
124
+ }
125
+
126
+ @utility radio {
127
+ @apply checkbox;
128
+ border-radius: 9999px;
129
+
130
+ /* Same selector as the checkbox's check, so this one wins: the dot replaces the check. */
131
+ &:is(
132
+ :checked,
133
+ [aria-checked="true"],
134
+ [data-state="checked"],
135
+ [data-checked],
136
+ [data-selected]
137
+ ):not(:indeterminate, [data-indeterminate])::before {
138
+ content: "";
139
+ width: 0.5rem;
140
+ height: 0.5rem;
141
+ margin: 0;
142
+ border: 0;
143
+ border-radius: 9999px;
144
+ background-color: currentColor;
145
+ rotate: none;
146
+ }
147
+ }
148
+
149
+ /* Apple's switch: 51 × 31 with a 27px thumb. */
150
+ @utility switch {
151
+ position: relative;
152
+ flex-shrink: 0;
153
+ width: 3.1875rem;
154
+ height: 1.9375rem;
155
+ margin: 0;
156
+ border: 0;
157
+ border-radius: 9999px;
158
+ background-color: color-mix(in oklab, var(--color-muted-foreground) 45%, var(--color-background));
159
+ appearance: none;
160
+ cursor: pointer;
161
+ transition: background-color 200ms;
162
+
163
+ &::before {
164
+ content: "";
165
+ position: absolute;
166
+ top: 0.125rem;
167
+ left: 0.125rem;
168
+ width: 1.6875rem;
169
+ height: 1.6875rem;
170
+ border-radius: 9999px;
171
+ background-color: oklch(1 0 0);
172
+ box-shadow:
173
+ 0 3px 8px oklch(0 0 0 / 15%),
174
+ 0 1px 1px oklch(0 0 0 / 16%);
175
+ transition: translate 200ms;
176
+ }
177
+
178
+ &::after {
179
+ content: "";
180
+ position: absolute;
181
+ inset: 50% auto auto 50%;
182
+ width: max(100%, var(--size-control));
183
+ height: var(--size-control);
184
+ translate: -50% -50%;
185
+ }
186
+
187
+ &:is(:checked, [aria-checked="true"], [data-state="checked"], [data-checked], [data-selected]) {
188
+ background-color: var(--color-primary);
189
+ }
190
+
191
+ &:is(
192
+ :checked,
193
+ [aria-checked="true"],
194
+ [data-state="checked"],
195
+ [data-checked],
196
+ [data-selected]
197
+ )::before {
198
+ translate: 1.25rem 0;
199
+ }
200
+
201
+ &:focus-visible,
202
+ &[data-focus-visible] {
203
+ outline: 3px solid color-mix(in oklab, var(--color-ring) 60%, transparent);
204
+ outline-offset: 2px;
205
+ }
206
+
207
+ &:disabled,
208
+ &[data-disabled] {
209
+ opacity: 0.5;
210
+ cursor: not-allowed;
211
+ }
212
+
213
+ @media (prefers-reduced-motion: reduce) {
214
+ &,
215
+ &::before {
216
+ transition: none;
217
+ }
218
+ }
219
+ }
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Follow a `.dark` class on <html> instead of the system setting. Import after
3
+ * "@kodentuzo/spotstrap/tailwind.css":
4
+ *
5
+ * @import "@kodentuzo/spotstrap/tailwind.css";
6
+ * @import "@kodentuzo/spotstrap/dark-class.css";
7
+ */
8
+ @custom-variant dark (&:where(.dark, .dark *));
9
+ @custom-variant light (&:not(:where(.dark, .dark *)));
10
+
11
+ @layer base {
12
+ :root {
13
+ color-scheme: light;
14
+ }
15
+
16
+ :root.dark {
17
+ color-scheme: dark;
18
+ }
19
+ }