devnonla-ui 0.10.0 → 0.12.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 +29 -3
- package/package.json +4 -2
- package/src/app/App.tsx +2 -4
- package/src/avatar/AgentAvatar.tsx +205 -0
- package/src/button/Button.tsx +28 -21
- package/src/chat/message-ui/ChatWelcome.tsx +3 -23
- package/src/desktop/DesktopWindow.tsx +41 -17
- package/src/index.ts +10 -1
- package/src/logo/Logo.tsx +17 -197
- package/src/markdown-editor/MarkdownPreview.tsx +1 -1
- package/src/markdown-editor/MarkdownTable.tsx +1 -1
- package/src/markdown-editor/MarkdownViewer.tsx +40 -11
- package/src/markdown-editor/ReactCode.tsx +75 -0
- package/src/markdown-editor/ReactCodeFrame.tsx +46 -0
- package/src/markdown-editor/ReactCodeRunner.tsx +82 -0
- package/src/markdown-editor/ReactCodeSandbox.tsx +156 -0
- package/src/markdown-editor/reactCodeProtocol.ts +47 -0
- package/src/markdown-editor/reactCompile.ts +31 -0
- package/src/sidebar/Sidebar.tsx +7 -7
- package/src/styles.css +108 -0
- package/src/theme.ts +1 -1
- package/src/typography/Typography.tsx +2 -2
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { type ReactNode, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { SolarIcon } from "../icon/SolarIcon";
|
|
3
|
+
import { cn } from "../lib/cn";
|
|
4
|
+
import { getColorMode, type NonlaColorMode, subscribeColorMode } from "../theme";
|
|
5
|
+
import { ReactCodeFrame } from "./ReactCodeFrame";
|
|
6
|
+
import { type HostMessage, REACT_CODE_SOURCE, readRunnerMessage } from "./reactCodeProtocol";
|
|
7
|
+
|
|
8
|
+
/** Keep `mode` on the runner URL without dropping a query the caller already set. */
|
|
9
|
+
function withColorMode(src: string, mode: NonlaColorMode): string {
|
|
10
|
+
const hashAt = src.indexOf("#");
|
|
11
|
+
const hash = hashAt >= 0 ? src.slice(hashAt) : "";
|
|
12
|
+
const beforeHash = hashAt >= 0 ? src.slice(0, hashAt) : src;
|
|
13
|
+
const queryAt = beforeHash.indexOf("?");
|
|
14
|
+
const path = queryAt >= 0 ? beforeHash.slice(0, queryAt) : beforeHash;
|
|
15
|
+
const params = new URLSearchParams(queryAt >= 0 ? beforeHash.slice(queryAt + 1) : "");
|
|
16
|
+
params.set("mode", mode);
|
|
17
|
+
return `${path}?${params.toString()}${hash}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The runner page must report `ready` within this time. */
|
|
21
|
+
const READY_TIMEOUT_MS = 20000;
|
|
22
|
+
/** After the code is sent, the runner must report `rendered` within this time. */
|
|
23
|
+
const RENDER_TIMEOUT_MS = 15000;
|
|
24
|
+
const MIN_HEIGHT = 32;
|
|
25
|
+
const MAX_HEIGHT = 1200;
|
|
26
|
+
|
|
27
|
+
export type ReactCodeSandboxProps = {
|
|
28
|
+
code: string;
|
|
29
|
+
/** URL of a page that calls `mountReactCodeRunner`. Serve it from its own origin. Loaded with `?mode=light|dark` so the runner can paint before its script. */
|
|
30
|
+
src: string;
|
|
31
|
+
/** Header above the result. Default `true`. */
|
|
32
|
+
showHeader?: boolean;
|
|
33
|
+
/** Code tab in the header. Needs `showHeader`. Default `true`. */
|
|
34
|
+
showCode?: boolean;
|
|
35
|
+
/** Header text. Default `Sandbox`. */
|
|
36
|
+
title?: ReactNode;
|
|
37
|
+
/** Header icon. `null` hides it. */
|
|
38
|
+
icon?: ReactNode;
|
|
39
|
+
/** Classes for the outer box. */
|
|
40
|
+
className?: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Runs untrusted `live-react` source in a sandboxed iframe.
|
|
45
|
+
*
|
|
46
|
+
* `sandbox="allow-scripts"` without `allow-same-origin` gives the frame an opaque origin,
|
|
47
|
+
* so it cannot read this page's cookies, storage, or DOM.
|
|
48
|
+
*/
|
|
49
|
+
export function ReactCodeSandbox({ code, src, showHeader = true, showCode = true, title = "Sandbox", icon, className }: ReactCodeSandboxProps) {
|
|
50
|
+
const frameRef = useRef<HTMLIFrameElement>(null);
|
|
51
|
+
const [height, setHeight] = useState(MIN_HEIGHT);
|
|
52
|
+
const [error, setError] = useState<string | null>(null);
|
|
53
|
+
const [mode, setMode] = useState(getColorMode);
|
|
54
|
+
const [painted, setPainted] = useState(false);
|
|
55
|
+
// Mode stays out of the URL after first load. A later theme change is a message, so the frame does not reload.
|
|
56
|
+
const modeOnLoad = useRef(getColorMode());
|
|
57
|
+
const frameSrc = useMemo(() => withColorMode(src, modeOnLoad.current), [src]);
|
|
58
|
+
|
|
59
|
+
useEffect(() => subscribeColorMode(() => setMode(getColorMode())), []);
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
setPainted(false);
|
|
63
|
+
setError(null);
|
|
64
|
+
}, [frameSrc, code]);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
const frame = frameRef.current;
|
|
68
|
+
if (!frame) return;
|
|
69
|
+
let alive = true;
|
|
70
|
+
// Once the runner has painted, a late timer must not replace the preview with an error.
|
|
71
|
+
let didRender = false;
|
|
72
|
+
let renderTimer: ReturnType<typeof setTimeout> | undefined;
|
|
73
|
+
const readyTimer = setTimeout(() => {
|
|
74
|
+
if (alive && !didRender) setError("The sandbox did not start.");
|
|
75
|
+
}, READY_TIMEOUT_MS);
|
|
76
|
+
|
|
77
|
+
const postRun = () => {
|
|
78
|
+
const run: HostMessage = { source: REACT_CODE_SOURCE, type: "run", code, mode: getColorMode() };
|
|
79
|
+
frame.contentWindow?.postMessage(run, "*");
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const expectRender = () => {
|
|
83
|
+
clearTimeout(renderTimer);
|
|
84
|
+
renderTimer = setTimeout(() => {
|
|
85
|
+
if (alive && !didRender) setError("The code took too long to run.");
|
|
86
|
+
}, RENDER_TIMEOUT_MS);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const onMessage = (event: MessageEvent) => {
|
|
90
|
+
// Only the frame we created. Its origin is opaque, so compare the window, not the origin.
|
|
91
|
+
if (event.source !== frame.contentWindow) return;
|
|
92
|
+
const msg = readRunnerMessage(event.data);
|
|
93
|
+
if (!msg) return;
|
|
94
|
+
if (msg.type === "ready") {
|
|
95
|
+
clearTimeout(readyTimer);
|
|
96
|
+
// A runner that restarts after paint (HMR) still needs the code, but must not restart the failure clock.
|
|
97
|
+
if (didRender) {
|
|
98
|
+
postRun();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
setError(null);
|
|
102
|
+
postRun();
|
|
103
|
+
expectRender();
|
|
104
|
+
} else if (msg.type === "rendered") {
|
|
105
|
+
didRender = true;
|
|
106
|
+
clearTimeout(renderTimer);
|
|
107
|
+
setError(null);
|
|
108
|
+
setPainted(true);
|
|
109
|
+
} else if (msg.type === "resize") {
|
|
110
|
+
setHeight(Math.min(MAX_HEIGHT, Math.max(MIN_HEIGHT, Math.ceil(msg.height))));
|
|
111
|
+
} else if (msg.type === "error") {
|
|
112
|
+
clearTimeout(readyTimer);
|
|
113
|
+
clearTimeout(renderTimer);
|
|
114
|
+
setError(msg.message);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// The frame has its own document, so it follows the page's light or dark mode through us.
|
|
119
|
+
const unsubscribeMode = subscribeColorMode(() => {
|
|
120
|
+
const mode: HostMessage = { source: REACT_CODE_SOURCE, type: "mode", mode: getColorMode() };
|
|
121
|
+
frame.contentWindow?.postMessage(mode, "*");
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
window.addEventListener("message", onMessage);
|
|
125
|
+
// Strict Mode remounts this listener after the frame already posted `ready`.
|
|
126
|
+
postRun();
|
|
127
|
+
return () => {
|
|
128
|
+
alive = false;
|
|
129
|
+
unsubscribeMode();
|
|
130
|
+
window.removeEventListener("message", onMessage);
|
|
131
|
+
clearTimeout(readyTimer);
|
|
132
|
+
clearTimeout(renderTimer);
|
|
133
|
+
};
|
|
134
|
+
}, [code, src]);
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<ReactCodeFrame
|
|
138
|
+
title={title}
|
|
139
|
+
icon={icon === undefined ? <SolarIcon name="shield-check-linear" size={16} className="text-success" /> : icon}
|
|
140
|
+
showHeader={showHeader}
|
|
141
|
+
code={showCode ? code : undefined}
|
|
142
|
+
className={className}
|
|
143
|
+
>
|
|
144
|
+
{error ? <p className="m-0 text-sm text-destructive">{error}</p> : null}
|
|
145
|
+
<iframe
|
|
146
|
+
ref={frameRef}
|
|
147
|
+
src={frameSrc}
|
|
148
|
+
title="React example"
|
|
149
|
+
sandbox="allow-scripts"
|
|
150
|
+
referrerPolicy="no-referrer"
|
|
151
|
+
className={cn("block w-full border-0 bg-background", (!painted || error) && "opacity-0")}
|
|
152
|
+
style={{ height, colorScheme: mode }}
|
|
153
|
+
/>
|
|
154
|
+
</ReactCodeFrame>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { NonlaColorMode } from "../theme";
|
|
2
|
+
|
|
3
|
+
/** Message tag shared by the sandbox host (`ReactCodeSandbox`) and the runner page. */
|
|
4
|
+
export const REACT_CODE_SOURCE = "nonla-react-code";
|
|
5
|
+
|
|
6
|
+
export type HostMessage =
|
|
7
|
+
| { source: typeof REACT_CODE_SOURCE; type: "run"; code: string; mode: NonlaColorMode }
|
|
8
|
+
| { source: typeof REACT_CODE_SOURCE; type: "mode"; mode: NonlaColorMode };
|
|
9
|
+
|
|
10
|
+
export type RunnerMessage =
|
|
11
|
+
| { source: typeof REACT_CODE_SOURCE; type: "ready" }
|
|
12
|
+
| { source: typeof REACT_CODE_SOURCE; type: "rendered" }
|
|
13
|
+
| { source: typeof REACT_CODE_SOURCE; type: "resize"; height: number }
|
|
14
|
+
| { source: typeof REACT_CODE_SOURCE; type: "error"; message: string };
|
|
15
|
+
|
|
16
|
+
/** A runner message without the shared tag. */
|
|
17
|
+
export type RunnerPayload = RunnerMessage extends infer M ? (M extends RunnerMessage ? Omit<M, "source"> : never) : never;
|
|
18
|
+
|
|
19
|
+
/** Anything from the iframe is untrusted, so check the shape before using it. */
|
|
20
|
+
export function readRunnerMessage(data: unknown): RunnerMessage | null {
|
|
21
|
+
if (typeof data !== "object" || data === null) return null;
|
|
22
|
+
const msg = data as Record<string, unknown>;
|
|
23
|
+
if (msg.source !== REACT_CODE_SOURCE) return null;
|
|
24
|
+
if (msg.type === "ready" || msg.type === "rendered") return { source: REACT_CODE_SOURCE, type: msg.type };
|
|
25
|
+
if (msg.type === "resize" && typeof msg.height === "number" && Number.isFinite(msg.height)) {
|
|
26
|
+
return { source: REACT_CODE_SOURCE, type: "resize", height: msg.height };
|
|
27
|
+
}
|
|
28
|
+
if (msg.type === "error" && typeof msg.message === "string") {
|
|
29
|
+
return { source: REACT_CODE_SOURCE, type: "error", message: msg.message.slice(0, 300) };
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function readMode(value: unknown): NonlaColorMode | null {
|
|
35
|
+
return value === "light" || value === "dark" ? value : null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function readHostMessage(data: unknown): HostMessage | null {
|
|
39
|
+
if (typeof data !== "object" || data === null) return null;
|
|
40
|
+
const msg = data as Record<string, unknown>;
|
|
41
|
+
if (msg.source !== REACT_CODE_SOURCE) return null;
|
|
42
|
+
const mode = readMode(msg.mode);
|
|
43
|
+
if (!mode) return null;
|
|
44
|
+
if (msg.type === "mode") return { source: REACT_CODE_SOURCE, type: "mode", mode };
|
|
45
|
+
if (msg.type === "run" && typeof msg.code === "string") return { source: REACT_CODE_SOURCE, type: "run", code: msg.code, mode };
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { transform } from "sucrase";
|
|
4
|
+
|
|
5
|
+
export type LiveComponent = () => ReactNode;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Compiles TSX source to a component. This runs the source as code in the current
|
|
9
|
+
* page, so it must only see trusted input or run inside the sandbox runner.
|
|
10
|
+
*/
|
|
11
|
+
export function compileReactCode(code: string, modules: Record<string, unknown>): LiveComponent {
|
|
12
|
+
const js = transform(code, {
|
|
13
|
+
transforms: ["typescript", "jsx", "imports"],
|
|
14
|
+
jsxRuntime: "classic",
|
|
15
|
+
production: true,
|
|
16
|
+
}).code;
|
|
17
|
+
const requireModule = (id: string) => {
|
|
18
|
+
if (id === "react") return React;
|
|
19
|
+
if (Object.hasOwn(modules, id)) return modules[id];
|
|
20
|
+
throw new Error(`Unknown module "${id}".`);
|
|
21
|
+
};
|
|
22
|
+
const exports: { default?: LiveComponent } = {};
|
|
23
|
+
const run = new Function("require", "exports", "React", `${js}\nreturn exports.default;`) as (
|
|
24
|
+
require: (id: string) => unknown,
|
|
25
|
+
exports: { default?: LiveComponent },
|
|
26
|
+
React: typeof import("react"),
|
|
27
|
+
) => LiveComponent | undefined;
|
|
28
|
+
const Demo = run(requireModule, exports, React);
|
|
29
|
+
if (typeof Demo !== "function") throw new Error("React block must export default a component.");
|
|
30
|
+
return Demo;
|
|
31
|
+
}
|
package/src/sidebar/Sidebar.tsx
CHANGED
|
@@ -98,9 +98,9 @@ function SidebarList({
|
|
|
98
98
|
}
|
|
99
99
|
if (isGroup(item)) {
|
|
100
100
|
return (
|
|
101
|
-
<div key={key} className="mb-
|
|
101
|
+
<div key={key} className="mb-5 last:mb-0">
|
|
102
102
|
{item.label != null && item.label !== "" ? (
|
|
103
|
-
<div className={cn("px-
|
|
103
|
+
<div className={cn("px-3 pb-2 pt-3 text-[11px] font-bold uppercase tracking-wider text-quaternary-foreground", item.className)}>
|
|
104
104
|
{item.label}
|
|
105
105
|
</div>
|
|
106
106
|
) : null}
|
|
@@ -113,9 +113,9 @@ function SidebarList({
|
|
|
113
113
|
|
|
114
114
|
const active = selected != null && key === selected;
|
|
115
115
|
const className = cn(
|
|
116
|
-
"nonla-sidebar-item flex w-full items-center gap-
|
|
116
|
+
"nonla-sidebar-item flex w-full items-center gap-3 px-3 text-left text-[13px] font-normal no-underline",
|
|
117
117
|
item.disabled ? "pointer-events-none cursor-not-allowed opacity-40" : "cursor-pointer",
|
|
118
|
-
active ? "
|
|
118
|
+
active ? "text-foreground" : "text-foreground/80 hover:text-foreground",
|
|
119
119
|
item.className,
|
|
120
120
|
);
|
|
121
121
|
|
|
@@ -184,13 +184,13 @@ export function Sidebar({
|
|
|
184
184
|
<div className={cn("flex h-full min-h-0 flex-col", className)}>
|
|
185
185
|
{header}
|
|
186
186
|
{searchable ? (
|
|
187
|
-
<div className={cn("shrink-0 px-3 pb-
|
|
187
|
+
<div className={cn("shrink-0 px-3 pb-3", header ? "pt-1" : "pt-3")}>
|
|
188
188
|
<SearchInput size="small" wait={0} placeholder={searchPlaceholder} onChange={setQuery} />
|
|
189
189
|
</div>
|
|
190
190
|
) : null}
|
|
191
|
-
<OverlayScroll className="min-h-0 flex-1" innerClassName={cn("px-
|
|
191
|
+
<OverlayScroll className="min-h-0 flex-1" innerClassName={cn("px-3 pb-6", !searchable && !header && "pt-3")}>
|
|
192
192
|
<nav aria-label={ariaLabel}>
|
|
193
|
-
{visible.length === 0 ? <p className="px-
|
|
193
|
+
{visible.length === 0 ? <p className="px-3 py-4 text-sm text-muted-foreground">{emptyText}</p> : <SidebarList items={visible} selected={selected} onSelect={handleSelect} />}
|
|
194
194
|
</nav>
|
|
195
195
|
</OverlayScroll>
|
|
196
196
|
{footer}
|
package/src/styles.css
CHANGED
|
@@ -1148,3 +1148,111 @@
|
|
|
1148
1148
|
color: #b31d28;
|
|
1149
1149
|
background-color: #ffeef0;
|
|
1150
1150
|
}
|
|
1151
|
+
|
|
1152
|
+
/* ── Agent avatars — a quiet shift, not a bounce ──────────────────────── */
|
|
1153
|
+
.nonla-avatar {
|
|
1154
|
+
display: inline-flex;
|
|
1155
|
+
flex-shrink: 0;
|
|
1156
|
+
line-height: 0;
|
|
1157
|
+
vertical-align: middle;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
.nonla-avatar-bob {
|
|
1161
|
+
display: block;
|
|
1162
|
+
width: 100%;
|
|
1163
|
+
height: 100%;
|
|
1164
|
+
transform: translate(var(--nonla-avatar-hx, 0), var(--nonla-avatar-hy, 0));
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
.nonla-avatar-gaze {
|
|
1168
|
+
transform-box: view-box;
|
|
1169
|
+
transform: translate(var(--nonla-avatar-ex, 0), var(--nonla-avatar-ey, 0));
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
.nonla-avatar-eyes {
|
|
1173
|
+
transform-box: fill-box;
|
|
1174
|
+
transform-origin: center;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
.nonla-avatar[data-motion="idle"] .nonla-avatar-bob {
|
|
1178
|
+
animation: nonla-avatar-wander 8.4s ease-in-out infinite;
|
|
1179
|
+
animation-delay: var(--nonla-avatar-delay, 0s);
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
.nonla-avatar[data-motion="idle"] .nonla-avatar-gaze {
|
|
1183
|
+
animation: nonla-avatar-glance 8.4s ease-in-out infinite;
|
|
1184
|
+
animation-delay: var(--nonla-avatar-delay, 0s);
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
.nonla-avatar[data-motion="idle"] .nonla-avatar-eyes {
|
|
1188
|
+
animation: nonla-avatar-blink 6.4s ease-in-out infinite;
|
|
1189
|
+
animation-delay: var(--nonla-avatar-delay, 0s);
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
@keyframes nonla-avatar-wander {
|
|
1193
|
+
0%,
|
|
1194
|
+
14%,
|
|
1195
|
+
100% {
|
|
1196
|
+
transform: translate(var(--nonla-avatar-hx, 0), var(--nonla-avatar-hy, 0));
|
|
1197
|
+
}
|
|
1198
|
+
22%,
|
|
1199
|
+
34% {
|
|
1200
|
+
transform: translate(-5%, 1%);
|
|
1201
|
+
}
|
|
1202
|
+
42%,
|
|
1203
|
+
54% {
|
|
1204
|
+
transform: translate(0, -4%);
|
|
1205
|
+
}
|
|
1206
|
+
62%,
|
|
1207
|
+
74% {
|
|
1208
|
+
transform: translate(5%, 1%);
|
|
1209
|
+
}
|
|
1210
|
+
82%,
|
|
1211
|
+
94% {
|
|
1212
|
+
transform: translate(0, 4.4%);
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
@keyframes nonla-avatar-glance {
|
|
1217
|
+
0%,
|
|
1218
|
+
14%,
|
|
1219
|
+
100% {
|
|
1220
|
+
transform: translate(var(--nonla-avatar-ex, 0), var(--nonla-avatar-ey, 0));
|
|
1221
|
+
}
|
|
1222
|
+
22%,
|
|
1223
|
+
34% {
|
|
1224
|
+
transform: translate(-10%, 0.6%);
|
|
1225
|
+
}
|
|
1226
|
+
42%,
|
|
1227
|
+
54% {
|
|
1228
|
+
transform: translate(0, -6.9%);
|
|
1229
|
+
}
|
|
1230
|
+
62%,
|
|
1231
|
+
74% {
|
|
1232
|
+
transform: translate(10%, 0.6%);
|
|
1233
|
+
}
|
|
1234
|
+
82%,
|
|
1235
|
+
94% {
|
|
1236
|
+
transform: translate(0, 7.2%);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
@keyframes nonla-avatar-blink {
|
|
1241
|
+
0%,
|
|
1242
|
+
46%,
|
|
1243
|
+
52%,
|
|
1244
|
+
100% {
|
|
1245
|
+
transform: scaleY(1);
|
|
1246
|
+
}
|
|
1247
|
+
49% {
|
|
1248
|
+
transform: scaleY(0.15);
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1253
|
+
.nonla-avatar[data-motion] .nonla-avatar-bob,
|
|
1254
|
+
.nonla-avatar[data-motion] .nonla-avatar-gaze,
|
|
1255
|
+
.nonla-avatar[data-motion] .nonla-avatar-eyes {
|
|
1256
|
+
animation: none;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
package/src/theme.ts
CHANGED
|
@@ -206,8 +206,8 @@ function isColorPreference(value: string | null): value is NonlaColorPreference
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
function readStoredPreference(): NonlaColorPreference | null {
|
|
209
|
-
if (typeof localStorage === "undefined") return null;
|
|
210
209
|
try {
|
|
210
|
+
// Sandboxed iframes throw on the property access itself, before getItem.
|
|
211
211
|
const value = localStorage.getItem(NONLA_COLOR_MODE_KEY);
|
|
212
212
|
return isColorPreference(value) ? value : null;
|
|
213
213
|
} catch {
|
|
@@ -43,7 +43,7 @@ const TITLE_CLASS: Record<TitleLevel, string> = {
|
|
|
43
43
|
5: "text-[16px] leading-[24px] font-semibold",
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
const TITLE_SPACE = "nonla-typo
|
|
46
|
+
const TITLE_SPACE = "nonla-typo m-0";
|
|
47
47
|
|
|
48
48
|
function decorationLine(underline?: boolean, deleted?: boolean) {
|
|
49
49
|
if (underline && deleted) return "underline line-through";
|
|
@@ -58,7 +58,7 @@ function wrapDecorations(children: ReactNode, props: Decorations) {
|
|
|
58
58
|
node = <mark className="rounded-sm bg-[color-mix(in_oklab,var(--nonla-yellow)_40%,transparent)] px-0.5 text-inherit">{node}</mark>;
|
|
59
59
|
}
|
|
60
60
|
if (props.code) {
|
|
61
|
-
node = <code className="rounded-sm bg-secondary px-1 py-px font-mono text-[0.9em]">{node}</code>;
|
|
61
|
+
node = <code className="rounded-sm bg-secondary px-1 py-px font-mono text-[0.9em] shadow-button-outline">{node}</code>;
|
|
62
62
|
}
|
|
63
63
|
if (props.keyboard) {
|
|
64
64
|
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>;
|