devnonla-ui 0.12.0 → 0.13.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.
package/src/styles.css CHANGED
@@ -1,6 +1,4 @@
1
1
  @import "highlight.js/styles/github-dark-dimmed.css";
2
- @import "@fontsource-variable/inter/index.css";
3
- @import "@fontsource-variable/inter/wght-italic.css";
4
2
 
5
3
  /**
6
4
  * NonlaUI theme — single source of color.
@@ -23,9 +21,9 @@
23
21
  color-scheme: dark;
24
22
 
25
23
  /* ── Knobs / Seed (override these) ──────────────────────────────────── */
26
- /* chrome #141414, editor #181818, base #f0f0f0. Text ranks follow Cursor's mix. */
24
+ /* Cursor dashboard chrome. Page #141414, sidebar and cards #181818. */
27
25
  --nonla-bg: #141414;
28
- --nonla-fg: #f0f0f0;
26
+ --nonla-fg: #ffffff;
29
27
  --nonla-fg-muted: color-mix(in oklab, var(--nonla-fg) 74%, var(--nonla-bg));
30
28
  --nonla-fg-tertiary: color-mix(in oklab, var(--nonla-fg) 60%, var(--nonla-bg));
31
29
  --nonla-fg-quaternary: color-mix(in oklab, var(--nonla-fg) 36%, var(--nonla-bg));
@@ -38,23 +36,28 @@
38
36
  --nonla-warn: #f1b467;
39
37
  /* Cursor "Learn more" — the only chromatic link. */
40
38
  --nonla-link: #81a1c1;
39
+ /* Body sits a step under the page ink. Headings stay on --nonla-fg so they don't pick up a gray cast from the mix. */
40
+ --md-ink: color-mix(in oklab, var(--nonla-fg) 78%, var(--nonla-bg));
41
+ --md-heading: var(--nonla-fg);
42
+ /* Inline code chip. A light wash, not a solid stamp. */
43
+ --md-inline-bg: color-mix(in oklab, var(--nonla-fg) 6%, var(--nonla-surface));
41
44
  --nonla-radius: 8px;
42
45
  --nonla-height: 32px;
43
46
  --nonla-height-sm: 24px;
44
47
  --nonla-height-lg: 40px;
45
48
 
46
49
  --nonla-ink: var(--nonla-fg);
47
- /* Page #141414, sidebar and cards #181818. Borders are ink hairlines, same as the dashboard. */
50
+ /* Page #141414. Sidebar and cards are the same step lighter, #181818. */
48
51
  --nonla-sidebar: #181818;
49
52
  --nonla-surface: #181818;
50
53
  --nonla-elevated: var(--nonla-surface);
51
54
  --nonla-chip: color-mix(in oklab, var(--nonla-fg) 6%, var(--nonla-surface));
52
55
  --nonla-chip-hover: color-mix(in oklab, var(--nonla-fg) 10%, var(--nonla-surface));
53
- /* border-tertiary 8%. Inputs use border-secondary 12%. */
54
- --nonla-border: color-mix(in oklab, var(--nonla-fg) 8%, transparent);
55
- /* Card ring and table rules — border-quaternary, lighter than --nonla-border. */
56
- --nonla-hairline: color-mix(in oklab, var(--nonla-fg) 4%, transparent);
57
- --nonla-input: color-mix(in oklab, var(--nonla-fg) 12%, transparent);
56
+ /* Hairlines on #1e1e1e. A step under the old 8% / 12% so they don't read heavy. */
57
+ --nonla-border: color-mix(in oklab, var(--nonla-fg) 6%, transparent);
58
+ /* Card ring and table rules — lighter than --nonla-border. */
59
+ --nonla-hairline: color-mix(in oklab, var(--nonla-fg) 3%, transparent);
60
+ --nonla-input: color-mix(in oklab, var(--nonla-fg) 9%, transparent);
58
61
  --nonla-composer: var(--nonla-surface);
59
62
  --nonla-chat-bg: var(--nonla-bg);
60
63
  /* Opaque header fill. */
@@ -72,28 +75,13 @@
72
75
  --nonla-ink-line: var(--nonla-border);
73
76
  --nonla-desktop-bar-height: 42px;
74
77
  /* Desktop window title bar. Body stays on --nonla-bg. */
75
- --nonla-window-header: #323233;
78
+ --nonla-window-header: #242424;
76
79
  --nonla-z-base: 0;
77
80
  --nonla-z-desktop: 20;
78
81
  --nonla-z-window: 30;
79
82
  --nonla-z-header: 40;
80
83
  --nonla-z-popup-base: 1000;
81
84
 
82
- /* Preset accents — Cursor dark seeds. Only used when a control asks for color="blue" / … */
83
- --nonla-blue: #7bafe9;
84
- --nonla-purple: #9386f2;
85
- --nonla-cyan: #81a1c1;
86
- --nonla-green: #3fa266;
87
- --nonla-magenta: #b48ead;
88
- --nonla-pink: #b48ead;
89
- --nonla-red: #fc6b83;
90
- --nonla-orange: #d08770;
91
- --nonla-yellow: #f1b467;
92
- --nonla-volcano: #fc6b83;
93
- --nonla-geekblue: #7bafe9;
94
- --nonla-lime: #70b489;
95
- --nonla-gold: #f1b467;
96
-
97
85
  /* ── Map + Alias (do not set unless you need a one-off exception) ───── */
98
86
  --nonla-radius-sm: max(0px, calc(var(--nonla-radius) - 2px));
99
87
  --nonla-radius-lg: calc(var(--nonla-radius) + 2px);
@@ -152,6 +140,8 @@
152
140
  --elevated-shadow: 0 16px 48px rgb(0 0 0 / 45%), 0 0 0 1px color-mix(in srgb, var(--nonla-fg) 8%, transparent);
153
141
  --popper-shadow: 0 16px 48px rgb(0 0 0 / 45%), 0 0 0 1px color-mix(in srgb, var(--nonla-fg) 8%, transparent);
154
142
  --nonla-shadow: 0 16px 48px rgb(0 0 0 / 45%);
143
+ /* Short drop plus the ring. On a dark page the drop lifts the surface; the ring stays the edge. */
144
+ --nonla-card-shadow: 0 1px 2px rgb(0 0 0 / 32%), 0 0 0 1px var(--nonla-border);
155
145
  --popper-border: var(--nonla-border);
156
146
  --mask: rgb(0 0 0 / 56%);
157
147
  --meadow: var(--nonla-meadow);
@@ -173,7 +163,7 @@
173
163
 
174
164
  /* Chat type — body and headings share one size. */
175
165
  --chat-body-size: 14px;
176
- --chat-body-leading: 22px;
166
+ --chat-body-leading: 24px;
177
167
  --chat-p-mb: 12px;
178
168
  --chat-h-mt: 16px;
179
169
  --chat-h-mb: 8px;
@@ -185,50 +175,47 @@
185
175
  --nonla-scrollbar-thumb-hover: var(--nonla-fg-quaternary);
186
176
 
187
177
  color: var(--foreground);
188
- /* macOS default is subpixel AA, which makes Inter look heavier. */
189
- -webkit-font-smoothing: antialiased;
190
- -moz-osx-font-smoothing: grayscale;
178
+ font-weight: 400;
179
+ -webkit-font-smoothing: subpixel-antialiased;
180
+ -moz-osx-font-smoothing: auto;
191
181
  }
192
182
 
193
183
  /*
194
- * Daylight. Page is a step off white so white cards lift the way #181818 lifts off #141414.
184
+ * Daylight. Page is white. Sidebar sits a step off it.
195
185
  * Beats `.nonla-ui` re-declaring the dark seeds. `.dark` inside `.light` stays on the block above.
196
186
  */
197
187
  .light:not(.dark),
198
188
  .light .nonla-ui:not(.dark) {
199
189
  color-scheme: light;
200
190
 
201
- --nonla-bg: #f3f3f3;
202
- --nonla-fg: #141414;
191
+ --nonla-bg: #ffffff;
192
+ --nonla-fg: #2c2c2b;
193
+ --nonla-fg-muted: color-mix(in oklab, var(--nonla-fg) 74%, var(--nonla-bg));
194
+ --nonla-fg-tertiary: color-mix(in oklab, var(--nonla-fg) 60%, var(--nonla-bg));
195
+ --nonla-fg-quaternary: color-mix(in oklab, var(--nonla-fg) 36%, var(--nonla-bg));
203
196
  --nonla-danger: #dc3b3b;
204
197
  --nonla-success: #2f7d4a;
205
198
  --nonla-warn: #a16207;
206
199
  --nonla-link: #3b6d99;
200
+ --md-ink: #37352f;
201
+ --md-heading: var(--md-ink);
202
+ --md-inline-bg: color-mix(in oklab, var(--nonla-fg) 6%, var(--nonla-surface));
207
203
 
208
- --nonla-sidebar: #ffffff;
204
+ /* Neutral on the brand hue (~63°). Chroma stays low so it reads gray, not cream. */
205
+ --nonla-sidebar: #f7f5f2;
209
206
  --nonla-surface: #ffffff;
210
- --nonla-meadow: #f3f3f3;
207
+ --nonla-border: color-mix(in oklab, var(--nonla-fg) 8%, transparent);
208
+ --nonla-hairline: color-mix(in oklab, var(--nonla-fg) 4%, transparent);
209
+ --nonla-input: color-mix(in oklab, var(--nonla-fg) 12%, transparent);
210
+ --nonla-meadow: #ffffff;
211
211
  --nonla-window-header: #e8e8e8;
212
212
 
213
- /* Darker than the night pastels so solid chips stay readable on white. */
214
- --nonla-blue: #3b7fc4;
215
- --nonla-purple: #6d5bd0;
216
- --nonla-cyan: #3d6a8c;
217
- --nonla-green: #2f7d4a;
218
- --nonla-magenta: #9a5f8a;
219
- --nonla-pink: #9a5f8a;
220
- --nonla-red: #e23b57;
221
- --nonla-orange: #c2613f;
222
- --nonla-yellow: #a16207;
223
- --nonla-volcano: #e23b57;
224
- --nonla-geekblue: #3b7fc4;
225
- --nonla-lime: #3d8f5c;
226
- --nonla-gold: #a16207;
227
-
228
213
  --elevated-shadow: 0 12px 32px rgb(0 0 0 / 12%), 0 0 0 1px color-mix(in srgb, var(--nonla-fg) 8%, transparent);
229
214
  --popper-shadow: 0 12px 32px rgb(0 0 0 / 12%), 0 0 0 1px color-mix(in srgb, var(--nonla-fg) 8%, transparent);
230
215
  --mask: rgb(0 0 0 / 40%);
231
216
  --nonla-shadow: 0 12px 32px rgb(0 0 0 / 12%);
217
+ /* White card on a white page. A drop shadow smears the ring into a gray halo, so the edge is the ring alone. */
218
+ --nonla-card-shadow: 0 0 0 1px var(--nonla-border);
232
219
  --shadow-drop: 0 2px 8px rgb(0 0 0 / 12%);
233
220
  --shadow-panel: 0 0 0 1px var(--border), 0 4px 16px rgb(0 0 0 / 10%);
234
221
  }
@@ -324,9 +311,12 @@
324
311
  --spacing-field-nav: 32px;
325
312
  --spacing-desktop-bar: var(--nonla-desktop-bar-height);
326
313
 
327
- --font-sans: "Inter Variable", sans-serif;
314
+ --font-sans: ui-sans-serif, -apple-system, system-ui, "Segoe UI Variable Display", "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
328
315
  --font-family-sans: var(--font-sans);
329
316
  --default-font-family: var(--font-sans);
317
+ --font-mono: SFMono-Regular, Menlo, Consolas, "PT Mono", "Liberation Mono", Courier, monospace;
318
+ --font-family-mono: var(--font-mono);
319
+ --default-mono-font-family: var(--font-mono);
330
320
 
331
321
  --text-2xs: 11px;
332
322
  --text-2xs--line-height: 14px;
@@ -709,6 +699,21 @@
709
699
  background: color-mix(in oklab, var(--foreground) 10%, var(--card));
710
700
  }
711
701
 
702
+ /* Daylight page is white. The lifted fill and the card shadow read as a gray smudge.
703
+ White fill, the field stroke, and no drop shadow. */
704
+ .light:not(.dark) .nonla-chat-input,
705
+ .light .nonla-ui:not(.dark) .nonla-chat-input {
706
+ background: var(--background);
707
+ box-shadow: none;
708
+ }
709
+
710
+ /* User bubble on a white page. The 10% well stamps a gray block; card white reads as no fill.
711
+ Match the sidebar, one warm step off the page. */
712
+ .light:not(.dark) .nonla-chat-user,
713
+ .light .nonla-ui:not(.dark) .nonla-chat-user {
714
+ background: var(--sidebar);
715
+ }
716
+
712
717
  /* Desktop window — solid page fill, no frost. Title bar is a step lighter. */
713
718
  .nonla-window-glass {
714
719
  border: 1px solid var(--border);
@@ -782,6 +787,20 @@
782
787
  width 380ms cubic-bezier(0.3, 1.25, 0.5, 1),
783
788
  height 380ms cubic-bezier(0.3, 1.25, 0.5, 1);
784
789
  }
790
+ /* Tabs underline — sits on the bar's hairline and glides with the active tab */
791
+ .nonla-tabs-ink {
792
+ position: absolute;
793
+ bottom: 0;
794
+ left: 0;
795
+ z-index: 1;
796
+ height: 2px;
797
+ border-radius: 2px 2px 0 0;
798
+ background: var(--brand);
799
+ pointer-events: none;
800
+ transition:
801
+ transform 380ms cubic-bezier(0.3, 1.25, 0.5, 1),
802
+ width 380ms cubic-bezier(0.3, 1.25, 0.5, 1);
803
+ }
785
804
 
786
805
  @media (prefers-reduced-motion: reduce) {
787
806
  .nonla-btn-glass {
@@ -790,7 +809,8 @@
790
809
  .nonla-btn-glass:active:not(:disabled):not([aria-disabled]) {
791
810
  transform: none;
792
811
  }
793
- .nonla-segmented-thumb {
812
+ .nonla-segmented-thumb,
813
+ .nonla-tabs-ink {
794
814
  transition: none;
795
815
  }
796
816
  }
@@ -980,6 +1000,20 @@
980
1000
  animation: nonla-pop-out 100ms var(--nonla-ease-in);
981
1001
  }
982
1002
 
1003
+ /* Inline code. The wash hugs the glyphs and a token stays on one line, so a table of chips does not turn into broken gray bars. */
1004
+ .nonla-inline-code {
1005
+ box-decoration-break: clone;
1006
+ -webkit-box-decoration-break: clone;
1007
+ border-radius: 4px;
1008
+ background: var(--md-inline-bg);
1009
+ padding: 0.12em 0.35em;
1010
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
1011
+ font-size: var(--md-inline-size, 14px);
1012
+ line-height: 1;
1013
+ white-space: nowrap;
1014
+ vertical-align: baseline;
1015
+ }
1016
+
983
1017
  .nonla-codeblock-pre code,
984
1018
  .nonla-codeblock-pre .hljs {
985
1019
  color: var(--foreground);
@@ -0,0 +1,261 @@
1
+ import { type CSSProperties, type KeyboardEvent, type ReactNode, useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
2
+ import { SolarIcon } from "../icon/SolarIcon";
3
+ import { solarIconName } from "../icon/solar";
4
+ import { cn } from "../lib/cn";
5
+
6
+ export type TabsItem = {
7
+ key: string;
8
+ label: ReactNode;
9
+ children?: ReactNode;
10
+ disabled?: boolean;
11
+ /** Solar icon name (`settings`), a legacy Fluent Color id (`settings-24`), or a node. */
12
+ icon?: ReactNode;
13
+ };
14
+
15
+ export type TabsProps = {
16
+ items: TabsItem[];
17
+ activeKey?: string;
18
+ defaultActiveKey?: string;
19
+ onChange?: (key: string) => void;
20
+ className?: string;
21
+ style?: CSSProperties;
22
+ "aria-label"?: string;
23
+ };
24
+
25
+ /** Chevron sits in the clear zone. Tabs scroll in past the fade. */
26
+ const FADE = 32;
27
+ const EDGE = 64;
28
+ const TAB_HEIGHT = 40;
29
+
30
+ type Ink = { left: number; width: number };
31
+ type Overflow = { left: boolean; right: boolean };
32
+
33
+ function firstEnabled(items: TabsItem[], preferred?: string) {
34
+ if (preferred && items.some((item) => item.key === preferred)) return preferred;
35
+ return items.find((item) => !item.disabled)?.key ?? items[0]?.key ?? "";
36
+ }
37
+
38
+ function fadeOf(overflow: Overflow): "left" | "right" | "both" | "none" {
39
+ if (overflow.left && overflow.right) return "both";
40
+ if (overflow.left) return "left";
41
+ if (overflow.right) return "right";
42
+ return "none";
43
+ }
44
+
45
+ function maskImage(fade: ReturnType<typeof fadeOf>) {
46
+ if (fade === "left") return `linear-gradient(to right, transparent ${FADE}px, #000 ${EDGE}px)`;
47
+ if (fade === "right") return `linear-gradient(to left, transparent ${FADE}px, #000 ${EDGE}px)`;
48
+ if (fade === "both") return `linear-gradient(to right, transparent ${FADE}px, #000 ${EDGE}px, #000 calc(100% - ${EDGE}px), transparent calc(100% - ${FADE}px))`;
49
+ return undefined;
50
+ }
51
+
52
+ function scrollToX(el: HTMLElement, target: number) {
53
+ const max = Math.max(0, el.scrollWidth - el.clientWidth);
54
+ el.scrollLeft = Math.min(max, Math.max(0, target));
55
+ }
56
+
57
+ function TabIcon({ icon, size }: { icon?: ReactNode; size: number }) {
58
+ if (icon == null || icon === false) return null;
59
+ if (typeof icon === "string") return <SolarIcon name={solarIconName(icon)} size={size} />;
60
+ return <span className="inline-flex shrink-0 items-center justify-center">{icon}</span>;
61
+ }
62
+
63
+ function ScrollButton({ dir, onClick }: { dir: "left" | "right"; onClick: () => void }) {
64
+ return (
65
+ <button
66
+ type="button"
67
+ aria-label={dir === "left" ? "Scroll tabs left" : "Scroll tabs right"}
68
+ className={cn(
69
+ "absolute top-0 z-10 flex h-full w-8 cursor-pointer items-center justify-center border-0 bg-transparent text-tertiary-foreground hover:text-foreground",
70
+ dir === "left" ? "left-0" : "right-0",
71
+ )}
72
+ onClick={onClick}
73
+ >
74
+ <SolarIcon name={dir === "left" ? "alt-arrow-left-linear" : "alt-arrow-right-linear"} size={16} />
75
+ </button>
76
+ );
77
+ }
78
+
79
+ export function Tabs({ items, activeKey, defaultActiveKey, onChange, className, style, "aria-label": ariaLabel = "Tabs" }: TabsProps) {
80
+ const uid = useId();
81
+
82
+ const [inner, setInner] = useState(() => firstEnabled(items, defaultActiveKey));
83
+ const active = firstEnabled(items, activeKey ?? inner);
84
+ const itemsKey = items.map((item) => item.key).join("\0");
85
+
86
+ const scrollerRef = useRef<HTMLDivElement>(null);
87
+ const rowRef = useRef<HTMLDivElement>(null);
88
+ const tabRefs = useRef(new Map<string, HTMLButtonElement>());
89
+ const focusKey = useRef<string | null>(null);
90
+
91
+ const [ink, setInk] = useState<Ink | null>(null);
92
+ const [overflow, setOverflow] = useState<Overflow>({ left: false, right: false });
93
+
94
+ const updateOverflow = useCallback(() => {
95
+ const el = scrollerRef.current;
96
+ if (!el) return;
97
+ const max = el.scrollWidth - el.clientWidth;
98
+ const left = el.scrollLeft > 1;
99
+ const right = max > 1 && el.scrollLeft < max - 1;
100
+ setOverflow((prev) => (prev.left === left && prev.right === right ? prev : { left, right }));
101
+ }, []);
102
+
103
+ const reveal = useCallback(() => {
104
+ const scroller = scrollerRef.current;
105
+ const tab = tabRefs.current.get(active);
106
+ if (!scroller || !tab) return;
107
+ const max = scroller.scrollWidth - scroller.clientWidth;
108
+ if (max <= 1) return;
109
+ const left = tab.offsetLeft;
110
+ const right = left + tab.offsetWidth;
111
+ const viewLeft = scroller.scrollLeft + EDGE;
112
+ const viewRight = scroller.scrollLeft + scroller.clientWidth - EDGE;
113
+ if (left < viewLeft) scrollToX(scroller, left - EDGE);
114
+ else if (right > viewRight) scrollToX(scroller, right - scroller.clientWidth + EDGE);
115
+ updateOverflow();
116
+ }, [active, updateOverflow]);
117
+
118
+ useLayoutEffect(() => {
119
+ const row = rowRef.current;
120
+ const measure = () => {
121
+ const el = tabRefs.current.get(active);
122
+ if (!el) {
123
+ setInk(null);
124
+ return;
125
+ }
126
+ const next = { left: el.offsetLeft, width: el.offsetWidth };
127
+ setInk((prev) => (prev && prev.left === next.left && prev.width === next.width ? prev : next));
128
+ updateOverflow();
129
+ };
130
+ measure();
131
+ const ro = new ResizeObserver(measure);
132
+ if (row) ro.observe(row);
133
+ if (scrollerRef.current) ro.observe(scrollerRef.current);
134
+ return () => ro.disconnect();
135
+ }, [active, itemsKey, updateOverflow]);
136
+
137
+ useLayoutEffect(() => {
138
+ reveal();
139
+ }, [active, itemsKey, reveal]);
140
+
141
+ useLayoutEffect(() => {
142
+ const key = focusKey.current;
143
+ if (!key || key !== active) return;
144
+ focusKey.current = null;
145
+ tabRefs.current.get(key)?.focus({ preventScroll: true });
146
+ }, [active]);
147
+
148
+ useEffect(() => {
149
+ const el = scrollerRef.current;
150
+ if (!el) return;
151
+ const onWheel = (event: WheelEvent) => {
152
+ if (el.scrollWidth <= el.clientWidth + 1) return;
153
+ if (Math.abs(event.deltaX) >= Math.abs(event.deltaY)) return;
154
+ if (event.deltaY === 0) return;
155
+ const max = el.scrollWidth - el.clientWidth;
156
+ const next = Math.min(max, Math.max(0, el.scrollLeft + event.deltaY));
157
+ if (next === el.scrollLeft) return;
158
+ el.scrollLeft = next;
159
+ updateOverflow();
160
+ event.preventDefault();
161
+ };
162
+ el.addEventListener("wheel", onWheel, { passive: false });
163
+ return () => el.removeEventListener("wheel", onWheel);
164
+ }, [itemsKey, updateOverflow]);
165
+
166
+ function select(key: string, fromKeyboard = false) {
167
+ if (fromKeyboard) focusKey.current = key;
168
+ if (activeKey === undefined) setInner(key);
169
+ if (key !== active) onChange?.(key);
170
+ }
171
+
172
+ function nudge(dir: -1 | 1) {
173
+ const el = scrollerRef.current;
174
+ if (!el) return;
175
+ const step = dir * Math.max(96, Math.round(el.clientWidth * 0.72));
176
+ scrollToX(el, el.scrollLeft + step);
177
+ updateOverflow();
178
+ }
179
+
180
+ function onKeyDown(event: KeyboardEvent<HTMLDivElement>) {
181
+ const enabled = items.filter((item) => !item.disabled);
182
+ if (!enabled.length) return;
183
+ const index = enabled.findIndex((item) => item.key === active);
184
+ let next = -1;
185
+ if (event.key === "ArrowRight") next = index < 0 ? 0 : (index + 1) % enabled.length;
186
+ else if (event.key === "ArrowLeft") next = index < 0 ? enabled.length - 1 : (index - 1 + enabled.length) % enabled.length;
187
+ else if (event.key === "Home") next = 0;
188
+ else if (event.key === "End") next = enabled.length - 1;
189
+ else return;
190
+ event.preventDefault();
191
+ const item = enabled[next];
192
+ if (item) select(item.key, true);
193
+ }
194
+
195
+ const fade = fadeOf(overflow);
196
+ const mask = maskImage(fade);
197
+ const panel = items.find((item) => item.key === active);
198
+ const showPanel = items.some((item) => item.children != null);
199
+
200
+ return (
201
+ <div className={cn("w-full min-w-0", className)} style={style}>
202
+ <div className="relative">
203
+ <div aria-hidden className="pointer-events-none absolute inset-x-0 bottom-0 h-px bg-border" />
204
+ <div
205
+ ref={scrollerRef}
206
+ className="nonla-scroll-hidden relative overflow-x-auto overflow-y-hidden overscroll-x-contain"
207
+ style={mask ? { maskImage: mask, WebkitMaskImage: mask } : undefined}
208
+ onScroll={updateOverflow}
209
+ >
210
+ <div ref={rowRef} role="tablist" aria-label={ariaLabel} aria-orientation="horizontal" className="relative flex w-max gap-3" onKeyDown={onKeyDown}>
211
+ {ink ? <span aria-hidden className="nonla-tabs-ink" style={{ width: ink.width, transform: `translateX(${ink.left}px)` }} /> : null}
212
+ {items.map((item) => {
213
+ const selected = item.key === active;
214
+ return (
215
+ <button
216
+ key={item.key}
217
+ ref={(node) => {
218
+ if (node) tabRefs.current.set(item.key, node);
219
+ else tabRefs.current.delete(item.key);
220
+ }}
221
+ type="button"
222
+ role="tab"
223
+ id={`${uid}-tab-${item.key}`}
224
+ aria-selected={selected}
225
+ aria-controls={showPanel ? `${uid}-panel` : undefined}
226
+ tabIndex={selected ? 0 : -1}
227
+ disabled={item.disabled}
228
+ className={cn(
229
+ "relative z-10 inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap border-0 bg-transparent font-normal text-tertiary-foreground transition-colors select-none",
230
+ "hover:text-foreground focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none focus-visible:ring-inset",
231
+ "disabled:cursor-not-allowed disabled:opacity-40",
232
+ selected && "text-foreground",
233
+ )}
234
+ style={{
235
+ height: TAB_HEIGHT,
236
+ paddingLeft: 4,
237
+ paddingRight: 4,
238
+ fontSize: 14,
239
+ }}
240
+ onClick={() => {
241
+ if (!item.disabled) select(item.key);
242
+ }}
243
+ >
244
+ <TabIcon icon={item.icon} size={16} />
245
+ {item.label}
246
+ </button>
247
+ );
248
+ })}
249
+ </div>
250
+ </div>
251
+ {overflow.left ? <ScrollButton dir="left" onClick={() => nudge(-1)} /> : null}
252
+ {overflow.right ? <ScrollButton dir="right" onClick={() => nudge(1)} /> : null}
253
+ </div>
254
+ {showPanel ? (
255
+ <div role="tabpanel" id={`${uid}-panel`} aria-labelledby={`${uid}-tab-${active}`} className="pt-3">
256
+ {panel?.children}
257
+ </div>
258
+ ) : null}
259
+ </div>
260
+ );
261
+ }
package/src/tag/Tag.tsx CHANGED
@@ -27,19 +27,19 @@ const NAMED_VAR: Record<string, string> = {
27
27
  warning: "var(--warn)",
28
28
  processing: "var(--link)",
29
29
  brand: "var(--brand)",
30
- blue: "var(--nonla-blue)",
31
- purple: "var(--nonla-purple)",
32
- cyan: "var(--nonla-cyan)",
33
- green: "var(--nonla-green)",
34
- magenta: "var(--nonla-magenta)",
35
- pink: "var(--nonla-pink)",
36
- orange: "var(--nonla-orange)",
37
- gold: "var(--nonla-gold)",
38
- red: "var(--nonla-red)",
39
- yellow: "var(--nonla-yellow)",
40
- volcano: "var(--nonla-volcano)",
41
- geekblue: "var(--nonla-geekblue)",
42
- lime: "var(--nonla-lime)",
30
+ blue: "light-dark(#3b7fc4, #7bafe9)",
31
+ purple: "light-dark(#6d5bd0, #9386f2)",
32
+ cyan: "light-dark(#3d6a8c, #81a1c1)",
33
+ green: "light-dark(#2f7d4a, #3fa266)",
34
+ magenta: "light-dark(#9a5f8a, #b48ead)",
35
+ pink: "light-dark(#9a5f8a, #b48ead)",
36
+ orange: "light-dark(#c2613f, #d08770)",
37
+ gold: "light-dark(#a16207, #f1b467)",
38
+ red: "light-dark(#e23b57, #fc6b83)",
39
+ yellow: "light-dark(#a16207, #f1b467)",
40
+ volcano: "light-dark(#e23b57, #fc6b83)",
41
+ geekblue: "light-dark(#3b7fc4, #7bafe9)",
42
+ lime: "light-dark(#3d8f5c, #70b489)",
43
43
  };
44
44
 
45
45
  const SOFT = "bg-[color-mix(in_oklab,var(--nonla-tag)_12%,transparent)] text-[color-mix(in_oklab,var(--nonla-tag)_72%,black)]";
package/src/theme.ts CHANGED
@@ -2,10 +2,8 @@
2
2
  * Theme knobs for NonlaUI.
3
3
  *
4
4
  * Defaults live in `styles.css` on `:root` / `.nonla-ui`.
5
+ * Consumers retheme by overriding `--nonla-*` in CSS. Aliases follow those knobs.
5
6
  * `--brand-50`…`--brand-800` follow `--nonla-brand` (500 = the knob).
6
- * Consumers retheme without touching components:
7
- * 1. CSS: `:root { --nonla-brand: #3b82f6; }`
8
- * 2. JS: `<App theme={{ colors: { brand: "#3b82f6" } }} />` or `applyNonlaTheme({ brand: "#3b82f6" })`
9
7
  * Color mode is `light` | `dark` on `<html>` (`setColorMode`, `<ThemeToggle>`). Dark is the default.
10
8
  * `<ThemeSwitcher>` also stores `system`, which follows the OS and still paints `light` or `dark`.
11
9
  */
@@ -52,83 +50,13 @@ export const NONLA_THEME_KEYS = {
52
50
  zWindow: "--nonla-z-window",
53
51
  zHeader: "--nonla-z-header",
54
52
  zPopupBase: "--nonla-z-popup-base",
55
- blue: "--nonla-blue",
56
- purple: "--nonla-purple",
57
- cyan: "--nonla-cyan",
58
- green: "--nonla-green",
59
- magenta: "--nonla-magenta",
60
- pink: "--nonla-pink",
61
- red: "--nonla-red",
62
- orange: "--nonla-orange",
63
- yellow: "--nonla-yellow",
64
- volcano: "--nonla-volcano",
65
- geekblue: "--nonla-geekblue",
66
- lime: "--nonla-lime",
67
- gold: "--nonla-gold",
68
53
  } as const;
69
54
 
70
55
  export type NonlaThemeKnobName = keyof typeof NONLA_THEME_KEYS;
71
56
  export type NonlaThemeKnob = (typeof NONLA_THEME_KEYS)[NonlaThemeKnobName];
72
57
 
73
- const METRIC_KEYS = new Set<NonlaThemeKnobName>(["radius", "height", "heightSm", "heightLg", "desktopBarHeight", "zBase", "zDesktop", "zWindow", "zHeader", "zPopupBase"]);
74
-
75
- export type NonlaThemeColorName = Exclude<
76
- NonlaThemeKnobName,
77
- "radius" | "height" | "heightSm" | "heightLg" | "desktopBarHeight" | "zBase" | "zDesktop" | "zWindow" | "zHeader" | "zPopupBase"
78
- >;
79
- export type NonlaThemeColors = { [K in NonlaThemeColorName]?: string };
80
-
81
- /** Flat aliases → knob name (`colorBorder` == `colors.border`). */
82
- const COLOR_ALIASES = {
83
- colorBorder: "border",
84
- colorBorderInput: "borderInput",
85
- /** @deprecated use `borderInput` / `colorBorderInput` */
86
- input: "borderInput",
87
- } as const satisfies Record<string, NonlaThemeColorName>;
88
-
89
58
  export const NONLA_THEME_KNOBS = Object.values(NONLA_THEME_KEYS);
90
59
 
91
- export type NonlaThemeConfig = {
92
- [K in NonlaThemeKnobName]?: string;
93
- } & {
94
- /** Grouped color knobs — same names as the flat keys (`colors.border`, `colors.borderInput`, …). */
95
- colors?: NonlaThemeColors;
96
- /** Alias of `colors.border` / `border`. */
97
- colorBorder?: string;
98
- /** Alias of `colors.borderInput` / `borderInput`. */
99
- colorBorderInput?: string;
100
- /** Extra CSS custom properties (include the leading `--`). */
101
- vars?: Record<string, string>;
102
- };
103
-
104
- function entriesOf(theme: NonlaThemeConfig): [string, string][] {
105
- const map = new Map<string, string>();
106
- const set = (key: string, value: unknown) => {
107
- if (typeof value !== "string" || !value) return;
108
- const knob = (COLOR_ALIASES as Record<string, NonlaThemeKnobName>)[key] ?? (key as NonlaThemeKnobName);
109
- const prop = NONLA_THEME_KEYS[knob];
110
- if (prop) map.set(prop, value);
111
- };
112
-
113
- if (theme.colors) {
114
- for (const [key, value] of Object.entries(theme.colors)) {
115
- if (METRIC_KEYS.has(key as NonlaThemeKnobName)) continue;
116
- set(key, value);
117
- }
118
- }
119
- set("colorBorder", theme.colorBorder);
120
- set("colorBorderInput", theme.colorBorderInput);
121
- for (const key of Object.keys(NONLA_THEME_KEYS) as NonlaThemeKnobName[]) {
122
- set(key, theme[key]);
123
- }
124
- if (theme.vars) {
125
- for (const [prop, value] of Object.entries(theme.vars)) {
126
- if (value) map.set(prop, value);
127
- }
128
- }
129
- return [...map.entries()];
130
- }
131
-
132
60
  export type NonlaTokenSnapshot = { [K in NonlaThemeKnobName]: string };
133
61
 
134
62
  /** Read computed `--nonla-*` knobs (`getDesignToken`). */
@@ -141,19 +69,6 @@ export function getDesignToken(target?: HTMLElement): NonlaTokenSnapshot {
141
69
  return token;
142
70
  }
143
71
 
144
- /** Apply knobs on an element (defaults to `:root`). Returns a restore function. */
145
- export function applyNonlaTheme(theme: NonlaThemeConfig, target: HTMLElement = document.documentElement): () => void {
146
- const entries = entriesOf(theme);
147
- const prev = entries.map(([prop]) => [prop, target.style.getPropertyValue(prop)] as const);
148
- for (const [prop, value] of entries) target.style.setProperty(prop, value);
149
- return () => {
150
- for (const [prop, value] of prev) {
151
- if (value) target.style.setProperty(prop, value);
152
- else target.style.removeProperty(prop);
153
- }
154
- };
155
- }
156
-
157
72
  export type NonlaColorMode = "light" | "dark";
158
73
 
159
74
  /** Stored choice. `system` follows the OS and still applies `light` or `dark` on `<html>`. */