devnonla-ui 0.8.0 → 0.9.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 (59) hide show
  1. package/README.md +31 -4
  2. package/package.json +3 -3
  3. package/src/app/App.tsx +5 -1
  4. package/src/app/context.ts +5 -3
  5. package/src/button/Button.tsx +2 -2
  6. package/src/button/ButtonCopy.tsx +2 -2
  7. package/src/card/Card.tsx +81 -0
  8. package/src/chat/AgentChatbox.tsx +1 -1
  9. package/src/chat/AgentPanel.tsx +1 -1
  10. package/src/chat/message-ui/ChatError.tsx +2 -2
  11. package/src/chat/message-ui/ChatInput.tsx +5 -5
  12. package/src/chat/message-ui/ChatMarkdown.tsx +8 -7
  13. package/src/chat/message-ui/ChatThinking.tsx +3 -3
  14. package/src/chat/message-ui/ChatUserMessage.tsx +3 -3
  15. package/src/chat/message-ui/MermaidBlock.tsx +68 -39
  16. package/src/chat/tool-ui/BackgroundTasksBar.tsx +3 -3
  17. package/src/chat/tool-ui/CallAgentToolUI.tsx +3 -3
  18. package/src/chat/tool-ui/ChatToolCall.tsx +4 -4
  19. package/src/chat/tool-ui/GetCurrentTimeToolUI.tsx +2 -2
  20. package/src/chat/tool-ui/ReadSkillToolUI.tsx +2 -2
  21. package/src/chat/tool-ui/RunJsToolUI.tsx +2 -2
  22. package/src/chat/tool-ui/ToolUiTrailing.tsx +3 -3
  23. package/src/chat/tool-ui/WebFetchToolUI.tsx +2 -2
  24. package/src/checkbox/Checkbox.tsx +17 -4
  25. package/src/codeblock/CodeBlock.tsx +2 -2
  26. package/src/datepicker/DatePicker.tsx +3 -3
  27. package/src/desktop/DesktopHeader.tsx +1 -1
  28. package/src/desktop/DesktopIcon.tsx +2 -2
  29. package/src/desktop/DesktopWindow.tsx +51 -29
  30. package/src/empty/Empty.tsx +8 -5
  31. package/src/form/FormItem.tsx +1 -1
  32. package/src/form-layout/FormLayout.tsx +1 -1
  33. package/src/icon/SolarIcon.tsx +39 -0
  34. package/src/icon/solar.ts +172 -0
  35. package/src/index.ts +24 -12
  36. package/src/input/EditableInput.tsx +3 -3
  37. package/src/input/Input.tsx +3 -3
  38. package/src/lib/sizes.ts +9 -6
  39. package/src/lib/surface.ts +1 -1
  40. package/src/markdown-editor/MarkdownDiff.tsx +211 -0
  41. package/src/markdown-editor/MarkdownEditor.tsx +294 -0
  42. package/src/markdown-editor/MarkdownPreview.tsx +326 -0
  43. package/src/markdown-editor/MarkdownSource.tsx +72 -0
  44. package/src/markdown-editor/blocks.ts +329 -0
  45. package/src/markdown-editor/diff.ts +296 -0
  46. package/src/menu/Menu.tsx +3 -3
  47. package/src/pagination/Pagination.tsx +8 -7
  48. package/src/segmented/Segmented.tsx +2 -2
  49. package/src/select/Select.tsx +192 -63
  50. package/src/sidebar/Sidebar.tsx +9 -8
  51. package/src/spin/Spin.tsx +17 -11
  52. package/src/styles.css +265 -110
  53. package/src/switch/Switch.tsx +17 -3
  54. package/src/table/Table.tsx +61 -26
  55. package/src/theme-toggle/ThemeToggle.tsx +33 -0
  56. package/src/theme.ts +72 -0
  57. package/src/timepicker/TimePicker.tsx +1 -1
  58. package/src/icon/FluentIcon.tsx +0 -28
  59. package/src/icon/fluent.ts +0 -75
@@ -1,5 +1,5 @@
1
- import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from "lucide-react";
2
1
  import { type ComponentType, type CSSProperties, cloneElement, isValidElement, type KeyboardEvent, type ReactElement, type ReactNode, useEffect, useState } from "react";
2
+ import { SolarIcon } from "../icon/SolarIcon";
3
3
  import { cn } from "../lib/cn";
4
4
  import { type CanonicalSize, type ControlSize, controlFieldFocusBorder, controlFieldSurface, controlFieldTransition, controlHeightVar, controlRadiusVar, getSizeTokens, useControlSize } from "../lib/sizes";
5
5
  import { Select, type SelectProps } from "../select/Select";
@@ -44,7 +44,8 @@ export type PaginationProps = {
44
44
  showQuickJumper?: boolean | { goButton?: ReactNode };
45
45
  showSizeChanger?: boolean | SelectProps;
46
46
  showTitle?: boolean;
47
- showTotal?: (total: number, range: [number, number]) => ReactNode;
47
+ /** `false` hides the total. A function renders it. */
48
+ showTotal?: false | ((total: number, range: [number, number]) => ReactNode);
48
49
  simple?: boolean | { readOnly?: boolean };
49
50
  size?: ControlSize;
50
51
  totalBoundaryShowSizeChanger?: number;
@@ -136,7 +137,7 @@ function JumpInner({ dir, icon }: { dir: "prev" | "next"; icon: number }) {
136
137
  <span className="relative inline-flex size-full items-center justify-center">
137
138
  <span className="leading-none group-hover:opacity-0 group-focus-visible:opacity-0">…</span>
138
139
  <span className="absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100">
139
- {dir === "prev" ? <ChevronsLeft size={icon} strokeWidth={2} /> : <ChevronsRight size={icon} strokeWidth={2} />}
140
+ {dir === "prev" ? <SolarIcon name="double-alt-arrow-left-linear" size={icon} /> : <SolarIcon name="double-alt-arrow-right-linear" size={icon} />}
140
141
  </span>
141
142
  </span>
142
143
  );
@@ -184,7 +185,7 @@ function MiniField({
184
185
  }
185
186
  }}
186
187
  className={cn(
187
- "text-center tabular-nums text-foreground placeholder:text-quaternary-foreground",
188
+ "text-center tabular-nums text-foreground placeholder:text-placeholder",
188
189
  controlFieldSurface,
189
190
  controlFieldTransition,
190
191
  controlFieldFocusBorder,
@@ -368,8 +369,8 @@ export function Pagination(props: PaginationProps) {
368
369
 
369
370
  const sizeOptions = toSizes(pageSizeOptions);
370
371
 
371
- const prevInner = wrap(page - 1, "prev", <ChevronLeft size={icon} strokeWidth={2} />);
372
- const nextInner = wrap(page + 1, "next", <ChevronRight size={icon} strokeWidth={2} />);
372
+ const prevInner = wrap(page - 1, "prev", <SolarIcon name="alt-arrow-left-linear" size={icon} />);
373
+ const nextInner = wrap(page + 1, "next", <SolarIcon name="alt-arrow-right-linear" size={icon} />);
373
374
 
374
375
  const pager = isSimple ? (
375
376
  <>
@@ -561,7 +562,7 @@ function JumperField({
561
562
  }
562
563
  }}
563
564
  className={cn(
564
- "text-center tabular-nums text-foreground placeholder:text-quaternary-foreground",
565
+ "text-center tabular-nums text-foreground placeholder:text-placeholder",
565
566
  controlFieldSurface,
566
567
  controlFieldTransition,
567
568
  controlFieldFocusBorder,
@@ -60,7 +60,7 @@ export function Segmented<V extends string | number = string | number>({ options
60
60
  <div
61
61
  ref={rootRef}
62
62
  className={cn(
63
- "relative inline-flex w-fit max-w-full shrink-0 items-center gap-0.5 rounded-lg border border-solid border-glass-border bg-glass-bar p-0.5 shadow-[inset_0_1px_0_var(--glass-highlight)] backdrop-blur-xl",
63
+ "relative inline-flex w-fit max-w-full shrink-0 items-center gap-0.5 rounded-lg border border-solid border-border bg-muted p-0.5",
64
64
  block && "flex w-full",
65
65
  className,
66
66
  )}
@@ -71,7 +71,7 @@ export function Segmented<V extends string | number = string | number>({ options
71
71
  {thumb ? (
72
72
  <span
73
73
  aria-hidden
74
- className="nonla-segmented-thumb pointer-events-none absolute border border-solid border-glass-border bg-glass shadow-[inset_0_1px_0_var(--glass-highlight),0_1px_3px_color-mix(in_srgb,black_10%,transparent)]"
74
+ className="nonla-segmented-thumb pointer-events-none absolute border border-solid border-border bg-card"
75
75
  style={{
76
76
  width: thumb.width,
77
77
  height: thumb.height,
@@ -6,6 +6,7 @@ import {
6
6
  type ReactElement,
7
7
  type ReactNode,
8
8
  useEffect,
9
+ useId,
9
10
  useLayoutEffect,
10
11
  useMemo,
11
12
  useRef,
@@ -103,9 +104,10 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
103
104
  const [query, setQuery] = useState("");
104
105
  const [active, setActive] = useState(0);
105
106
  const [triggerW, setTriggerW] = useState<number>();
106
- const triggerRef = useRef<HTMLButtonElement | null>(null);
107
+ const triggerRef = useRef<HTMLElement | null>(null);
107
108
  const searchRef = useRef<HTMLInputElement>(null);
108
109
  const listRef = useRef<HTMLDivElement>(null);
110
+ const listId = useId();
109
111
  const resolvedSize = useControlSize(size);
110
112
  const portal = usePopupContainer()?.();
111
113
 
@@ -133,12 +135,16 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
133
135
  setActive(0);
134
136
  return;
135
137
  }
136
- const idx = options.findIndex((o) => o.value === selected);
137
- setActive(idx >= 0 ? idx : 0);
138
- if (searchable) {
139
- const t = window.setTimeout(() => searchRef.current?.focus(), 0);
140
- return () => window.clearTimeout(t);
138
+ // Opening by typing already set `query` and highlight. A click opens with an empty query.
139
+ if (!query) {
140
+ const idx = options.findIndex((o) => o.value === selected);
141
+ setActive(idx >= 0 ? idx : 0);
141
142
  }
143
+ if (!searchable) return;
144
+ const t = window.setTimeout(() => searchRef.current?.focus(), 0);
145
+ return () => window.clearTimeout(t);
146
+ // `query` is only read for the closed → open transition.
147
+ // eslint-disable-next-line react-hooks/exhaustive-deps
142
148
  }, [open, searchable]);
143
149
 
144
150
  useEffect(() => {
@@ -175,6 +181,42 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
175
181
  }
176
182
  };
177
183
 
184
+ const onSearchKey = (e: KeyboardEvent<HTMLInputElement>) => {
185
+ if (disabled || e.nativeEvent.isComposing) return;
186
+ if (!open) {
187
+ if (e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Enter" || e.key === " ") {
188
+ e.preventDefault();
189
+ setOpen(true);
190
+ }
191
+ return;
192
+ }
193
+ if (e.key === "ArrowDown") {
194
+ e.preventDefault();
195
+ move(1);
196
+ } else if (e.key === "ArrowUp") {
197
+ e.preventDefault();
198
+ move(-1);
199
+ } else if (e.key === "Enter") {
200
+ e.preventDefault();
201
+ pickActive();
202
+ } else if (e.key === "Escape") {
203
+ e.preventDefault();
204
+ setOpen(false);
205
+ } else if (e.key === "Tab") {
206
+ setOpen(false);
207
+ }
208
+ };
209
+
210
+ const focusSearch = () => {
211
+ const input = searchRef.current;
212
+ if (!input) return;
213
+ input.focus();
214
+ const end = input.value.length;
215
+ input.setSelectionRange(end, end);
216
+ };
217
+
218
+ const eventInsideTrigger = (target: EventTarget | null) => target instanceof Node && !!triggerRef.current?.contains(target);
219
+
178
220
  const onListKey = (e: KeyboardEvent) => {
179
221
  if (e.key === "ArrowDown") {
180
222
  e.preventDefault();
@@ -191,13 +233,27 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
191
233
  }
192
234
  };
193
235
 
194
- const setRefs = (node: HTMLButtonElement | null) => {
236
+ const setRefs = (node: HTMLElement | null) => {
195
237
  triggerRef.current = node;
196
- if (typeof ref === "function") ref(node);
197
- else if (ref) (ref as { current: HTMLButtonElement | null }).current = node;
238
+ const buttonNode = node as HTMLButtonElement | null;
239
+ if (typeof ref === "function") ref(buttonNode);
240
+ else if (ref) ref.current = buttonNode;
198
241
  };
199
242
 
200
243
  const showClear = allowClear && selected != null && selected !== "" && !disabled;
244
+ const display = selectedOpt ? selectedOpt.label : selected != null && selected !== "" ? String(selected) : placeholder;
245
+ const displayEmpty = !selectedOpt && (selected == null || selected === "");
246
+ const activeId = open && filtered[active] ? `${listId}-opt-${active}` : undefined;
247
+
248
+ const fieldClass = cn(
249
+ "group/select inline-flex w-full items-center gap-2 text-left",
250
+ controlFieldSurface,
251
+ controlFieldTransition,
252
+ controlFieldFocusBorder,
253
+ "outline-none disabled:cursor-not-allowed disabled:opacity-45",
254
+ controlStatusClass(status),
255
+ className,
256
+ );
201
257
 
202
258
  return (
203
259
  <PopoverPrimitive.Root
@@ -207,56 +263,142 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
207
263
  setOpen(v);
208
264
  }}
209
265
  >
210
- <PopoverPrimitive.Trigger asChild>
211
- <button
212
- ref={setRefs}
213
- type="button"
214
- disabled={disabled}
215
- aria-haspopup="listbox"
216
- aria-expanded={open}
217
- className={cn(
218
- "group/select inline-flex w-full cursor-pointer items-center gap-2 text-left",
219
- controlFieldSurface,
220
- controlFieldTransition,
221
- controlFieldFocusBorder,
222
- "focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45",
223
- controlStatusClass(status),
224
- className,
225
- )}
226
- style={controlFieldStyle(resolvedSize)}
227
- onKeyDown={onTriggerKey}
228
- >
229
- <span className={cn("min-w-0 flex-1 truncate", selected == null || selected === "" ? "text-quaternary-foreground" : "")}>
230
- {selectedOpt ? selectedOpt.label : selected != null && selected !== "" ? String(selected) : placeholder}
231
- </span>
232
- {showClear ? (
266
+ {searchable ? (
267
+ <PopoverPrimitive.Anchor asChild>
268
+ <div
269
+ ref={setRefs}
270
+ data-state={open ? "open" : "closed"}
271
+ aria-disabled={disabled || undefined}
272
+ className={cn(fieldClass, "cursor-text", disabled && "cursor-not-allowed opacity-45")}
273
+ style={controlFieldStyle(resolvedSize)}
274
+ onPointerDown={(e) => {
275
+ if (disabled) return;
276
+ const target = e.target as HTMLElement;
277
+ if (target.closest("[data-select-affix]")) return;
278
+ if (!open) setOpen(true);
279
+ if (target !== searchRef.current) {
280
+ e.preventDefault();
281
+ focusSearch();
282
+ }
283
+ }}
284
+ >
285
+ <div className="relative min-w-0 flex-1 overflow-hidden">
286
+ <span aria-hidden className={cn("block truncate", (open && query) || displayEmpty ? "invisible" : "")}>
287
+ {displayEmpty ? placeholder : display}
288
+ </span>
289
+ <input
290
+ ref={searchRef}
291
+ role="combobox"
292
+ aria-expanded={open}
293
+ aria-controls={listId}
294
+ aria-activedescendant={activeId}
295
+ aria-autocomplete="list"
296
+ aria-label={placeholder}
297
+ disabled={disabled}
298
+ autoComplete="off"
299
+ autoCorrect="off"
300
+ spellCheck={false}
301
+ value={open ? query : ""}
302
+ placeholder={displayEmpty ? placeholder : undefined}
303
+ onChange={(e) => {
304
+ setQuery(e.target.value);
305
+ setActive(0);
306
+ if (!open) setOpen(true);
307
+ }}
308
+ onKeyDown={onSearchKey}
309
+ className={cn(
310
+ "absolute inset-0 w-full border-0 bg-transparent p-0 font-[inherit] leading-[inherit] text-inherit outline-none placeholder:text-placeholder",
311
+ !open && "caret-transparent",
312
+ )}
313
+ />
314
+ </div>
315
+ {showClear ? (
316
+ <span
317
+ data-select-affix=""
318
+ role="button"
319
+ tabIndex={-1}
320
+ aria-label="Clear"
321
+ className="inline-flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-full text-muted-foreground opacity-0 transition-opacity hover:bg-ink-hover hover:text-foreground group-hover/select:opacity-100"
322
+ onPointerDown={(e) => {
323
+ e.preventDefault();
324
+ e.stopPropagation();
325
+ }}
326
+ onClick={(e) => {
327
+ e.preventDefault();
328
+ e.stopPropagation();
329
+ commit(null);
330
+ }}
331
+ >
332
+ <ClearIcon />
333
+ </span>
334
+ ) : null}
233
335
  <span
234
- role="button"
235
- tabIndex={-1}
236
- aria-label="Clear"
237
- className="inline-flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-full text-muted-foreground opacity-0 transition-opacity hover:bg-ink-hover hover:text-foreground group-hover/select:opacity-100"
238
- onPointerDown={(e) => e.preventDefault()}
239
- onClick={(e) => {
336
+ data-select-affix=""
337
+ className="inline-flex shrink-0 cursor-pointer"
338
+ onPointerDown={(e) => {
240
339
  e.preventDefault();
241
340
  e.stopPropagation();
242
- commit(null);
341
+ if (disabled) return;
342
+ setOpen((v) => !v);
243
343
  }}
244
344
  >
245
- <ClearIcon />
345
+ <Chevron />
246
346
  </span>
247
- ) : null}
248
- <Chevron />
249
- </button>
250
- </PopoverPrimitive.Trigger>
347
+ </div>
348
+ </PopoverPrimitive.Anchor>
349
+ ) : (
350
+ <PopoverPrimitive.Trigger asChild>
351
+ <button
352
+ ref={setRefs}
353
+ type="button"
354
+ disabled={disabled}
355
+ aria-haspopup="listbox"
356
+ aria-expanded={open}
357
+ className={cn(fieldClass, "cursor-pointer focus-visible:outline-none")}
358
+ style={controlFieldStyle(resolvedSize)}
359
+ onKeyDown={onTriggerKey}
360
+ >
361
+ <span className={cn("min-w-0 flex-1 truncate", displayEmpty && "text-placeholder")}>{display}</span>
362
+ {showClear ? (
363
+ <span
364
+ role="button"
365
+ tabIndex={-1}
366
+ aria-label="Clear"
367
+ className="inline-flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-full text-muted-foreground opacity-0 transition-opacity hover:bg-ink-hover hover:text-foreground group-hover/select:opacity-100"
368
+ onPointerDown={(e) => e.preventDefault()}
369
+ onClick={(e) => {
370
+ e.preventDefault();
371
+ e.stopPropagation();
372
+ commit(null);
373
+ }}
374
+ >
375
+ <ClearIcon />
376
+ </span>
377
+ ) : null}
378
+ <Chevron />
379
+ </button>
380
+ </PopoverPrimitive.Trigger>
381
+ )}
251
382
  <PopoverPrimitive.Portal container={portal}>
252
383
  <PopoverPrimitive.Content
253
384
  align="start"
254
385
  sideOffset={4}
255
386
  onOpenAutoFocus={(e) => {
256
- if (searchable) {
257
- e.preventDefault();
258
- searchRef.current?.focus();
259
- }
387
+ if (!searchable) return;
388
+ e.preventDefault();
389
+ focusSearch();
390
+ }}
391
+ onCloseAutoFocus={(e) => {
392
+ if (searchable) e.preventDefault();
393
+ }}
394
+ onFocusOutside={(e) => {
395
+ if (searchable && eventInsideTrigger(e.target)) e.preventDefault();
396
+ }}
397
+ onPointerDownOutside={(e) => {
398
+ if (searchable && eventInsideTrigger(e.target)) e.preventDefault();
399
+ }}
400
+ onInteractOutside={(e) => {
401
+ if (searchable && eventInsideTrigger(e.target)) e.preventDefault();
260
402
  }}
261
403
  onKeyDown={onListKey}
262
404
  className={cn(
@@ -269,27 +411,14 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
269
411
  width: popupMatchSelectWidth ? triggerW : undefined,
270
412
  }}
271
413
  >
272
- {searchable ? (
273
- <div className="border-b border-glass-border p-1.5">
274
- <input
275
- ref={searchRef}
276
- value={query}
277
- onChange={(e) => {
278
- setQuery(e.target.value);
279
- setActive(0);
280
- }}
281
- placeholder="Search…"
282
- className="h-7 w-full rounded-md border-0 bg-transparent px-2 text-sm text-foreground outline-none placeholder:text-quaternary-foreground"
283
- />
284
- </div>
285
- ) : null}
286
- <div ref={listRef} role="listbox" tabIndex={-1} className="flex max-h-72 flex-col gap-px overflow-auto p-1">
414
+ <div ref={listRef} id={listId} role="listbox" tabIndex={-1} className="nonla-select-options flex max-h-72 flex-col gap-0.5 overflow-auto p-1">
287
415
  {filtered.length === 0 ? (
288
416
  <div className="px-2.5 py-2 text-sm text-muted-foreground">No results</div>
289
417
  ) : (
290
418
  filtered.map((opt, i) => (
291
419
  <div
292
420
  key={String(opt.value)}
421
+ id={`${listId}-opt-${i}`}
293
422
  role="option"
294
423
  tabIndex={-1}
295
424
  aria-selected={opt.value === selected}
@@ -1,5 +1,6 @@
1
1
  import { type MouseEvent, type ReactNode, useMemo, useState } from "react";
2
- import { FluentIcon } from "../icon/FluentIcon";
2
+ import { SolarIcon } from "../icon/SolarIcon";
3
+ import { solarIconName } from "../icon/solar";
3
4
  import { SearchInput } from "../input/SearchInput";
4
5
  import { cn } from "../lib/cn";
5
6
  import { OverlayScroll } from "../scroll/OverlayScroll";
@@ -7,7 +8,7 @@ import { OverlayScroll } from "../scroll/OverlayScroll";
7
8
  export type SidebarItemType = {
8
9
  key?: string;
9
10
  label?: ReactNode;
10
- /** Fluent icon name, or a node. */
11
+ /** Solar icon name (`settings`), a legacy Fluent Color id (`settings-24`), or a node. String icons render as bold-duotone. */
11
12
  icon?: ReactNode;
12
13
  disabled?: boolean;
13
14
  type?: "item" | "group" | "divider";
@@ -75,7 +76,7 @@ function filterItems(items: SidebarItemType[], q: string): SidebarItemType[] {
75
76
 
76
77
  function ItemIcon({ icon }: { icon?: ReactNode }) {
77
78
  if (icon == null || icon === false) return null;
78
- if (typeof icon === "string") return <FluentIcon name={icon} size={16} />;
79
+ if (typeof icon === "string") return <SolarIcon name={solarIconName(icon, "bold-duotone")} size={16} />;
79
80
  return <span className="inline-flex size-4 shrink-0 items-center justify-center [&_img]:size-4 [&_svg]:size-4">{icon}</span>;
80
81
  }
81
82
 
@@ -99,11 +100,11 @@ function SidebarList({
99
100
  return (
100
101
  <div key={key} className="mb-4">
101
102
  {item.label != null && item.label !== "" ? (
102
- <div className={cn("px-2 pb-1.5 pt-2 text-[11px] font-medium uppercase tracking-wider text-quaternary-foreground", item.className)}>
103
+ <div className={cn("px-2.5 pb-1.5 pt-2 text-[11px] font-bold uppercase tracking-wider text-quaternary-foreground", item.className)}>
103
104
  {item.label}
104
105
  </div>
105
106
  ) : null}
106
- <div className="flex flex-col gap-0.5">
107
+ <div className="flex flex-col gap-1">
107
108
  <SidebarList items={item.children ?? []} selected={selected} onSelect={onSelect} />
108
109
  </div>
109
110
  </div>
@@ -112,9 +113,9 @@ function SidebarList({
112
113
 
113
114
  const active = selected != null && key === selected;
114
115
  const className = cn(
115
- "flex w-full items-center gap-2 rounded-md border-0 px-2 py-1.5 text-left text-sm no-underline",
116
+ "nonla-sidebar-item flex w-full items-center gap-2.5 px-2.5 text-left text-base no-underline",
116
117
  item.disabled ? "pointer-events-none cursor-not-allowed opacity-40" : "cursor-pointer",
117
- active ? "bg-ink-active font-medium text-foreground" : "bg-transparent text-foreground/80 hover:bg-ink-hover hover:text-foreground",
118
+ active ? "font-medium text-foreground" : "text-foreground/80 hover:text-foreground",
118
119
  item.className,
119
120
  );
120
121
 
@@ -122,7 +123,7 @@ function SidebarList({
122
123
  <>
123
124
  <ItemIcon icon={item.icon} />
124
125
  <span className="min-w-0 flex-1 truncate">{item.label}</span>
125
- {item.extra != null ? <span className="shrink-0 text-xs tabular-nums text-muted-foreground">{item.extra}</span> : null}
126
+ {item.extra != null ? <span className="shrink-0 text-sm tabular-nums text-muted-foreground">{item.extra}</span> : null}
126
127
  </>
127
128
  );
128
129
 
package/src/spin/Spin.tsx CHANGED
@@ -3,6 +3,8 @@ import { cn } from "../lib/cn";
3
3
  import { type ControlSize, getSizeTokens, normalizeSize, useControlSize } from "../lib/sizes";
4
4
 
5
5
  export type SpinVariant = "default" | "agent";
6
+ /** `brand` follows `--nonla-brand`. `neutral` is ink gray and ignores the brand hue. */
7
+ export type SpinColor = "brand" | "neutral";
6
8
 
7
9
  export type SpinProps = {
8
10
  spinning?: boolean;
@@ -10,6 +12,8 @@ export type SpinProps = {
10
12
  size?: ControlSize;
11
13
  /** Visual style — `agent` is the 3×3 snake for AI run states. */
12
14
  variant?: SpinVariant;
15
+ /** Indicator hue. `neutral` stays gray in light and dark. */
16
+ color?: SpinColor;
13
17
  /** Replace the built-in indicator entirely. */
14
18
  indicator?: ReactNode;
15
19
  children?: ReactNode;
@@ -20,11 +24,11 @@ function dimFor(size: ControlSize | undefined) {
20
24
  return Math.round(getSizeTokens(size).icon * 1.25);
21
25
  }
22
26
 
23
- function DefaultSpinner({ size }: { size: ControlSize | undefined }) {
27
+ function DefaultSpinner({ size, color }: { size: ControlSize | undefined; color: SpinColor }) {
24
28
  const dim = dimFor(size);
25
29
  return (
26
30
  <span
27
- className="inline-block rounded-full border-2 border-current/25 border-t-current animate-spin text-brand"
31
+ className={cn("inline-block rounded-full border-2 border-current/25 border-t-current animate-spin", color === "neutral" ? "text-muted-foreground" : "text-brand")}
28
32
  style={{ width: dim, height: dim }}
29
33
  aria-hidden
30
34
  />
@@ -84,7 +88,7 @@ function matrixMetrics(size: ControlSize | undefined): { cell: number; gap: numb
84
88
  }
85
89
 
86
90
  /** 3×3 fixed dots — 3 adjacent lit cells crawl randomly (snake). */
87
- function MatrixSnake({ size, tickMs = 240 }: { size: ControlSize | undefined; tickMs?: number }) {
91
+ function MatrixSnake({ size, color, tickMs = 240 }: { size: ControlSize | undefined; color: SpinColor; tickMs?: number }) {
88
92
  const { cell, gap } = matrixMetrics(size);
89
93
  const dim = cell * 3 + gap * 2;
90
94
  const [snake, setSnake] = useState<Snake>(() => randomSnake());
@@ -101,7 +105,7 @@ function MatrixSnake({ size, tickMs = 240 }: { size: ControlSize | undefined; ti
101
105
 
102
106
  return (
103
107
  <span
104
- className="nonla-spin-matrix inline-grid"
108
+ className={cn("nonla-spin-matrix inline-grid", color === "neutral" && "is-neutral")}
105
109
  style={{
106
110
  width: dim,
107
111
  height: dim,
@@ -118,30 +122,32 @@ function MatrixSnake({ size, tickMs = 240 }: { size: ControlSize | undefined; ti
118
122
  );
119
123
  }
120
124
 
121
- function Spinner({ size, variant }: { size: ControlSize | undefined; variant: SpinVariant }) {
122
- if (variant === "agent") return <MatrixSnake size={size} />;
123
- return <DefaultSpinner size={size} />;
125
+ function Spinner({ size, variant, color }: { size: ControlSize | undefined; variant: SpinVariant; color: SpinColor }) {
126
+ if (variant === "agent") return <MatrixSnake size={size} color={color} />;
127
+ return <DefaultSpinner size={size} color={color} />;
124
128
  }
125
129
 
126
130
  function Indicator({
127
131
  size,
128
132
  variant,
133
+ color,
129
134
  indicator,
130
135
  }: {
131
136
  size: ControlSize | undefined;
132
137
  variant: SpinVariant;
138
+ color: SpinColor;
133
139
  indicator?: ReactNode;
134
140
  }) {
135
141
  if (indicator != null) return <>{indicator}</>;
136
- return <Spinner size={size} variant={variant} />;
142
+ return <Spinner size={size} variant={variant} color={color} />;
137
143
  }
138
144
 
139
- export function Spin({ spinning = true, tip, size, variant = "default", indicator, children, className }: SpinProps) {
145
+ export function Spin({ spinning = true, tip, size, variant = "default", color = "brand", indicator, children, className }: SpinProps) {
140
146
  const resolvedSize = useControlSize(size);
141
147
  if (children == null) {
142
148
  return (
143
149
  <div className={cn("inline-flex flex-col items-center gap-2", className)} role={spinning ? "status" : undefined} aria-live={spinning ? "polite" : undefined}>
144
- {spinning ? <Indicator size={resolvedSize} variant={variant} indicator={indicator} /> : null}
150
+ {spinning ? <Indicator size={resolvedSize} variant={variant} color={color} indicator={indicator} /> : null}
145
151
  {tip ? <span className="text-xs text-muted-foreground">{tip}</span> : null}
146
152
  </div>
147
153
  );
@@ -151,7 +157,7 @@ export function Spin({ spinning = true, tip, size, variant = "default", indicato
151
157
  {children}
152
158
  {spinning ? (
153
159
  <div className="absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/50" role="status" aria-live="polite">
154
- <Indicator size={resolvedSize} variant={variant} indicator={indicator} />
160
+ <Indicator size={resolvedSize} variant={variant} color={color} indicator={indicator} />
155
161
  {tip ? <span className="text-xs text-muted-foreground">{tip}</span> : null}
156
162
  </div>
157
163
  ) : null}