@tokamaq/ui 0.0.0-stage → 0.1.0-dev.1

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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -2
  3. package/lint/index.js +22 -0
  4. package/lint/oxlint.json +58 -0
  5. package/lint/plugin.js +411 -0
  6. package/package.json +82 -4
  7. package/src/avatar.tsx +34 -0
  8. package/src/button.tsx +109 -0
  9. package/src/chip.tsx +52 -0
  10. package/src/cn.ts +71 -0
  11. package/src/code-block.tsx +58 -0
  12. package/src/collapsible.tsx +76 -0
  13. package/src/command.tsx +101 -0
  14. package/src/dialog.tsx +93 -0
  15. package/src/file-name.tsx +41 -0
  16. package/src/fonts/Geist-Variable.woff2 +0 -0
  17. package/src/fonts/GeistMono-Variable.woff2 +0 -0
  18. package/src/fonts/OFL.txt +92 -0
  19. package/src/fonts.css +15 -0
  20. package/src/icon.tsx +30 -0
  21. package/src/icons.ts +23 -0
  22. package/src/index.ts +24 -0
  23. package/src/input.tsx +86 -0
  24. package/src/kbd.tsx +33 -0
  25. package/src/kit/command.tsx +45 -0
  26. package/src/kit/contrast.ts +31 -0
  27. package/src/kit/controls.tsx +233 -0
  28. package/src/kit/disclosure.tsx +39 -0
  29. package/src/kit/frame.tsx +34 -0
  30. package/src/kit/inputs.tsx +53 -0
  31. package/src/kit/kit.tsx +76 -0
  32. package/src/kit/overlays.tsx +79 -0
  33. package/src/kit/rows.tsx +160 -0
  34. package/src/kit/tokens.tsx +189 -0
  35. package/src/menu.tsx +99 -0
  36. package/src/resizable.tsx +40 -0
  37. package/src/row-list.tsx +65 -0
  38. package/src/row.tsx +147 -0
  39. package/src/scroll-area.tsx +64 -0
  40. package/src/select.tsx +67 -0
  41. package/src/status-icon.tsx +49 -0
  42. package/src/switch.tsx +73 -0
  43. package/src/tabs.tsx +44 -0
  44. package/src/textarea.tsx +30 -0
  45. package/src/theme.css +397 -0
  46. package/src/tooltip.tsx +40 -0
  47. package/tests/setup.ts +29 -0
@@ -0,0 +1,30 @@
1
+ /*
2
+ <Textarea aria-label="Note" placeholder="Add a note" />
3
+
4
+ Grows with its text from one line up to the window's height, then scrolls.
5
+ A translucent well with an edge, so it sits on any surface.
6
+ */
7
+ import { Textarea as Base } from "@ui-sdk/solid/textarea";
8
+ import { omit } from "solid-js";
9
+ import type { ComponentProps, JSX } from "@solidjs/web";
10
+ import { cn } from "./cn.ts";
11
+
12
+ export type TextareaProps = ComponentProps<typeof Base>;
13
+
14
+ export function Textarea(props: TextareaProps): JSX.Element {
15
+ const rest = omit(props, "class");
16
+ return (
17
+ <Base
18
+ autoResize
19
+ rows={1}
20
+ {...rest}
21
+ data-slot="textarea"
22
+ class={cn(
23
+ "block min-h-8 max-h-dvh w-full resize-none rounded-sm bg-edge/50 px-3 py-line",
24
+ "text-row text-ink inset-ring inset-ring-edge placeholder:text-ink-3 focus-ring",
25
+ "disabled:text-ink-3 data-disabled:text-ink-3 field-sizing-content",
26
+ props.class as string,
27
+ )}
28
+ />
29
+ );
30
+ }
package/src/theme.css ADDED
@@ -0,0 +1,397 @@
1
+ /*
2
+ Tokamaq tokens and helpers. Import after Tailwind:
3
+
4
+ @layer ui-sdk;
5
+ @import "tailwindcss";
6
+ @import "@tokamaq/ui/theme.css";
7
+
8
+ Dark is the default; data-theme="light" on any element swaps every colour
9
+ inside it. Default scales are cleared, so off-scale classes do not exist.
10
+ */
11
+ @import "./fonts.css";
12
+ @source "./";
13
+
14
+ @theme {
15
+ --color-*: initial;
16
+ --color-window: oklch(13.44% 0 0);
17
+ --color-stage: oklch(17.3% 0 0);
18
+ --color-tray: oklch(20.02% 0 0);
19
+ --color-card: oklch(22.64% 0 0);
20
+ --color-band: oklch(25.2% 0 0);
21
+ /* A chip on the stage (the branch and folder in a thread's header). */
22
+ --color-chip: oklch(23.5% 0 0);
23
+ /* Raised above a card: an initial's disc, the pressed half of a segmented control. */
24
+ --color-lifted: oklch(28.5% 0 0);
25
+ --color-ink: oklch(92.49% 0 0);
26
+ --color-ink-2: oklch(74.76% 0 0);
27
+ --color-ink-3: oklch(63.34% 0 0);
28
+ --color-added: oklch(80.03% 0.182 151.7);
29
+ --color-removed: oklch(71.06% 0.166 22.2);
30
+ --color-warn: oklch(83.686% 0.1644 84.43);
31
+ --color-info: oklch(71.37% 0.143 254.6);
32
+ --color-added-tint: oklch(24.35% 0.034 158.5);
33
+ --color-removed-tint: oklch(22.7% 0.036 20.3);
34
+ --color-warn-tint: oklch(25.35% 0.032 82.4);
35
+ --color-info-tint: oklch(23.98% 0.048 259.9);
36
+ /* A diff's added and removed lines: a quiet wash under the code, so long changes stay readable. */
37
+ --color-diff-added: oklch(20.5% 0.022 155);
38
+ --color-diff-removed: oklch(20.5% 0.024 20);
39
+ /* brand fills the brand button; brand-text is the lighter shade for brand text,
40
+ links and the focus ring, since brand itself is under 4.5 on the dark tones. */
41
+ --color-brand: oklch(58.7% 0.243 300.9);
42
+ --color-brand-text: oklch(66.04% 0.201 302.3);
43
+ --color-brand-ink: oklch(100% 0 0);
44
+ --color-brand-tint: oklch(26.42% 0.052 305.3);
45
+ --color-edge: oklch(92.49% 0 0 / 0.12);
46
+ --color-edge-strong: oklch(92.49% 0 0 / 0.4);
47
+ --color-lip: oklch(14.08% 0.004 285.8 / 0.5);
48
+ --color-highlight: oklch(100% 0 0 / 0.08);
49
+
50
+ --spacing: initial;
51
+ --spacing-*: initial;
52
+ --spacing-0: 0px;
53
+ --spacing-1: 4px;
54
+ --spacing-2: 8px;
55
+ --spacing-3: 12px;
56
+ --spacing-4: 16px;
57
+ /* One line of a message header or a diff (Paper's 20 px rows). */
58
+ --spacing-5: 20px;
59
+ --spacing-6: 24px;
60
+ --spacing-8: 32px;
61
+ /* A diff's line-number lane and a file header in the review panel (Paper "Diff"). */
62
+ --spacing-10: 40px;
63
+ --spacing-12: 48px;
64
+ --spacing-16: 64px;
65
+
66
+ --radius-*: initial;
67
+ --radius-xs: 4px;
68
+ --radius-sm: 8px;
69
+ --radius-md: 12px;
70
+ --radius-lg: 16px;
71
+
72
+ --font-*: initial;
73
+ --font-sans: "Geist", ui-sans-serif, system-ui, sans-serif;
74
+ --font-mono: "Geist Mono", ui-monospace, monospace;
75
+
76
+ --font-weight-*: initial;
77
+ --font-weight-normal: 400;
78
+ --font-weight-medium: 500;
79
+ --font-weight-semibold: 600;
80
+
81
+ --text-*: initial;
82
+ --text-read: 16px;
83
+ --text-read--line-height: 26px;
84
+ --text-row: 14px;
85
+ --text-row--line-height: 20px;
86
+ --text-label: 12px;
87
+ --text-label--line-height: 16px;
88
+ --text-label--font-weight: 500;
89
+ --text-data: 12px;
90
+ --text-data--line-height: 16px;
91
+ /* Code in a diff: mono, one 20 px line per source line. */
92
+ --text-code: 13px;
93
+ --text-code--line-height: 20px;
94
+ /* The letter in an 18 px initial disc. */
95
+ --text-initial: 10px;
96
+ --text-initial--line-height: 12px;
97
+ --text-initial--font-weight: 600;
98
+
99
+ --leading-*: initial;
100
+ --tracking-*: initial;
101
+ --shadow-*: initial;
102
+ --shadow-raised:
103
+ 0 4px 6px -1px oklch(14.08% 0.004 285.8 / 0.2), 0 2px 4px -2px oklch(14.08% 0.004 285.8 / 0.2);
104
+ --shadow-quiet:
105
+ 0 1px 3px 0 oklch(14.08% 0.004 285.8 / 0.15), 0 1px 2px -1px oklch(14.08% 0.004 285.8 / 0.15);
106
+ --inset-shadow-*: initial;
107
+ --drop-shadow-*: initial;
108
+ --text-shadow-*: initial;
109
+ --blur-*: initial;
110
+ --container-*: initial;
111
+ --container-read: 560px;
112
+ --container-thread: 760px;
113
+ --container-dialog: 440px;
114
+ --container-menu: 192px;
115
+ /* A folded line in a thread (an agent's actions line) is at least this wide. */
116
+ --container-fold: 360px;
117
+ }
118
+
119
+ /* Two sizes off the 4 px scale that Paper draws: an initial's disc before a
120
+ message's author (18) and the small marks in rows and chips (14). */
121
+ @theme {
122
+ --spacing-avatar: 18px;
123
+ --spacing-mark: 14px;
124
+ }
125
+
126
+ /* Values that depend on the surface, density or nesting an element sits in. */
127
+ @theme inline {
128
+ --color-hover: var(--tk-hover);
129
+ --color-selected: var(--tk-selected);
130
+ --radius-inner: var(--tk-inner);
131
+ --inset-shadow-highlight: inset 0 1px 0 var(--color-highlight);
132
+ }
133
+
134
+ @custom-variant light (&:where([data-theme="light"], [data-theme="light"] *));
135
+
136
+ /* data-preview pins a state for the kit page, so every state can be shown at once. */
137
+ @custom-variant hover {
138
+ &:hover {
139
+ @slot;
140
+ }
141
+ &[data-preview~="hover"] {
142
+ @slot;
143
+ }
144
+ }
145
+ @custom-variant active {
146
+ &:active {
147
+ @slot;
148
+ }
149
+ &[data-preview~="pressed"] {
150
+ @slot;
151
+ }
152
+ }
153
+
154
+ /* Data is mono: it is the role for things a person could copy. */
155
+ @utility text-data {
156
+ font-family: var(--font-mono);
157
+ }
158
+
159
+ /* The scrollbar thumb's colour (Paper "Scrollbars · options", option B). Registered so
160
+ it can transition: a scrollbar pseudo-element cannot be transitioned itself, but it
161
+ follows this property. */
162
+ @property --tk-thumb {
163
+ syntax: "<color>";
164
+ inherits: true;
165
+ initial-value: transparent;
166
+ }
167
+
168
+ /* A panel's one native scroll container: scrolls on y only and keeps a steady 12 px
169
+ lane; the thumb brightens while the pointer or focus is inside. (ScrollArea draws
170
+ the same thumb over its edge instead.) */
171
+ @utility scroller {
172
+ overflow-x: hidden;
173
+ overflow-y: scroll;
174
+ --tk-thumb: var(--color-edge);
175
+ transition: --tk-thumb 300ms ease-out 600ms;
176
+ &:hover,
177
+ &:focus-within {
178
+ --tk-thumb: var(--color-edge-strong);
179
+ transition: --tk-thumb 150ms ease-out;
180
+ }
181
+ @media (prefers-reduced-motion: reduce) {
182
+ transition: none;
183
+ }
184
+ }
185
+
186
+ /* A code line that wraps instead of scrolling sideways; wrapped parts hang 2ch in. */
187
+ @utility wrap-code {
188
+ white-space: pre-wrap;
189
+ overflow-wrap: anywhere;
190
+ padding-inline-start: 2ch;
191
+ text-indent: -2ch;
192
+ }
193
+
194
+ /* Code is mono too, a step larger than data. */
195
+ @utility text-code {
196
+ font-family: var(--font-mono);
197
+ }
198
+
199
+ /* A row's height and inline padding, read from the nearest density-*. */
200
+ @utility h-row {
201
+ height: var(--tk-row);
202
+ }
203
+ @utility px-row {
204
+ padding-inline: var(--tk-row-x);
205
+ }
206
+
207
+ /* A container's density: rows inside read h-row and px-row. */
208
+ @utility density-roomy {
209
+ --tk-row: 48px;
210
+ --tk-row-x: 16px;
211
+ }
212
+ @utility density-normal {
213
+ --tk-row: 40px;
214
+ --tk-row-x: 12px;
215
+ }
216
+ @utility density-dense {
217
+ --tk-row: 32px;
218
+ --tk-row-x: 8px;
219
+ }
220
+
221
+ /* A region in one tone; sets bg-hover and bg-selected for what sits on it. */
222
+ @utility surface-window {
223
+ background-color: var(--color-window);
224
+ color: var(--color-ink);
225
+ --tk-hover: var(--color-tray);
226
+ --tk-selected: var(--tk-window-selected);
227
+ }
228
+ @utility surface-stage {
229
+ background-color: var(--color-stage);
230
+ color: var(--color-ink);
231
+ --tk-hover: var(--color-tray);
232
+ --tk-selected: var(--color-card);
233
+ }
234
+ @utility surface-tray {
235
+ background-color: var(--color-tray);
236
+ color: var(--color-ink);
237
+ --tk-hover: var(--color-card);
238
+ --tk-selected: var(--color-band);
239
+ }
240
+ @utility surface-card {
241
+ background-color: var(--color-card);
242
+ color: var(--color-ink);
243
+ --tk-hover: var(--color-band);
244
+ --tk-selected: var(--color-band);
245
+ }
246
+ @utility surface-band {
247
+ background-color: var(--color-band);
248
+ color: var(--color-ink);
249
+ --tk-hover: var(--color-edge);
250
+ --tk-selected: var(--color-edge);
251
+ }
252
+
253
+ /* A rounded, padded container whose children take rounded-inner: nest-lg/1. */
254
+ @utility nest-* {
255
+ border-radius: --value(--radius-*);
256
+ padding: --modifier(--spacing-*);
257
+ --tk-inner: max(0px, --value(--radius-*) - --modifier(--spacing-*));
258
+ }
259
+
260
+ /* Keyboard focus: a 2 px brand-text ring with a 2 px gap. */
261
+ @utility focus-ring {
262
+ &:is(:focus-visible, [data-preview~="focus"]) {
263
+ outline: 2px solid var(--color-brand-text);
264
+ outline-offset: 2px;
265
+ }
266
+ }
267
+
268
+ /* A key's lip: a 2 px bottom edge (1 px all round in light) in translucent near-black. */
269
+ @utility lip {
270
+ border-style: solid;
271
+ border-color: var(--color-lip);
272
+ border-width: var(--tk-key-side) var(--tk-key-side) 2px;
273
+ }
274
+
275
+ /* A key's light edge: a translucent white inner ring and top line. */
276
+ @utility highlight {
277
+ @apply inset-ring inset-ring-highlight inset-shadow-highlight;
278
+ }
279
+
280
+ /* A filled key: fill fading to 85% toward the top, lip, highlight, raised shadow. */
281
+ @utility key {
282
+ @apply lip highlight bg-linear-to-t/oklch shadow-raised hover:brightness-110 active:brightness-90;
283
+ }
284
+
285
+ /* Block padding that centres one row line in a 32 px control (6 px). */
286
+ @utility py-line {
287
+ padding-block: calc((var(--spacing-8) - var(--text-row--line-height)) / 2);
288
+ }
289
+
290
+ /* Centres text on its cap height where the webview supports it. */
291
+ @utility text-trim {
292
+ text-box: trim-both cap alphabetic;
293
+ }
294
+
295
+ @utility link {
296
+ color: var(--color-brand-text);
297
+ text-decoration-line: underline;
298
+ text-decoration-thickness: 1px;
299
+ text-underline-offset: 0.2em;
300
+ }
301
+
302
+ @layer base {
303
+ :root,
304
+ [data-theme] {
305
+ color-scheme: dark;
306
+ --tk-hover: var(--color-tray);
307
+ --tk-selected: var(--color-card);
308
+ --tk-window-selected: var(--color-card);
309
+ --tk-row: 40px;
310
+ --tk-row-x: 12px;
311
+ --tk-key-side: 0px;
312
+ --tk-thumb: var(--color-edge);
313
+ font: 400 var(--text-row) / var(--text-row--line-height) var(--font-sans);
314
+ color: var(--color-ink);
315
+ -webkit-font-smoothing: antialiased;
316
+ -moz-osx-font-smoothing: grayscale;
317
+ font-synthesis: none;
318
+ }
319
+ [data-theme="light"] {
320
+ color-scheme: light;
321
+ --color-window: oklch(94.01% 0 0);
322
+ --color-stage: oklch(100% 0 0);
323
+ --color-tray: oklch(97.02% 0 0);
324
+ --color-card: oklch(94.61% 0 0);
325
+ --color-band: oklch(92.19% 0 0);
326
+ --color-chip: oklch(94.61% 0 0);
327
+ --color-lifted: oklch(90.67% 0 0);
328
+ --color-ink: oklch(20.46% 0 0);
329
+ --color-ink-2: oklch(40.91% 0 0);
330
+ --color-ink-3: oklch(51.03% 0 0);
331
+ --color-added: oklch(48.09% 0.118 151.7);
332
+ --color-removed: oklch(50.542% 0.1905 27.52);
333
+ --color-warn: oklch(49.402% 0.1093 66.91);
334
+ --color-info: oklch(48.82% 0.217 264.4);
335
+ --color-added-tint: oklch(96.12% 0.017 159.1);
336
+ --color-removed-tint: oklch(95.66% 0.018 17.5);
337
+ --color-warn-tint: oklch(96.92% 0.031 86.5);
338
+ --color-info-tint: oklch(95.67% 0.019 263);
339
+ --color-diff-added: oklch(97.5% 0.014 155);
340
+ --color-diff-removed: oklch(97.2% 0.013 20);
341
+ --color-brand: oklch(49% 0.24 300.8);
342
+ --color-brand-text: oklch(49% 0.24 300.8);
343
+ --color-brand-ink: oklch(100% 0 0);
344
+ --color-brand-tint: oklch(95.56% 0.02 308.2);
345
+ --color-edge: oklch(20.46% 0 0 / 0.12);
346
+ --color-edge-strong: oklch(20.46% 0 0 / 0.5);
347
+ --color-lip: oklch(14.08% 0.004 285.8 / 0.4);
348
+ --color-highlight: oklch(100% 0 0 / 0.25);
349
+ --tk-window-selected: var(--color-stage);
350
+ --tk-key-side: 1px;
351
+ }
352
+ /* Every native scroller gets the quiet thumb (option B): a 4 px thumb in a 12 px lane.
353
+ WebKit (Tauri on macOS and Linux) and Chromium (Tauri on Windows). Setting either
354
+ standard scrollbar property switches these rules off, hence the guard. */
355
+ @supports selector(::-webkit-scrollbar) {
356
+ ::-webkit-scrollbar {
357
+ width: 12px;
358
+ height: 12px;
359
+ }
360
+ ::-webkit-scrollbar-track,
361
+ ::-webkit-scrollbar-corner {
362
+ background: transparent;
363
+ }
364
+ ::-webkit-scrollbar-thumb {
365
+ background-color: var(--tk-thumb);
366
+ background-clip: content-box;
367
+ border: 4px solid transparent;
368
+ border-radius: 999px;
369
+ min-height: 32px;
370
+ min-width: 32px;
371
+ }
372
+ ::-webkit-scrollbar-thumb:hover,
373
+ ::-webkit-scrollbar-thumb:active {
374
+ background-color: var(--color-ink-3);
375
+ }
376
+ /* ScrollArea draws its own thumb and hides the native bar with scrollbar-width: none,
377
+ which WebKit before Safari 18.2 (macOS 14 and 15) ignores: hide it here too, or the
378
+ lane above would draw a second thumb. */
379
+ [data-slot="scroll-area-viewport"]::-webkit-scrollbar {
380
+ display: none;
381
+ }
382
+ }
383
+ /* Engines without the pseudo-elements (Firefox): no inset or radius control there. */
384
+ @supports not selector(::-webkit-scrollbar) {
385
+ * {
386
+ scrollbar-width: thin;
387
+ scrollbar-color: var(--tk-thumb) transparent;
388
+ }
389
+ }
390
+ :focus-visible {
391
+ outline: 2px solid var(--color-brand-text);
392
+ outline-offset: 2px;
393
+ }
394
+ :focus:not(:focus-visible) {
395
+ outline: none;
396
+ }
397
+ }
@@ -0,0 +1,40 @@
1
+ /*
2
+ <Tooltip.Root>
3
+ <Tooltip.Trigger variant="ghost" icon={icons.search} label="Search" />
4
+ <Tooltip.Content>Search threads</Tooltip.Content>
5
+ </Tooltip.Root>
6
+
7
+ Plain text, 12/16 on the band tone. Status words live here.
8
+ */
9
+ import * as Base from "@ui-sdk/solid/tooltip";
10
+ import { omit } from "solid-js";
11
+ import type { ComponentProps } from "@solidjs/web";
12
+ import { ButtonContent, buttonClass, lookKeys, type ButtonLook } from "./button.tsx";
13
+ import { cn } from "./cn.ts";
14
+
15
+ export const Root = Base.Tooltip;
16
+
17
+ export function Trigger(
18
+ props: Omit<ComponentProps<typeof Base.TooltipTrigger>, "children" | "class"> & ButtonLook,
19
+ ) {
20
+ const rest = omit(props, ...lookKeys);
21
+ return (
22
+ <Base.TooltipTrigger {...rest} class={buttonClass(props)} aria-label={props.label}>
23
+ <ButtonContent {...props} />
24
+ </Base.TooltipTrigger>
25
+ );
26
+ }
27
+
28
+ export function Content(
29
+ props: Omit<ComponentProps<typeof Base.TooltipContent>, "class"> & { class?: string },
30
+ ) {
31
+ return (
32
+ <Base.TooltipContent
33
+ {...omit(props, "class")}
34
+ class={cn(
35
+ "z-50 m-0 rounded-sm border-0 bg-band px-2 py-1 text-label text-ink inset-ring inset-ring-edge",
36
+ props.class,
37
+ )}
38
+ />
39
+ );
40
+ }
package/tests/setup.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { afterEach } from "vitest";
2
+ declare global {
3
+ var __UI_SDK_STRICT__: boolean | undefined;
4
+ }
5
+ globalThis.__UI_SDK_STRICT__ = true;
6
+ if (typeof window !== "undefined") {
7
+ window.scrollTo = () => {};
8
+ HTMLElement.prototype.showPopover = function () {};
9
+ HTMLElement.prototype.hidePopover = function () {};
10
+ Element.prototype.getAnimations = () => [];
11
+ Element.prototype.scrollIntoView = function () {};
12
+ Element.prototype.checkVisibility = () => true;
13
+ Element.prototype.getClientRects = () => [] as unknown as DOMRectList;
14
+ document.elementFromPoint = () => null;
15
+ document.elementsFromPoint = () => [];
16
+ globalThis.ResizeObserver = class {
17
+ observe() {}
18
+ unobserve() {}
19
+ disconnect() {}
20
+ };
21
+ document.head.append(
22
+ Object.assign(document.createElement("style"), {
23
+ textContent: "[popover] { display: block !important }",
24
+ }),
25
+ );
26
+ }
27
+ afterEach(() => {
28
+ if (typeof document !== "undefined") document.body.replaceChildren();
29
+ });