devnonla-ui 0.8.0 → 0.9.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 (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 +301 -0
  42. package/src/markdown-editor/MarkdownPreview.tsx +346 -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
package/README.md CHANGED
@@ -55,6 +55,8 @@ Aliases: `xs` → small, `middle` / `medium` → default.
55
55
 
56
56
  All color lives in **`--nonla-*` knobs** (`src/styles.css`). Components never hardcode palette hex.
57
57
 
58
+ Dark is the default (`:root` and `.dark`). `.light` is the daylight palette. `<App>` calls `initColorMode()` once and restores `localStorage` key `nonla-color-mode`, falling back to dark. Switch with `setColorMode("light" | "dark")` or `<ThemeToggle>`. To start in daylight before paint, put `class="light"` on `<html>`.
59
+
58
60
  **Other apps** — import the CSS, then override knobs. Do not fork Button/Tag/….
59
61
 
60
62
  ```css
@@ -67,7 +69,7 @@ All color lives in **`--nonla-*` knobs** (`src/styles.css`). Components never ha
67
69
  }
68
70
  ```
69
71
 
70
- `--brand-50` … `--brand-800` follow `--nonla-brand` (500 = the knob). Text on cream uses `brand-700`. Text **on** the brand fill (Button primary, Tag solid, Checkbox) is `--nonla-solid-fg` / `colors.solidFg` — default white.
72
+ `--brand-50` … `--brand-800` follow `--nonla-brand` (500 = the knob). Tints mix into the surface; `brand-700` stays with the ink. Text **on** the brand fill (Button primary, Tag solid, Checkbox) is `--nonla-solid-fg` / `colors.solidFg` — default `#181818` on the neutral `#f0f0f0` fill.
71
73
 
72
74
  Or at runtime:
73
75
 
@@ -99,12 +101,27 @@ Those map into shadcn-standard tokens (`--background`, `--destructive`, …) plu
99
101
  </App>
100
102
  ```
101
103
 
104
+ # Card
105
+
106
+ Titled settings surface. `Card.Item` is a label row; `align="center"` for a short row, `split` so a field fills the trailing half. `Card.Footer` sits under the rows. `caption` is the note under the frame.
107
+
108
+ ```tsx
109
+ import { Card, Switch } from "devnonla-ui";
110
+
111
+ <Card title="General" caption="Applies to this workspace.">
112
+ <Card.Item label="Notifications" align="center">
113
+ <Switch />
114
+ </Card.Item>
115
+ <Card.Footer>Saved</Card.Footer>
116
+ </Card>
117
+ ```
118
+
102
119
  # Desktop
103
120
 
104
121
  Meadow wallpaper, window chrome, header bar, and desktop icons live in this package so other Nonla apps share the same shell.
105
122
 
106
123
  ```tsx
107
- import { DesktopStage, DesktopHeader, MeadowDesktop, DesktopWindow, MeadowShell, Menu, FluentIcon } from "devnonla-ui";
124
+ import { DesktopStage, DesktopHeader, MeadowDesktop, DesktopWindow, MeadowShell, Menu, SolarIcon } from "devnonla-ui";
108
125
 
109
126
  <DesktopStage>
110
127
  <MeadowDesktop>{icons}</MeadowDesktop>
@@ -175,10 +192,20 @@ Stream events:
175
192
 
176
193
  Primitives (`ChatWelcome`, `ChatUserMessage`, `ChatAgentMessage`, `ChatThinking`, `ChatToolCall`, `ChatInput`, `ChatError`, `ChatMarkdown`) stay exported for custom layouts.
177
194
 
195
+ # Markdown
196
+
197
+ `MarkdownEditor` edits markdown in preview, source, or diff. Pass `original` to enable the diff view. `diffLayout` is side by side by default. `readOnly` shows a finished document and hides the mode switcher.
198
+
199
+ ```tsx
200
+ import { MarkdownEditor } from "devnonla-ui";
201
+
202
+ <MarkdownEditor value={text} original={previous} onChange={setText} />
203
+ ```
204
+
178
205
  # Icons
179
206
 
180
- `FluentIcon` renders vendored Fluent Color (`@iconify-json/fluent-color`). No Solar / Lucide.
207
+ `SolarIcon` renders vendored Solar icons (`@iconify-json/solar`) as inline SVG, so they follow `currentColor`. Default style is `linear`. A legacy Fluent Color id such as `settings-24` still resolves to the Solar equivalent.
181
208
 
182
209
  ```tsx
183
- <FluentIcon name="settings-24" size={16} />
210
+ <SolarIcon name="settings-linear" size={16} />
184
211
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devnonla-ui",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "type": "module",
5
5
  "description": "NonlaUI — React controls for Nonla Agents",
6
6
  "author": "devlangla <devlangla0x01@gmail.com>",
@@ -37,7 +37,8 @@
37
37
  "react-hook-form": "^7.0.0"
38
38
  },
39
39
  "dependencies": {
40
- "@iconify-json/fluent-color": "^1.2.21",
40
+ "@fontsource-variable/inter": "^5.3.0",
41
+ "@iconify-json/solar": "^1.2.13",
41
42
  "@radix-ui/react-checkbox": "^1.3.3",
42
43
  "@radix-ui/react-context-menu": "^2.3.7",
43
44
  "@radix-ui/react-dialog": "^1.1.15",
@@ -49,7 +50,6 @@
49
50
  "clsx": "^2.1.1",
50
51
  "date-fns": "^4.4.0",
51
52
  "highlight.js": "^11.12.0",
52
- "lucide-react": "^1.45.0",
53
53
  "mermaid": "^11.14.0",
54
54
  "react-day-picker": "^10.0.1",
55
55
  "react-markdown": "^10.1.0",
package/src/app/App.tsx CHANGED
@@ -3,7 +3,7 @@ import { type ReactNode, useLayoutEffect, useMemo, useState } from "react";
3
3
  import { type ControlSize, ControlSizeContext, normalizeSize } from "../lib/sizes";
4
4
  import { MessageHolder, message } from "../message/message";
5
5
  import { ConfirmHolder, Modal } from "../modal/Modal";
6
- import { applyNonlaTheme, type NonlaThemeConfig } from "../theme";
6
+ import { applyNonlaTheme, initColorMode, type NonlaThemeConfig } from "../theme";
7
7
  import { AppContext, type NonlaAppConfig, useAppConfig, usePopupContainer, useToken } from "./context";
8
8
 
9
9
  export type { NonlaAppConfig };
@@ -27,6 +27,10 @@ export function App({ children, getPopupContainer, componentSize, theme }: AppPr
27
27
  [getPopupContainer, size, themeRev],
28
28
  );
29
29
 
30
+ useLayoutEffect(() => {
31
+ initColorMode();
32
+ }, []);
33
+
30
34
  useLayoutEffect(() => {
31
35
  if (!theme) return;
32
36
  const restore = applyNonlaTheme(theme);
@@ -1,6 +1,6 @@
1
- import { createContext, useContext, useMemo } from "react";
1
+ import { createContext, useContext, useMemo, useSyncExternalStore } from "react";
2
2
  import type { CanonicalSize } from "../lib/sizes";
3
- import { getDesignToken, type NonlaTokenSnapshot } from "../theme";
3
+ import { getColorMode, getDesignToken, type NonlaTokenSnapshot, subscribeColorMode } from "../theme";
4
4
 
5
5
  export type NonlaAppConfig = {
6
6
  getPopupContainer?: () => HTMLElement;
@@ -24,9 +24,11 @@ export function usePopupContainer(override?: () => HTMLElement) {
24
24
  /** Computed seed knobs under the current App theme (`useToken`). */
25
25
  export function useToken(): { token: NonlaTokenSnapshot } {
26
26
  const { themeRev } = useAppConfig();
27
+ const mode = useSyncExternalStore(subscribeColorMode, getColorMode, () => "dark" as const);
27
28
  const token = useMemo(() => {
28
29
  void themeRev;
30
+ void mode;
29
31
  return getDesignToken();
30
- }, [themeRev]);
32
+ }, [themeRev, mode]);
31
33
  return { token };
32
34
  }
@@ -73,7 +73,7 @@ const GroupSizeContext = createContext<ButtonSize | undefined>(undefined);
73
73
  function tokenAppearance(color: "default" | "primary" | "danger" | "link", variant: ButtonVariant, ghost: boolean): string {
74
74
  const g = ghost && variant !== "text" && variant !== "link";
75
75
  if (color === "primary") {
76
- if (variant === "solid" && !g) return "border-transparent bg-brand text-[var(--nonla-solid-fg)] hover:bg-[color-mix(in_oklab,var(--brand),white_14%)] active:bg-[color-mix(in_oklab,var(--brand),black_10%)]";
76
+ if (variant === "solid" && !g) return "border-transparent bg-brand text-[var(--nonla-solid-fg)] hover:bg-[color-mix(in_oklab,var(--brand),var(--background)_14%)] active:bg-[color-mix(in_oklab,var(--brand),black_18%)]";
77
77
  if (variant === "filled") return "bg-brand/15 text-brand-700 border-transparent hover:bg-brand/25";
78
78
  if (variant === "text") return "bg-transparent text-brand border-transparent hover:bg-brand/10";
79
79
  if (variant === "link") return "text-brand border-transparent hover:text-brand-700";
@@ -89,7 +89,7 @@ function tokenAppearance(color: "default" | "primary" | "danger" | "link", varia
89
89
  if (color === "link" || variant === "link") return "text-link border-transparent hover:text-link/80";
90
90
  if (variant === "filled") return "bg-muted text-foreground border-transparent hover:bg-muted/80";
91
91
  if (variant === "text") return "bg-transparent text-foreground border-transparent hover:bg-ink-hover hover:text-foreground";
92
- if (variant === "dashed") return "bg-transparent text-foreground border-dashed border-glass-border hover:bg-glass-bar backdrop-blur-xl";
92
+ if (variant === "dashed") return "bg-transparent text-foreground border-dashed border-border hover:bg-ink-hover";
93
93
  return "nonla-btn-glass text-foreground";
94
94
  }
95
95
 
@@ -1,5 +1,5 @@
1
- import { Check, Copy } from "lucide-react";
2
1
  import { type ComponentProps, useEffect, useState } from "react";
2
+ import { SolarIcon } from "../icon/SolarIcon";
3
3
  import { cn } from "../lib/cn";
4
4
  import { type ControlSize, getSizeTokens, useControlSize } from "../lib/sizes";
5
5
 
@@ -44,7 +44,7 @@ export function ButtonCopy({ text, getText, label = "Copy", className, onClick,
44
44
  }
45
45
  }}
46
46
  >
47
- {copied ? <Check size={icon} aria-hidden /> : <Copy size={icon} aria-hidden />}
47
+ {copied ? <SolarIcon name="check-linear" size={icon} /> : <SolarIcon name="copy-linear" size={icon} />}
48
48
  </button>
49
49
  );
50
50
  }
@@ -0,0 +1,81 @@
1
+ import type { HTMLAttributes, ReactNode } from "react";
2
+ import { cn } from "../lib/cn";
3
+
4
+ /** Hairline used by the dashboard card ring and row rules (`--nonla-hairline`). */
5
+ const HAIRLINE = "var(--nonla-hairline)";
6
+
7
+ export type CardProps = HTMLAttributes<HTMLElement> & {
8
+ /** Section label above the surface. */
9
+ title?: ReactNode;
10
+ /** Note under the surface, such as a “Learn more” link. */
11
+ caption?: ReactNode;
12
+ };
13
+
14
+ export type CardItemProps = HTMLAttributes<HTMLDivElement> & {
15
+ label?: ReactNode;
16
+ description?: ReactNode;
17
+ /**
18
+ * `start` — label and control align to the top (rows with a description).
19
+ * `center` — short rows, control vertically centered with the label.
20
+ */
21
+ align?: "start" | "center";
22
+ /** Split the row in half so a field can fill the trailing column. */
23
+ split?: boolean;
24
+ };
25
+
26
+ export type CardFooterProps = HTMLAttributes<HTMLDivElement>;
27
+
28
+ function CardRoot({ title, caption, className, children, ...rest }: CardProps) {
29
+ return (
30
+ <section className={cn("flex flex-col gap-[9px]", className)} {...rest}>
31
+ {title != null && title !== "" ? <div className="px-2 text-sm leading-4 text-foreground">{title}</div> : null}
32
+ <div className="flex flex-col self-stretch rounded-xl bg-card" style={{ boxShadow: `0 0 0 1px ${HAIRLINE}` }}>
33
+ {children}
34
+ </div>
35
+ {caption != null && caption !== "" ? <div className="px-3 text-xs leading-4 text-tertiary-foreground">{caption}</div> : null}
36
+ </section>
37
+ );
38
+ }
39
+
40
+ function CardItem({ label, description, align = "start", split = false, className, children, ...rest }: CardItemProps) {
41
+ const hasCopy = (label != null && label !== "") || (description != null && description !== "");
42
+ const centered = align === "center";
43
+
44
+ return (
45
+ <div
46
+ className={cn(
47
+ "relative flex w-full gap-5 px-4 py-3",
48
+ centered ? "items-center" : "items-start",
49
+ "before:pointer-events-none before:absolute before:top-0 before:right-4 before:left-4 before:h-px before:bg-hairline before:content-[''] first:before:hidden",
50
+ className,
51
+ )}
52
+ {...rest}
53
+ >
54
+ {hasCopy ? (
55
+ <>
56
+ <div className={cn("flex min-w-0 flex-1 flex-col gap-0.5", centered && "justify-center")}>
57
+ {label != null && label !== "" ? <div className="flex items-center gap-1 text-sm leading-5 text-foreground">{label}</div> : null}
58
+ {description != null && description !== "" ? <div className="text-sm text-muted-foreground">{description}</div> : null}
59
+ </div>
60
+ {children != null ? (
61
+ <div className={cn("flex min-h-6 min-w-0 justify-end gap-2 text-sm text-foreground", split ? "flex-1" : "shrink-0", centered ? "items-center self-center" : "items-start self-stretch pt-[3px]")}>{children}</div>
62
+ ) : null}
63
+ </>
64
+ ) : (
65
+ children
66
+ )}
67
+ </div>
68
+ );
69
+ }
70
+
71
+ function CardFooter({ className, children, ...rest }: CardFooterProps) {
72
+ return (
73
+ <div className={cn("flex justify-end gap-2 py-4 pr-4", className)} {...rest}>
74
+ {children}
75
+ </div>
76
+ );
77
+ }
78
+
79
+ /** Settings surface — title outside, rows inside, caption underneath. */
80
+ export const Card = Object.assign(CardRoot, { Item: CardItem, Footer: CardFooter });
81
+ export { CardFooter, CardItem };
@@ -88,7 +88,7 @@ export function AgentChatbox({
88
88
  };
89
89
 
90
90
  return (
91
- <div className={cn("nonla-agent-chatbox relative flex h-full min-h-0 flex-col overflow-hidden bg-chat", className)}>
91
+ <div className={cn("nonla-agent-chatbox relative flex h-full min-h-0 flex-col overflow-hidden bg-transparent", className)}>
92
92
  <OverlayScroll visibility={scrollbar} scrollRef={scrollRef} onScroll={onScroll} className="flex-1 min-h-0 min-w-0" innerClassName={messages.length === 0 ? "flex flex-col" : undefined}>
93
93
  <div data-chat-scroll-content className={`max-w-200 mx-auto min-w-0 w-full ${messages.length === 0 ? "flex flex-1 flex-col pb-16" : "pt-4 pb-20"}`}>
94
94
  {messages.length === 0 ? (
@@ -95,7 +95,7 @@ export function AgentPanel({
95
95
  };
96
96
 
97
97
  return (
98
- <div className={cn("nonla-agent-panel relative flex h-full min-h-0 flex-col overflow-hidden bg-chat", className)}>
98
+ <div className={cn("nonla-agent-panel relative flex h-full min-h-0 flex-col overflow-hidden bg-transparent", className)}>
99
99
  <OverlayScroll visibility={scrollbar} scrollRef={scrollRef} onScroll={onScroll} className="flex-1 min-h-0 min-w-0" innerClassName={messages.length === 0 ? "flex flex-col" : undefined}>
100
100
  <div data-chat-scroll-content className={`max-w-200 mx-auto min-w-0 w-full ${messages.length === 0 ? "flex flex-1 flex-col pb-24" : "pt-4 pb-28"}`}>
101
101
  {messages.length === 0 ? (
@@ -1,5 +1,5 @@
1
- import { CircleX } from "lucide-react";
2
1
  import type { ReactNode } from "react";
2
+ import { SolarIcon } from "../../icon/SolarIcon";
3
3
  import { cn } from "../../lib/cn";
4
4
 
5
5
  export type ChatErrorProps = {
@@ -14,7 +14,7 @@ export function ChatError({ children, className }: ChatErrorProps) {
14
14
  role="alert"
15
15
  className="flex items-center gap-2 rounded-lg border border-destructive/40 bg-[color-mix(in_oklab,var(--destructive)_14%,var(--nonla-surface))] px-3 py-2 text-(length:--chat-body-size) leading-(--chat-body-leading) text-destructive"
16
16
  >
17
- <CircleX className="size-4 shrink-0" aria-hidden />
17
+ <SolarIcon name="close-circle-linear" size={16} className="shrink-0" />
18
18
  <div className="min-w-0">{children}</div>
19
19
  </div>
20
20
  </div>
@@ -1,5 +1,5 @@
1
- import { ArrowUp, Eraser, Square } from "lucide-react";
2
1
  import { type KeyboardEvent as ReactKeyboardEvent, type ReactNode, useEffect, useLayoutEffect, useRef, useState } from "react";
2
+ import { SolarIcon } from "../../icon/SolarIcon";
3
3
  import { cn } from "../../lib/cn";
4
4
 
5
5
  export type ChatInputProps = {
@@ -137,14 +137,14 @@ export function ChatInput({ generating = false, placeholder = "Message…", disa
137
137
  className={cn(
138
138
  "w-full resize-none appearance-none border-0 bg-transparent shadow-none outline-none focus:outline-none px-2.5 pt-1 pb-2.5",
139
139
  "text-(length:--chat-composer-size) leading-(--chat-composer-leading) font-normal",
140
- disabled ? "text-muted-foreground cursor-not-allowed placeholder:text-quaternary-foreground" : "text-foreground placeholder:text-muted-foreground/60",
140
+ disabled ? "text-muted-foreground cursor-not-allowed placeholder:text-placeholder" : "text-foreground placeholder:text-placeholder",
141
141
  )}
142
142
  />
143
143
 
144
144
  <div className="flex items-center gap-1.5 pb-2 px-2">
145
145
  {onClear ? (
146
146
  <button type="button" onClick={onClear} title="Clear chat" aria-label="Clear chat" className="inline-flex size-6 shrink-0 items-center justify-center rounded-lg border-0 bg-transparent cursor-pointer hover:bg-ink-hover">
147
- <Eraser size={14} strokeWidth={1.5} aria-hidden />
147
+ <SolarIcon name="eraser-linear" size={14} />
148
148
  </button>
149
149
  ) : null}
150
150
  {toolbar}
@@ -152,7 +152,7 @@ export function ChatInput({ generating = false, placeholder = "Message…", disa
152
152
 
153
153
  {generating ? (
154
154
  <button type="button" onClick={onCancel} title="Stop" className="w-6 h-6 rounded-full bg-brand text-(--nonla-solid-fg) flex items-center justify-center shrink-0 cursor-pointer hover:bg-brand/90 active:scale-95 transition-all duration-100 border-0">
155
- <Square size={12} fill="currentColor" strokeWidth={0} aria-hidden />
155
+ <SolarIcon name="stop-bold" size={12} />
156
156
  <span className="sr-only">Stop</span>
157
157
  </button>
158
158
  ) : (
@@ -163,7 +163,7 @@ export function ChatInput({ generating = false, placeholder = "Message…", disa
163
163
  title="Send (Enter)"
164
164
  className={cn("w-6 h-6 rounded-full flex items-center justify-center shrink-0 transition-all duration-100 border-0", canSend ? "bg-foreground text-background cursor-pointer" : "bg-border text-muted-foreground cursor-not-allowed opacity-50")}
165
165
  >
166
- <ArrowUp size={14} strokeWidth={2.5} aria-hidden />
166
+ <SolarIcon name="arrow-up-linear" size={14} />
167
167
  <span className="sr-only">Send</span>
168
168
  </button>
169
169
  )}
@@ -16,11 +16,8 @@ export const chatMarkdownClass = cn(
16
16
  chatBodyClass,
17
17
  "min-w-0 wrap-anywhere",
18
18
  "[&_p]:m-0 [&_p]:mb-(--chat-p-mb) [&_p:last-child]:mb-0",
19
- "[&_h1]:mt-(--chat-h-mt) [&_h1]:mb-(--chat-h-mb) [&_h1]:text-(length:--chat-h1-size) [&_h1]:font-semibold [&_h1]:leading-snug",
20
- "[&_h2]:mt-(--chat-h-mt) [&_h2]:mb-(--chat-h-mb) [&_h2]:text-(length:--chat-h2-size) [&_h2]:font-semibold [&_h2]:leading-snug",
21
- "[&_h3]:mt-(--chat-h-mt) [&_h3]:mb-(--chat-h-mb) [&_h3]:text-(length:--chat-h3-size) [&_h3]:font-semibold [&_h3]:leading-snug",
22
- "[&_h4]:mt-(--chat-h-mt) [&_h4]:mb-(--chat-h-mb) [&_h4]:text-(length:--chat-h4-size) [&_h4]:font-semibold [&_h4]:leading-snug",
23
- "[&_h1:first-child]:mt-0 [&_h2:first-child]:mt-0 [&_h3:first-child]:mt-0 [&_h4:first-child]:mt-0",
19
+ "[&_:is(h1,h2,h3,h4,h5,h6)]:mt-(--chat-h-mt) [&_:is(h1,h2,h3,h4,h5,h6)]:mb-(--chat-h-mb) [&_:is(h1,h2,h3,h4,h5,h6)]:text-(length:--chat-body-size) [&_:is(h1,h2,h3,h4,h5,h6)]:font-semibold [&_:is(h1,h2,h3,h4,h5,h6)]:leading-(--chat-body-leading)",
20
+ "[&_:is(h1,h2,h3,h4,h5,h6):first-child]:mt-0",
24
21
  "[&_strong]:font-semibold [&_em]:italic",
25
22
  "[&_blockquote]:m-0 [&_blockquote]:mb-(--chat-p-mb) [&_blockquote]:border-0 [&_blockquote]:p-0 [&_blockquote]:not-italic [&_blockquote]:text-inherit [&_blockquote:last-child]:mb-0",
26
23
  "[&_ul]:mt-2 [&_ul]:mb-(--chat-p-mb)",
@@ -67,7 +64,7 @@ export function createChatMarkdownComponents(getState?: () => ChatMarkdownStream
67
64
  return <CodeBlock code={codeText} language={lang || undefined} className="my-3 last:mb-0" />;
68
65
  }
69
66
 
70
- return <span className="rounded-sm bg-gray-50/60 px-1">{children}</span>;
67
+ return <span className="rounded-sm bg-foreground/12 font-mono px-px">{children}</span>;
71
68
  },
72
69
  hr() {
73
70
  return null;
@@ -100,7 +97,11 @@ export function createChatMarkdownComponents(getState?: () => ChatMarkdownStream
100
97
  if (type !== "checkbox") return <input type={type} checked={checked} readOnly />;
101
98
  return (
102
99
  <span className="nonla-md-task-check pointer-events-none inline-flex h-(--chat-body-leading) items-center">
103
- <Checkbox checked={Boolean(checked)} tabIndex={-1} />
100
+ <Checkbox
101
+ checked={Boolean(checked)}
102
+ tabIndex={-1}
103
+ className="data-[state=checked]:border-white data-[state=checked]:bg-white data-[state=checked]:text-(--nonla-bg) data-[state=indeterminate]:border-white data-[state=indeterminate]:bg-white data-[state=indeterminate]:text-(--nonla-bg)"
104
+ />
104
105
  </span>
105
106
  );
106
107
  },
@@ -1,5 +1,5 @@
1
- import { ChevronRight } from "lucide-react";
2
1
  import { useEffect, useLayoutEffect, useRef, useState } from "react";
2
+ import { SolarIcon } from "../../icon/SolarIcon";
3
3
  import { cn } from "../../lib/cn";
4
4
  import { Shimmer } from "../../shimmer/Shimmer";
5
5
 
@@ -48,9 +48,9 @@ export function ChatThinking({ thinking, duration = 0, streaming = false, classN
48
48
  if (el) el.scrollTop = el.scrollHeight;
49
49
  }}
50
50
  >
51
- <summary className="cursor-pointer select-none text-base font-medium flex items-center gap-1 py-0.5 list-none [&::-webkit-details-marker]:hidden">
51
+ <summary className="cursor-pointer select-none text-base font-normal flex items-center gap-1 py-0.5 list-none [&::-webkit-details-marker]:hidden">
52
52
  <Shimmer active={streaming} className="text-tertiary-foreground">{label}</Shimmer>
53
- <ChevronRight className="size-3 shrink-0 opacity-0 text-tertiary-foreground transition-[opacity,transform] duration-150 group-hover/thinking:opacity-100 group-open/thinking:opacity-100 group-open/thinking:rotate-90" aria-hidden />
53
+ <SolarIcon name="alt-arrow-right-linear" size={12} className="shrink-0 opacity-0 text-tertiary-foreground transition-[opacity,transform] duration-150 group-hover/thinking:opacity-100 group-open/thinking:opacity-100 group-open/thinking:rotate-90" />
54
54
  </summary>
55
55
 
56
56
  <div ref={bodyRef} className="pt-2 max-h-40 min-w-0 overflow-y-auto overflow-x-hidden mb-2 text-[14px] leading-normal">
@@ -1,5 +1,5 @@
1
- import { ChevronDown } from "lucide-react";
2
1
  import { useEffect, useRef, useState } from "react";
2
+ import { SolarIcon } from "../../icon/SolarIcon";
3
3
  import { cn } from "../../lib/cn";
4
4
 
5
5
  const MAX_HEIGHT = 150;
@@ -30,7 +30,7 @@ export function ChatUserMessage({ content, className }: ChatUserMessageProps) {
30
30
  <div
31
31
  className={cn(
32
32
  "nonla-chat-user relative isolate mt-6 mb-3 mx-4 overflow-hidden rounded-xl px-3 py-1.5",
33
- "border border-solid border-brand-200 bg-brand-100",
33
+ "border border-solid border-(--nonla-input) bg-well-strong",
34
34
  className,
35
35
  )}
36
36
  >
@@ -55,7 +55,7 @@ export function ChatUserMessage({ content, className }: ChatUserMessageProps) {
55
55
  }}
56
56
  className="flex w-full cursor-pointer items-center justify-center border-0 bg-transparent pt-1 text-muted-foreground hover:text-foreground"
57
57
  >
58
- <ChevronDown size={12} className={cn("transition-transform duration-200", isExpanded && "rotate-180")} aria-hidden />
58
+ <SolarIcon name="alt-arrow-down-linear" size={12} className={cn("transition-transform duration-200", isExpanded && "rotate-180")} />
59
59
  </button>
60
60
  ) : null}
61
61
  </div>
@@ -1,10 +1,29 @@
1
- import { Download, Maximize2, Minimize2 } from "lucide-react";
2
- import { useCallback, useEffect, useId, useRef, useState } from "react";
1
+ import { useCallback, useEffect, useId, useRef, useState, useSyncExternalStore } from "react";
3
2
  import { Button } from "../../button/Button";
4
3
  import { CodeBlock } from "../../codeblock/CodeBlock";
4
+ import { SolarIcon } from "../../icon/SolarIcon";
5
5
  import { cn } from "../../lib/cn";
6
+ import { getColorMode, subscribeColorMode } from "../../theme";
6
7
  import { sanitizeMermaid } from "./sanitizeMermaid";
7
8
 
9
+ /** Official Mermaid palettes: `default` is light, `dark` is dark. */
10
+ function useMermaidTheme(): "default" | "dark" {
11
+ const mode = useSyncExternalStore(subscribeColorMode, getColorMode, () => "dark" as const);
12
+ return mode === "light" ? "default" : "dark";
13
+ }
14
+
15
+ /** Mermaid keeps one global theme. Render one diagram at a time so a cancelled pass cannot overwrite it. */
16
+ let mermaidQueue: Promise<unknown> = Promise.resolve();
17
+
18
+ function enqueueMermaid<T>(task: () => Promise<T>): Promise<T> {
19
+ const run = mermaidQueue.then(task, task);
20
+ mermaidQueue = run.then(
21
+ () => undefined,
22
+ () => undefined,
23
+ );
24
+ return run;
25
+ }
26
+
8
27
  export type MermaidBlockProps = {
9
28
  children: string;
10
29
  className?: string;
@@ -12,6 +31,7 @@ export type MermaidBlockProps = {
12
31
 
13
32
  export function MermaidBlock({ children, className }: MermaidBlockProps) {
14
33
  const id = useId().replace(/:/g, "_");
34
+ const theme = useMermaidTheme();
15
35
  const containerRef = useRef<HTMLDivElement>(null);
16
36
  const dialogRef = useRef<HTMLDialogElement>(null);
17
37
  const fullscreenRef = useRef<HTMLDivElement>(null);
@@ -27,46 +47,52 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
27
47
 
28
48
  const render = async () => {
29
49
  const { default: mermaid } = await import("mermaid");
30
- mermaid.initialize({
31
- startOnLoad: false,
32
- theme: "default",
33
- });
34
-
35
- const raw = children.trim();
36
- const renderId = `mermaid-${id}`;
37
-
38
- try {
39
- document.getElementById(`d${renderId}`)?.remove();
40
- const { svg } = await mermaid.render(renderId, raw);
41
- if (!cancelled) {
42
- setSvgContent(svg);
43
- setError(null);
50
+ if (cancelled) return;
51
+
52
+ await enqueueMermaid(async () => {
53
+ if (cancelled) return;
54
+ mermaid.initialize({
55
+ startOnLoad: false,
56
+ theme,
57
+ });
58
+
59
+ const raw = children.trim();
60
+ const renderId = `mermaid-${id}-${theme}`;
61
+
62
+ try {
63
+ document.getElementById(`d${renderId}`)?.remove();
64
+ const { svg } = await mermaid.render(renderId, raw);
65
+ if (!cancelled) {
66
+ setSvgContent(svg);
67
+ setError(null);
68
+ }
69
+ return;
70
+ } catch {
71
+ document.getElementById(`d${renderId}`)?.remove();
44
72
  }
45
- return;
46
- } catch {
47
- document.getElementById(`d${renderId}`)?.remove();
48
- }
49
-
50
- const sanitized = sanitizeMermaid(raw);
51
- try {
52
- const sanitizedId = `${renderId}-s`;
53
- document.getElementById(sanitizedId)?.remove();
54
- document.getElementById(`d${sanitizedId}`)?.remove();
55
- const { svg } = await mermaid.render(sanitizedId, sanitized);
56
- if (!cancelled) {
57
- setSvgContent(svg);
58
- setError(null);
73
+
74
+ if (cancelled) return;
75
+ const sanitized = sanitizeMermaid(raw);
76
+ try {
77
+ const sanitizedId = `${renderId}-s`;
78
+ document.getElementById(sanitizedId)?.remove();
79
+ document.getElementById(`d${sanitizedId}`)?.remove();
80
+ const { svg } = await mermaid.render(sanitizedId, sanitized);
81
+ if (!cancelled) {
82
+ setSvgContent(svg);
83
+ setError(null);
84
+ }
85
+ } catch (err) {
86
+ if (!cancelled) setError(String(err));
59
87
  }
60
- } catch (err) {
61
- if (!cancelled) setError(String(err));
62
- }
88
+ });
63
89
  };
64
90
 
65
91
  void render();
66
92
  return () => {
67
93
  cancelled = true;
68
94
  };
69
- }, [children, id]);
95
+ }, [children, id, theme]);
70
96
 
71
97
  useEffect(() => {
72
98
  if (containerRef.current && svgContent) containerRef.current.innerHTML = svgContent;
@@ -104,7 +130,6 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
104
130
 
105
131
  const closeFullscreen = () => {
106
132
  dialogRef.current?.close();
107
- resetView();
108
133
  };
109
134
 
110
135
  const handleWheel = useCallback((e: React.WheelEvent) => {
@@ -166,7 +191,7 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
166
191
  <>
167
192
  <div className={cn("my-3 last:mb-0 group relative rounded-xl border border-border overflow-hidden bg-card", className)}>
168
193
  <div className="absolute top-2 right-2 z-10 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
169
- <Button size="small" icon={<Maximize2 aria-hidden />} title="Fullscreen" aria-label="Fullscreen" onClick={openFullscreen} />
194
+ <Button size="small" icon={<SolarIcon name="maximize-linear" size={12} />} title="Fullscreen" aria-label="Fullscreen" onClick={openFullscreen} />
170
195
  </div>
171
196
  <div ref={containerRef} className="flex justify-center p-6 overflow-x-auto [&_svg]:max-w-full" />
172
197
  </div>
@@ -174,13 +199,17 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
174
199
  <dialog
175
200
  ref={dialogRef}
176
201
  className="m-0 p-0 w-screen h-screen max-w-none max-h-none backdrop:bg-black/40 open:flex open:flex-col bg-card"
202
+ onClose={resetView}
177
203
  onKeyDown={(e) => {
178
- if (e.key === "Escape") closeFullscreen();
204
+ if (e.key !== "Escape") return;
205
+ e.preventDefault();
206
+ e.stopPropagation();
207
+ closeFullscreen();
179
208
  }}
180
209
  >
181
210
  <div className="fixed top-5 right-5 z-50 flex items-center gap-1.5">
182
- <Button size="small" icon={<Download aria-hidden />} title="Download SVG" aria-label="Download SVG" onClick={downloadSvg} disabled={!svgContent} />
183
- <Button size="small" icon={<Minimize2 aria-hidden />} title="Exit fullscreen" onClick={closeFullscreen}>
211
+ <Button size="small" icon={<SolarIcon name="download-linear" size={12} />} title="Download SVG" aria-label="Download SVG" onClick={downloadSvg} disabled={!svgContent} />
212
+ <Button size="small" icon={<SolarIcon name="minimize-linear" size={12} />} title="Exit fullscreen" onClick={closeFullscreen}>
184
213
  Exit
185
214
  </Button>
186
215
  </div>
@@ -1,5 +1,5 @@
1
- import { ChevronDown, Square } from "lucide-react";
2
1
  import { type ReactNode, useEffect, useLayoutEffect, useRef, useState } from "react";
2
+ import { SolarIcon } from "../../icon/SolarIcon";
3
3
  import { cn } from "../../lib/cn";
4
4
  import { Modal } from "../../modal/Modal";
5
5
  import { Popconfirm } from "../../popconfirm/Popconfirm";
@@ -56,7 +56,7 @@ function TaskRow({
56
56
  </button>
57
57
  <Popconfirm title={`Stop ${formatToolName(task.toolName)}?`} okText="Stop" okType="danger" onConfirm={onCancel} getPopupContainer={() => document.body}>
58
58
  <button type="button" disabled={cancelling} title="Stop" aria-label={`Stop ${formatToolName(task.toolName)}`} className="inline-flex size-5 shrink-0 items-center justify-center rounded cursor-pointer text-destructive transition-colors hover:bg-destructive/10 disabled:opacity-40">
59
- <Square size={10} fill="currentColor" strokeWidth={0} aria-hidden />
59
+ <SolarIcon name="stop-bold" size={10} />
60
60
  </button>
61
61
  </Popconfirm>
62
62
  </div>
@@ -120,7 +120,7 @@ export function BackgroundTasksBar({ children, tasks = [], cancellingIds, onCanc
120
120
  <div className="absolute inset-x-6 bottom-[calc(100%)] z-20 overflow-hidden rounded-t-lg border-x border-t border-border">
121
121
  <div className={cn("flex h-7.5 items-center gap-1 px-1", open && "border-b border-border-subtle")}>
122
122
  <button type="button" onClick={() => setOpen((v) => !v)} className="flex min-w-0 flex-1 cursor-pointer font-medium items-center gap-1 rounded-md px-1.5 py-1 text-[13px] text-muted-foreground/90 transition-colors hover:text-foreground" aria-expanded={open} aria-label={label}>
123
- <ChevronDown size={13} className={cn("shrink-0 transition-transform duration-150", !open && "-rotate-90")} aria-hidden />
123
+ <SolarIcon name="alt-arrow-down-linear" size={13} className={cn("shrink-0 transition-transform duration-150", !open && "-rotate-90")} />
124
124
  <span className="truncate">{label}</span>
125
125
  </button>
126
126
  </div>
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode, useEffect, useRef, useState } from "react";
2
- import { FluentIcon } from "../../icon/FluentIcon";
2
+ import { SolarIcon } from "../../icon/SolarIcon";
3
3
  import { cn } from "../../lib/cn";
4
4
  import { Shimmer } from "../../shimmer/Shimmer";
5
5
  import { Spin } from "../../spin/Spin";
@@ -126,7 +126,7 @@ export function CallAgentToolUI({ msg, assistantLabel = "Assistant", assistantCo
126
126
  {calling ? (
127
127
  <Spin variant="agent" size="small" className="shrink-0" />
128
128
  ) : (
129
- <FluentIcon name="chat-multiple-24" size={13} className="shrink-0 text-muted-foreground" />
129
+ <SolarIcon name="dialog-2-linear" size={13} className="shrink-0 text-muted-foreground" />
130
130
  )}
131
131
  <Shimmer active={calling} className="min-w-0 flex-1 truncate text-[14px] font-medium text-foreground">Calling {calleeName}</Shimmer>
132
132
  {bgRunning ? <span className="text-[14px] tabular-nums text-muted-foreground">{formatBgElapsed(timestampMs(msg.timestamp), now)}</span> : null}
@@ -138,7 +138,7 @@ export function CallAgentToolUI({ msg, assistantLabel = "Assistant", assistantCo
138
138
  <div className="flex flex-col gap-3 px-3 py-3">
139
139
  {composing || hasRequest ? (
140
140
  <AgentTurn name={assistantLabel} align="end">
141
- <div className="rounded-2xl rounded-tr-sm border border-brand/40 bg-[color-mix(in_oklab,var(--brand)_14%,var(--card))] px-3 py-2 text-left">
141
+ <div className="rounded-2xl rounded-tr-sm border border-solid border-(--nonla-input) bg-well-strong px-3 py-2 text-left">
142
142
  {composing ? <TypingDots /> : <p className="m-0 text-[14px] leading-[1.55] whitespace-pre-wrap text-foreground">{requestMessage}</p>}
143
143
  </div>
144
144
  </AgentTurn>