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/README.md +6 -245
- package/package.json +2 -2
- package/src/app/App.tsx +4 -20
- package/src/app/context.ts +3 -7
- package/src/avatar/AgentAvatar.tsx +17 -6
- package/src/card/Card.tsx +1 -4
- package/src/chat/AgentChatbox.tsx +1 -1
- package/src/chat/AgentPanel.tsx +1 -1
- package/src/chat/chatMessageList.tsx +1 -4
- package/src/chat/message-ui/ChatAgentMessage.tsx +6 -4
- package/src/chat/message-ui/ChatMarkdown.tsx +2 -2
- package/src/chat/tool-ui/CallAgentToolUI.tsx +1 -1
- package/src/codeblock/CodeBlock.tsx +1 -1
- package/src/index.ts +6 -4
- package/src/markdown-editor/MarkdownPreview.tsx +3 -3
- package/src/markdown-editor/MarkdownTable.tsx +2 -2
- package/src/markdown-editor/MarkdownViewer.tsx +53 -55
- package/src/markdown-editor/MermaidBlock.tsx +1 -1
- package/src/markdown-editor/ReactCode.tsx +6 -7
- package/src/markdown-editor/ReactCodeFrame.tsx +41 -15
- package/src/markdown-editor/ReactCodeSandbox.tsx +1 -1
- package/src/markdown-editor/markdownScale.ts +144 -0
- package/src/sidebar/Sidebar.tsx +2 -2
- package/src/styles.css +86 -52
- package/src/tabs/Tabs.tsx +261 -0
- package/src/tag/Tag.tsx +13 -13
- package/src/theme.ts +1 -86
- package/src/typography/Typography.tsx +41 -35
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type AnchorHTMLAttributes, createElement, type HTMLAttributes, type ReactNode } from "react";
|
|
1
|
+
import { type AnchorHTMLAttributes, type CSSProperties, createElement, type HTMLAttributes, type ReactNode } from "react";
|
|
2
2
|
import { cn } from "../lib/cn";
|
|
3
|
+
import { headingClass, markdownBodyClass, markdownParagraphClass, markdownVariantStyle, pageTitleClass } from "../markdown-editor/markdownScale";
|
|
3
4
|
|
|
4
5
|
export type TypographyType = "secondary" | "success" | "warning" | "danger";
|
|
5
6
|
|
|
6
|
-
export type TitleLevel = 1 | 2 | 3 | 4 | 5;
|
|
7
|
+
export type TitleLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
7
8
|
|
|
8
9
|
type Decorations = {
|
|
9
10
|
type?: TypographyType;
|
|
@@ -17,12 +18,18 @@ type Decorations = {
|
|
|
17
18
|
italic?: boolean;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
/** Same ink as MarkdownViewer. Status tones sit on top of that. */
|
|
22
|
+
const INK = {
|
|
23
|
+
title: "var(--md-heading)",
|
|
24
|
+
body: "var(--md-ink)",
|
|
25
|
+
secondary: "var(--nonla-fg-tertiary)",
|
|
26
|
+
quiet: "var(--nonla-fg-quaternary)",
|
|
27
|
+
success: "var(--nonla-success)",
|
|
28
|
+
warning: "var(--nonla-warn)",
|
|
29
|
+
danger: "var(--nonla-danger)",
|
|
30
|
+
} as const;
|
|
31
|
+
|
|
32
|
+
type InkRole = "title" | "body";
|
|
26
33
|
|
|
27
34
|
const TITLE_TAG = {
|
|
28
35
|
1: "h1",
|
|
@@ -30,20 +37,15 @@ const TITLE_TAG = {
|
|
|
30
37
|
3: "h3",
|
|
31
38
|
4: "h4",
|
|
32
39
|
5: "h5",
|
|
40
|
+
6: "h6",
|
|
33
41
|
} as const;
|
|
34
42
|
|
|
35
|
-
/**
|
|
36
|
-
const BODY =
|
|
43
|
+
/** Same scale as MarkdownViewer `docs`. Body 16/24. Inline code reads `--md-inline-size` (14px). */
|
|
44
|
+
const BODY = markdownBodyClass;
|
|
37
45
|
|
|
38
|
-
const
|
|
39
|
-
1: "text-[38px] leading-[46px] font-bold",
|
|
40
|
-
2: "text-[30px] leading-[38px] font-bold",
|
|
41
|
-
3: "text-[24px] leading-[32px] font-semibold",
|
|
42
|
-
4: "text-[20px] leading-[28px] font-semibold",
|
|
43
|
-
5: "text-[16px] leading-[24px] font-semibold",
|
|
44
|
-
};
|
|
46
|
+
const INLINE_CODE = "nonla-inline-code";
|
|
45
47
|
|
|
46
|
-
const TITLE_SPACE = "nonla-typo
|
|
48
|
+
const TITLE_SPACE = "nonla-typo";
|
|
47
49
|
|
|
48
50
|
function decorationLine(underline?: boolean, deleted?: boolean) {
|
|
49
51
|
if (underline && deleted) return "underline line-through";
|
|
@@ -55,10 +57,10 @@ function decorationLine(underline?: boolean, deleted?: boolean) {
|
|
|
55
57
|
function wrapDecorations(children: ReactNode, props: Decorations) {
|
|
56
58
|
let node = children;
|
|
57
59
|
if (props.mark) {
|
|
58
|
-
node = <mark className="rounded-sm bg-[color-mix(in_oklab,var(--nonla-
|
|
60
|
+
node = <mark className="rounded-sm bg-[color-mix(in_oklab,var(--nonla-warn)_40%,transparent)] px-0.5 text-inherit">{node}</mark>;
|
|
59
61
|
}
|
|
60
62
|
if (props.code) {
|
|
61
|
-
node = <code className=
|
|
63
|
+
node = <code className={INLINE_CODE}>{node}</code>;
|
|
62
64
|
}
|
|
63
65
|
if (props.keyboard) {
|
|
64
66
|
node = <kbd className="inline-block rounded-md border border-b-2 border-border bg-muted px-1.5 font-mono text-[0.85em] leading-5">{node}</kbd>;
|
|
@@ -66,16 +68,24 @@ function wrapDecorations(children: ReactNode, props: Decorations) {
|
|
|
66
68
|
return node;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
function
|
|
70
|
-
if (disabled) return
|
|
71
|
-
|
|
71
|
+
function rankColor(role: InkRole, props: Decorations): string | undefined {
|
|
72
|
+
if (props.disabled) return INK.quiet;
|
|
73
|
+
if (props.type === "secondary") return INK.secondary;
|
|
74
|
+
if (props.type === "success") return INK.success;
|
|
75
|
+
if (props.type === "warning") return INK.warning;
|
|
76
|
+
if (props.type === "danger") return INK.danger;
|
|
77
|
+
if (role === "title") return INK.title;
|
|
78
|
+
if (role === "body") return INK.body;
|
|
79
|
+
return undefined;
|
|
72
80
|
}
|
|
73
81
|
|
|
74
|
-
function decorated(props: Decorations, children: ReactNode, base: string, className?: string, style?: HTMLAttributes<HTMLElement>["style"]) {
|
|
82
|
+
function decorated(props: Decorations, children: ReactNode, base: string, className?: string, style?: HTMLAttributes<HTMLElement>["style"], role: InkRole = "body") {
|
|
75
83
|
const line = decorationLine(props.underline, props.delete);
|
|
84
|
+
const color = rankColor(role, props);
|
|
85
|
+
const scale: CSSProperties = { ...markdownVariantStyle("docs"), ...(color ? { color } : null), ...(line ? { textDecorationLine: line } : null), ...style };
|
|
76
86
|
return {
|
|
77
|
-
className: cn(base,
|
|
78
|
-
style:
|
|
87
|
+
className: cn(base, props.disabled && "cursor-not-allowed", props.strong && "font-(--md-strong-weight,600)", props.italic && "italic", props.underline && "underline-offset-[3px]", className),
|
|
88
|
+
style: scale,
|
|
79
89
|
children: wrapDecorations(children, props),
|
|
80
90
|
"aria-disabled": props.disabled || undefined,
|
|
81
91
|
};
|
|
@@ -99,7 +109,7 @@ export type TypographyTextProps = Omit<HTMLAttributes<HTMLSpanElement>, "color">
|
|
|
99
109
|
|
|
100
110
|
export function Text({ className, style, children, ...props }: TypographyTextProps) {
|
|
101
111
|
const { decorations, rest } = splitDecorations(props);
|
|
102
|
-
return <span {...rest} {...decorated(decorations, children,
|
|
112
|
+
return <span {...rest} {...decorated(decorations, children, BODY, className, style, "body")} />;
|
|
103
113
|
}
|
|
104
114
|
|
|
105
115
|
export type TypographyTitleProps = Omit<HTMLAttributes<HTMLHeadingElement>, "color"> & Decorations & {
|
|
@@ -109,14 +119,14 @@ export type TypographyTitleProps = Omit<HTMLAttributes<HTMLHeadingElement>, "col
|
|
|
109
119
|
|
|
110
120
|
export function Title({ level = 1, className, style, children, ...props }: TypographyTitleProps) {
|
|
111
121
|
const { decorations, rest } = splitDecorations(props);
|
|
112
|
-
return createElement(TITLE_TAG[level], { ...rest, ...decorated(decorations, children, cn(TITLE_SPACE,
|
|
122
|
+
return createElement(TITLE_TAG[level], { ...rest, ...decorated(decorations, children, cn(TITLE_SPACE, level === 1 ? pageTitleClass : headingClass(level)), className, style, "title") });
|
|
113
123
|
}
|
|
114
124
|
|
|
115
125
|
export type TypographyParagraphProps = Omit<HTMLAttributes<HTMLParagraphElement>, "color"> & Decorations & { children?: ReactNode };
|
|
116
126
|
|
|
117
127
|
export function Paragraph({ className, style, children, ...props }: TypographyParagraphProps) {
|
|
118
128
|
const { decorations, rest } = splitDecorations(props);
|
|
119
|
-
return <p {...rest} {...decorated(decorations, children,
|
|
129
|
+
return <p {...rest} {...decorated(decorations, children, markdownParagraphClass, className, style, "body")} />;
|
|
120
130
|
}
|
|
121
131
|
|
|
122
132
|
export type TypographyLinkProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "color"> & Decorations & { children?: ReactNode };
|
|
@@ -126,14 +136,10 @@ export function Link({ href, target, rel, className, style, children, onClick, .
|
|
|
126
136
|
const view = decorated(
|
|
127
137
|
decorations,
|
|
128
138
|
children,
|
|
129
|
-
cn(
|
|
130
|
-
"cursor-pointer underline-offset-[3px]",
|
|
131
|
-
BODY,
|
|
132
|
-
decorations.type || decorations.disabled ? undefined : "text-brand hover:text-brand-700",
|
|
133
|
-
decorations.disabled || decorations.underline ? undefined : "hover:underline",
|
|
134
|
-
),
|
|
139
|
+
cn("cursor-pointer underline-offset-[3px]", BODY, decorations.disabled || decorations.underline ? undefined : "hover:underline"),
|
|
135
140
|
className,
|
|
136
141
|
style,
|
|
142
|
+
"body",
|
|
137
143
|
);
|
|
138
144
|
|
|
139
145
|
return (
|