devnonla-ui 0.7.1 → 0.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devnonla-ui",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "description": "NonlaUI — React controls for Nonla Agents",
6
6
  "author": "devlangla <devlangla0x01@gmail.com>",
@@ -124,7 +124,7 @@ export function ChatInput({ generating = false, placeholder = "Message…", disa
124
124
  };
125
125
 
126
126
  return (
127
- <div className={cn("nonla-glass relative isolate shrink-0 mx-4 mb-2.5 overflow-hidden pt-1 rounded-xl flex flex-col", disabled && "opacity-70", className)}>
127
+ <div className={cn("nonla-glass nonla-chat-input relative isolate shrink-0 mx-4 mb-2.5 overflow-hidden pt-1 rounded-xl flex flex-col", disabled && "opacity-70", className)}>
128
128
  <textarea
129
129
  ref={textareaRef}
130
130
  data-chat-input
@@ -35,7 +35,7 @@ export function ChatMarkdownTable({ children }: { children: ReactNode }) {
35
35
  <div className="overflow-x-auto">
36
36
  <table
37
37
  ref={tableRef}
38
- className="w-max min-w-full wrap-normal border-separate border-spacing-0 text-[14px] [&_th]:bg-foreground/4 [&_th]:text-foreground [&_th]:font-semibold [&_th]:px-2.5 [&_th]:py-1.5 [&_th]:text-left [&_th]:align-top [&_th]:border-r [&_th]:border-b [&_th]:border-border [&_th:last-child]:border-r-0 [&_td]:px-2.5 [&_td]:py-1.5 [&_td]:align-top [&_td]:text-foreground [&_td]:bg-card [&_td]:border-r [&_td]:border-b [&_td]:border-border [&_td:last-child]:border-r-0 [&_tbody_tr:last-child_td]:border-b-0"
38
+ className="w-max min-w-full wrap-normal border-separate border-spacing-0 text-[14px] [&_th]:bg-(--nonla-table-head) [&_th]:text-foreground [&_th]:font-semibold [&_th]:px-2.5 [&_th]:py-1.5 [&_th]:text-left [&_th]:align-top [&_th]:border-r [&_th]:border-b [&_th]:border-border [&_th:last-child]:border-r-0 [&_td]:px-2.5 [&_td]:py-1.5 [&_td]:align-top [&_td]:text-foreground [&_td]:bg-card [&_td]:border-r [&_td]:border-b [&_td]:border-border [&_td:last-child]:border-r-0 [&_tbody_tr:last-child_td]:border-b-0"
39
39
  >
40
40
  {children}
41
41
  </table>
@@ -48,7 +48,7 @@ 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-sm 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-medium 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
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 />
54
54
  </summary>
@@ -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-border bg-[color-mix(in_oklab,var(--nonla-ink)_7%,transparent)] backdrop-blur-xl",
33
+ "border border-solid border-brand-200 bg-brand-100",
34
34
  className,
35
35
  )}
36
36
  >
@@ -1,5 +1,6 @@
1
- import { Download, Maximize2, Minimize2, Moon, Sun } from "lucide-react";
1
+ import { Download, Maximize2, Minimize2 } from "lucide-react";
2
2
  import { useCallback, useEffect, useId, useRef, useState } from "react";
3
+ import { Button } from "../../button/Button";
3
4
  import { CodeBlock } from "../../codeblock/CodeBlock";
4
5
  import { cn } from "../../lib/cn";
5
6
  import { sanitizeMermaid } from "./sanitizeMermaid";
@@ -9,10 +10,6 @@ export type MermaidBlockProps = {
9
10
  className?: string;
10
11
  };
11
12
 
12
- type MermaidTheme = "light" | "dark";
13
-
14
- const btnClass = "flex items-center gap-1 px-2 py-1 rounded-lg border border-border text-muted-foreground text-xs cursor-pointer transition-colors hover:text-primary hover:border-primary/30 bg-transparent";
15
-
16
13
  export function MermaidBlock({ children, className }: MermaidBlockProps) {
17
14
  const id = useId().replace(/:/g, "_");
18
15
  const containerRef = useRef<HTMLDivElement>(null);
@@ -20,15 +17,11 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
20
17
  const fullscreenRef = useRef<HTMLDivElement>(null);
21
18
  const [error, setError] = useState<string | null>(null);
22
19
  const [svgContent, setSvgContent] = useState("");
23
- const [theme, setTheme] = useState<MermaidTheme>("light");
24
20
  const [zoom, setZoom] = useState(1);
25
21
  const [pan, setPan] = useState({ x: 0, y: 0 });
26
22
  const dragRef = useRef({ active: false, startX: 0, startY: 0, panX: 0, panY: 0 });
27
23
  const [isDragging, setIsDragging] = useState(false);
28
24
 
29
- const isDark = theme === "dark";
30
- const surfaceClass = isDark ? "bg-[#1e1e1e]" : "bg-card";
31
-
32
25
  useEffect(() => {
33
26
  let cancelled = false;
34
27
 
@@ -36,11 +29,11 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
36
29
  const { default: mermaid } = await import("mermaid");
37
30
  mermaid.initialize({
38
31
  startOnLoad: false,
39
- theme: isDark ? "dark" : "default",
32
+ theme: "default",
40
33
  });
41
34
 
42
35
  const raw = children.trim();
43
- const renderId = `mermaid-${id}-${theme}`;
36
+ const renderId = `mermaid-${id}`;
44
37
 
45
38
  try {
46
39
  document.getElementById(`d${renderId}`)?.remove();
@@ -73,7 +66,7 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
73
66
  return () => {
74
67
  cancelled = true;
75
68
  };
76
- }, [children, id, theme, isDark]);
69
+ }, [children, id]);
77
70
 
78
71
  useEffect(() => {
79
72
  if (containerRef.current && svgContent) containerRef.current.innerHTML = svgContent;
@@ -90,8 +83,6 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
90
83
  setPan({ x: 0, y: 0 });
91
84
  }, []);
92
85
 
93
- const toggleTheme = () => setTheme((prev) => (prev === "light" ? "dark" : "light"));
94
-
95
86
  const downloadSvg = () => {
96
87
  if (!svgContent) return;
97
88
  const blob = new Blob([svgContent], { type: "image/svg+xml;charset=utf-8" });
@@ -173,47 +164,33 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
173
164
 
174
165
  return (
175
166
  <>
176
- <div className={cn("my-3 last:mb-0 group relative rounded-xl border border-border overflow-hidden", surfaceClass, className)}>
167
+ <div className={cn("my-3 last:mb-0 group relative rounded-xl border border-border overflow-hidden bg-card", className)}>
177
168
  <div className="absolute top-2 right-2 z-10 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
178
- <button type="button" onClick={toggleTheme} className={cn(btnClass, surfaceClass)} title={isDark ? "Light theme" : "Dark theme"}>
179
- {isDark ? <Sun size={14} aria-hidden /> : <Moon size={14} aria-hidden />}
180
- </button>
181
- <button type="button" onClick={downloadSvg} className={cn(btnClass, surfaceClass)} title="Download SVG" disabled={!svgContent}>
182
- <Download size={14} aria-hidden />
183
- </button>
184
- <button type="button" onClick={openFullscreen} className={cn(btnClass, surfaceClass)} title="Fullscreen">
185
- <Maximize2 size={14} aria-hidden />
186
- </button>
169
+ <Button size="small" icon={<Maximize2 aria-hidden />} title="Fullscreen" aria-label="Fullscreen" onClick={openFullscreen} />
187
170
  </div>
188
171
  <div ref={containerRef} className="flex justify-center p-6 overflow-x-auto [&_svg]:max-w-full" />
189
172
  </div>
190
173
 
191
174
  <dialog
192
175
  ref={dialogRef}
193
- className={cn("m-0 p-0 w-screen h-screen max-w-none max-h-none backdrop:bg-black/40 open:flex open:flex-col", surfaceClass)}
176
+ 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"
194
177
  onKeyDown={(e) => {
195
178
  if (e.key === "Escape") closeFullscreen();
196
179
  }}
197
180
  >
198
181
  <div className="fixed top-5 right-5 z-50 flex items-center gap-1.5">
199
- <button type="button" onClick={toggleTheme} className={cn(btnClass, surfaceClass, "px-3 py-2 text-sm shadow-md")} title={isDark ? "Light theme" : "Dark theme"}>
200
- {isDark ? <Sun size={16} aria-hidden /> : <Moon size={16} aria-hidden />}
201
- </button>
202
- <button type="button" onClick={downloadSvg} className={cn(btnClass, surfaceClass, "px-3 py-2 text-sm shadow-md")} title="Download SVG" disabled={!svgContent}>
203
- <Download size={16} aria-hidden />
204
- </button>
205
- <button type="button" onClick={closeFullscreen} className={cn(btnClass, surfaceClass, "px-3 py-2 text-sm shadow-md")} title="Exit fullscreen">
206
- <Minimize2 size={16} aria-hidden />
207
- <span>Exit</span>
208
- </button>
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}>
184
+ Exit
185
+ </Button>
209
186
  </div>
210
187
 
211
- <div className={cn("fixed bottom-5 left-1/2 -translate-x-1/2 z-50 flex items-center gap-2 px-3 py-1.5 rounded-full border border-border text-xs text-muted-foreground shadow-md select-none", surfaceClass)}>
188
+ <div className="fixed bottom-5 left-1/2 -translate-x-1/2 z-50 flex items-center gap-2 px-3 py-1.5 rounded-full border border-border text-xs text-muted-foreground shadow-md select-none bg-card">
212
189
  <span>{Math.round(zoom * 100)}%</span>
213
190
  {!isDefaultView ? (
214
- <button type="button" onClick={resetView} className="text-muted-foreground hover:text-primary cursor-pointer transition-colors border-0 bg-transparent p-0 font-[inherit]">
191
+ <Button type="text" size="small" onClick={resetView}>
215
192
  Reset
216
- </button>
193
+ </Button>
217
194
  ) : null}
218
195
  </div>
219
196
 
@@ -1,4 +1,3 @@
1
- import { FileText } from "lucide-react";
2
1
  import { type ComponentProps, createContext, type ReactNode, useContext, useMemo } from "react";
3
2
  import { ButtonCopy } from "../button/ButtonCopy";
4
3
  import { cn } from "../lib/cn";
@@ -46,21 +45,16 @@ export function CodeBlock({ code, language, title, lineNumbers = false, wordWrap
46
45
  return (
47
46
  <CodeBlockContext.Provider value={{ code }}>
48
47
  <div className={cn("nonla-codeblock relative flex min-w-0 w-full flex-col overflow-clip rounded-lg border border-border bg-glass-bar text-sm text-foreground backdrop-blur-lg", className)} data-language={language} {...props}>
49
- <div className="flex h-9 items-center justify-between gap-2 pl-2 pr-1 text-sm text-muted-foreground">
48
+ <div className="flex h-8 items-center justify-between gap-2 pl-3 pr-1 text-xs text-muted-foreground">
50
49
  <div className="flex min-w-0 items-center gap-2">
51
- {label ? (
52
- <>
53
- <FileText size={14} className="shrink-0" aria-hidden />
54
- <span className="truncate font-medium">{label}</span>
55
- </>
56
- ) : null}
50
+ {label ? <span className="truncate font-medium">{label}</span> : null}
57
51
  </div>
58
52
  <CodeBlockCopyButton />
59
53
  </div>
60
54
 
61
55
  <OverlayScroll
62
56
  autoHeight
63
- className={cn("nonla-codeblock-body nonla-codeblock-well min-w-0 bg-card font-mono text-[13px] leading-5 max-h-96", !children && "mx-0.5 mb-0.5 rounded-lg")}
57
+ className={cn("nonla-codeblock-body nonla-codeblock-well min-w-0 bg-card font-mono text-[13px] leading-5 max-h-96", !children && "mx-0.5 mb-0.5 w-[calc(100%-4px)] rounded-lg")}
64
58
  innerClassName={wordWrap ? undefined : "overflow-x-auto"}
65
59
  >
66
60
  <pre className={cn("nonla-codeblock-pre m-0 whitespace-pre break-normal", lineNumbers && "nonla-codeblock-lines", wordWrap && "whitespace-pre-wrap wrap-break-word")}>
@@ -162,10 +162,10 @@ export function OverlayScroll({ visibility = "hover", autoHeight = false, classN
162
162
  {children}
163
163
  </div>
164
164
  {vThumb.shown ? (
165
- <div aria-hidden onPointerDown={onThumbPointerDown("y")} className={thumbClass} style={{ top: insetTop, right: 2, width: "var(--nonla-scrollbar-size)", height: vThumb.size, transform: `translateY(${vThumb.offset}px)` }} />
165
+ <div aria-hidden onPointerDown={onThumbPointerDown("y")} className={thumbClass} style={{ top: insetTop, right: 1, width: "var(--nonla-scrollbar-size)", height: vThumb.size, transform: `translateY(${vThumb.offset}px)` }} />
166
166
  ) : null}
167
167
  {hThumb.shown ? (
168
- <div aria-hidden onPointerDown={onThumbPointerDown("x")} className={thumbClass} style={{ left: 0, bottom: 2, height: "var(--nonla-scrollbar-size)", width: hThumb.size, transform: `translateX(${hThumb.offset}px)` }} />
168
+ <div aria-hidden onPointerDown={onThumbPointerDown("x")} className={thumbClass} style={{ left: 0, bottom: 1, height: "var(--nonla-scrollbar-size)", width: hThumb.size, transform: `translateX(${hThumb.offset}px)` }} />
169
169
  ) : null}
170
170
  </div>
171
171
  );
package/src/styles.css CHANGED
@@ -18,18 +18,19 @@
18
18
  color-scheme: light;
19
19
 
20
20
  /* ── Knobs / Seed (override these) ──────────────────────────────────── */
21
- --nonla-bg: #fffcf1;
22
- --nonla-fg: #1f1f1e;
23
- /* Text rank on cream — same ink, contrast steps ~13.6 / 7 / 4.5 / 3 (WCAG AAA body → AA body → AA UI). */
24
- --nonla-fg-muted: color-mix(in oklab, var(--nonla-fg) 78%, var(--nonla-bg));
25
- --nonla-fg-tertiary: color-mix(in oklab, var(--nonla-fg) 64%, var(--nonla-bg));
26
- --nonla-fg-quaternary: color-mix(in oklab, var(--nonla-fg) 50%, var(--nonla-bg));
21
+ /* Neutrals measured from Discord light (Vietnix DEV #website). */
22
+ --nonla-bg: #f3f3f4;
23
+ --nonla-fg: #2e2e34;
24
+ /* Text rank: default / subtle / muted / placeholder. */
25
+ --nonla-fg-muted: #595a63;
26
+ --nonla-fg-tertiary: #6c6d76;
27
+ --nonla-fg-quaternary: #84858d;
27
28
  --nonla-brand: #f18d00;
28
29
  /* Label on brand fills (Button primary, Tag solid, Checkbox). Override via `colors.solidFg`. */
29
30
  --nonla-solid-fg: #ffffff;
30
- --nonla-danger: #c0392b;
31
+ --nonla-danger: #ef4444;
31
32
  --nonla-success: #1f9d55;
32
- --nonla-warn: #c47d12;
33
+ --nonla-warn: #f59e0b;
33
34
  --nonla-link: var(--nonla-brand);
34
35
  --nonla-radius: 8px;
35
36
  --nonla-height: 32px;
@@ -39,12 +40,14 @@
39
40
  --nonla-ink: var(--nonla-fg);
40
41
  --nonla-surface: #ffffff;
41
42
  --nonla-elevated: var(--nonla-surface);
42
- --nonla-chip: color-mix(in oklab, var(--nonla-fg) 5%, var(--nonla-bg));
43
- --nonla-chip-hover: color-mix(in oklab, var(--nonla-fg) 9%, var(--nonla-bg));
44
- --nonla-border: color-mix(in oklab, var(--nonla-fg) 7%, var(--nonla-bg));
45
- --nonla-input: color-mix(in oklab, var(--nonla-fg) 12%, var(--nonla-bg));
43
+ --nonla-chip: #e6e6e8;
44
+ --nonla-chip-hover: #ebeced;
45
+ --nonla-border: #e2e2e4;
46
+ --nonla-input: #d5d5d9;
46
47
  --nonla-composer: var(--nonla-surface);
47
- --nonla-chat-bg: #fcfcfc;
48
+ --nonla-chat-bg: #fbfbfb;
49
+ /* Opaque header fill. Alpha `fg/4` picks up whatever sits behind the glass. */
50
+ --nonla-table-head: color-mix(in srgb, var(--nonla-fg) 4%, var(--nonla-bg));
48
51
 
49
52
  /* Neutral frost — blur shows whatever sits behind, no page-tint */
50
53
  --nonla-meadow: #4f7a32;
@@ -53,9 +56,10 @@
53
56
  --nonla-glass-menu: color-mix(in srgb, white 48%, transparent);
54
57
  --nonla-glass-border: color-mix(in srgb, white 62%, transparent);
55
58
  --nonla-glass-highlight: color-mix(in srgb, white 70%, transparent);
56
- --nonla-ink-hover: color-mix(in srgb, var(--nonla-ink) 6%, transparent);
57
- --nonla-ink-active: color-mix(in srgb, var(--nonla-ink) 8%, transparent);
58
- --nonla-ink-line: color-mix(in srgb, var(--nonla-ink) 14%, transparent);
59
+ /* Discord interactive wash: hsl(240 4% 60.784%) at hover / active alpha. */
60
+ --nonla-ink-hover: hsl(240 4% 60.784% / 0.122);
61
+ --nonla-ink-active: hsl(240 4% 60.784% / 0.161);
62
+ --nonla-ink-line: #e2e2e4;
59
63
  --nonla-desktop-bar-height: 42px;
60
64
  --nonla-z-base: 0;
61
65
  --nonla-z-desktop: 20;
@@ -150,8 +154,8 @@
150
154
  --nonla-dur-slow: 300ms;
151
155
 
152
156
  /* Chat type — one scale for full-page chat and side panels */
153
- --chat-body-size: 15px;
154
- --chat-body-leading: 24px;
157
+ --chat-body-size: 14px;
158
+ --chat-body-leading: 20px;
155
159
  --chat-h1-size: 16px;
156
160
  --chat-h2-size: 16px;
157
161
  --chat-h3-size: 14px;
@@ -626,8 +630,15 @@
626
630
  backdrop-filter: blur(24px) saturate(160%);
627
631
  }
628
632
 
633
+ /* Composer sits on light glass; the white hairline disappears. Use the input stroke. */
634
+ .nonla-chat-input {
635
+ border-color: var(--nonla-input);
636
+ }
637
+
629
638
  /* Desktop window — cream wash + less saturate so meadow doesn't tint the panel. */
630
639
  .nonla-window-glass {
640
+ border: 0;
641
+ box-shadow: inset 0 0 0 1px var(--glass-border), 0 10px 28px color-mix(in srgb, black 12%, transparent);
631
642
  background: color-mix(in srgb, var(--nonla-bg) 81%, transparent);
632
643
  -webkit-backdrop-filter: blur(40px) saturate(108%);
633
644
  backdrop-filter: blur(40px) saturate(108%);
@@ -378,8 +378,8 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
378
378
  const next = head ? Math.ceil(head.getBoundingClientRect().height) + 4 : 0;
379
379
  setThumbInset((prev) => (prev === next ? prev : next));
380
380
  }, [headSticky, showHeader, size, flexLayout]);
381
- /** Opaque fill. `bg-foreground/4` is 4% alpha, so body text shows through a sticky header. */
382
- const headBg: CSSProperties | undefined = headSticky ? { backgroundColor: "var(--nonla-bg)" } : undefined;
381
+ /** Opaque fill so a sticky header does not show body text, and every header matches. */
382
+ const headBg: CSSProperties = { backgroundColor: "var(--nonla-table-head)" };
383
383
 
384
384
  const colStyle = (col: ColumnType<T>, key: string): CSSProperties => {
385
385
  const measured = flexLayout?.cols[key];
@@ -408,7 +408,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
408
408
  <thead data-slot="table-header" className={cn("[&_tr]:border-b [&_tr]:border-border", headSticky && "relative z-20")}>
409
409
  <tr data-slot="table-row" className="border-b border-border transition-colors hover:bg-transparent">
410
410
  {rowSelection ? (
411
- <th data-slot="table-head" className={cn(sz.head, sz.check, "align-middle font-medium text-foreground", headSticky ? "sticky top-0 z-10 border-b border-border" : "bg-foreground/4", bordered && "border-b border-border")} style={{ ...(selectionColWidth != null ? { width: selectionColWidth } : undefined), ...headBg }}>
411
+ <th data-slot="table-head" className={cn(sz.head, sz.check, "align-middle font-medium text-foreground", headSticky && "sticky top-0 z-10 border-b border-border", bordered && "border-b border-border")} style={{ ...(selectionColWidth != null ? { width: selectionColWidth } : undefined), ...headBg }}>
412
412
  <div className="flex items-center justify-center">
413
413
  {rowSelection.type === "radio" ? null : (
414
414
  <Checkbox
@@ -433,7 +433,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
433
433
  <th
434
434
  key={key}
435
435
  data-slot="table-head"
436
- className={cn(sz.head, "align-middle font-medium text-foreground", headSticky ? "sticky top-0 z-10 border-b border-border" : "bg-foreground/4", flexLayout && flexWeight(col) > 0 ? "min-w-0" : "whitespace-nowrap", alignClass(col.align), bordered && "border-b border-border", sortable && "cursor-pointer select-none", col.className, headerExtra?.className)}
436
+ className={cn(sz.head, "align-middle font-medium text-foreground", headSticky && "sticky top-0 z-10 border-b border-border", flexLayout && flexWeight(col) > 0 ? "min-w-0" : "whitespace-nowrap", alignClass(col.align), bordered && "border-b border-border", sortable && "cursor-pointer select-none", col.className, headerExtra?.className)}
437
437
  style={{
438
438
  ...colStyle(col, key),
439
439
  ...headBg,