@behavioral-agentic-design-system/core 0.6.0 → 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/LICENSE +21 -0
- package/package.json +35 -6
- package/scripts/bads-sync.mjs +1 -1
- package/scripts/build-fonts.cjs +15 -8
- package/scripts/build-tokens.cjs +139 -23
- package/src/api/brand-fonts.ts +27 -6
- package/src/api/layers/file.ts +4 -3
- package/src/api/layers.ts +41 -12
- package/src/api/onboarding-extract.ts +435 -0
- package/src/api/onboarding.ts +82 -0
- package/src/api/site-auth.ts +50 -0
- package/src/app/font-ready.tsx +1 -1
- package/src/app/layout.tsx +9 -3
- package/src/app/preview/components/page.tsx +78 -1
- package/src/app/preview/icons/page.tsx +5 -0
- package/src/app/shell.tsx +90 -23
- package/src/app/site-login/page.tsx +82 -0
- package/src/brand-fonts.css +5 -0
- package/src/components/Foundations/Colors.stories.tsx +10 -1
- package/src/components/Foundations/Motion.stories.tsx +66 -0
- package/src/components/customize/letter-spacing.tsx +3 -2
- package/src/components/customize/type-scale.tsx +3 -2
- package/src/components/customize-tab.tsx +11 -7
- package/src/components/home-tab.tsx +498 -235
- package/src/components/layers-tab.tsx +313 -10
- package/src/components/onboarding-wizard.tsx +1421 -0
- package/src/components/ui/alert.tsx +2 -2
- package/src/components/ui/bottom-sheet.tsx +124 -0
- package/src/components/ui/button.tsx +1 -1
- package/src/components/ui/chart.tsx +115 -14
- package/src/components/ui/checkbox.tsx +3 -2
- package/src/components/ui/dialog.tsx +7 -4
- package/src/components/ui/dropdown-menu.tsx +4 -0
- package/src/components/ui/index.ts +1 -0
- package/src/components/ui/popover.tsx +6 -0
- package/src/components/ui/radio-group.tsx +4 -3
- package/src/components/ui/scroll-area.tsx +5 -0
- package/src/components/ui/select.tsx +4 -0
- package/src/components/ui/sheet.tsx +8 -1
- package/src/components/ui/slider.tsx +22 -7
- package/src/components/ui/switch.tsx +3 -3
- package/src/components/ui/tabs.tsx +6 -0
- package/src/components/ui/tooltip.tsx +4 -0
- package/src/fonts/HyperlegibleSans-Bold.woff2 +0 -0
- package/src/fonts/HyperlegibleSans-BoldItalic.woff2 +0 -0
- package/src/fonts/HyperlegibleSans-Italic.woff2 +0 -0
- package/src/fonts/HyperlegibleSans-Medium.woff2 +0 -0
- package/src/fonts/HyperlegibleSans-MediumItalic.woff2 +0 -0
- package/src/fonts/HyperlegibleSans-Regular.woff2 +0 -0
- package/src/fonts/InterVariable-Italic.woff2 +0 -0
- package/src/fonts/InterVariable.woff2 +0 -0
- package/src/fonts.css +99 -0
- package/src/hooks/use-global-primary-color.ts +114 -68
- package/src/hooks/use-global-serif-font.ts +1 -1
- package/src/hooks/use-portal-theme-class.tsx +90 -0
- package/src/lib/storage.ts +2 -2
- package/src/styles.css +151 -61
- package/src/tokens.default.json +4 -4
- package/src/tokens.json +159 -162
- package/src/app/preview/login/page.tsx +0 -5
- package/src/app/preview/mail/page.tsx +0 -4
- package/src/app/preview/pricing/page.tsx +0 -4
- package/src/components/admin-menu.stories.tsx +0 -68
- package/src/components/admin-menu.tsx +0 -59
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
-
import { Loader2, FileText, GitCommit, ChevronRight, Check, AlertCircle } from "lucide-react";
|
|
4
|
+
import { Loader2, FileText, GitCommit, ChevronRight, Check, AlertCircle, Palette } from "lucide-react";
|
|
5
|
+
import ReactMarkdown, { type Components } from "react-markdown";
|
|
6
|
+
import remarkGfm from "remark-gfm";
|
|
5
7
|
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
|
|
6
8
|
import { Input } from "@behavioral-agentic-design-system/core/components/ui/input";
|
|
7
9
|
import { Textarea } from "@behavioral-agentic-design-system/core/components/ui/textarea";
|
|
@@ -10,12 +12,107 @@ import { ScrollArea } from "@behavioral-agentic-design-system/core/components/ui
|
|
|
10
12
|
type LayerEntry = { slug: string; label: string; files: string[] };
|
|
11
13
|
type SaveStatus = "idle" | "saving" | "success" | "error";
|
|
12
14
|
type FileType = "editable" | "read-only";
|
|
15
|
+
type ViewMode = "preview" | "code";
|
|
13
16
|
|
|
14
17
|
function getFileType(path: string): FileType {
|
|
15
18
|
if (path.endsWith("tokens.json")) return "read-only";
|
|
16
19
|
return "editable";
|
|
17
20
|
}
|
|
18
21
|
|
|
22
|
+
function isMarkdown(path: string | null): boolean {
|
|
23
|
+
return !!path && path.toLowerCase().endsWith(".md");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// BADS-styled wrapper around react-markdown so the rendered preview reads
|
|
27
|
+
// like the rest of the system (token-aligned colors, AAA text contrast,
|
|
28
|
+
// 14px floor on body type via the global type scale).
|
|
29
|
+
const MARKDOWN_COMPONENTS: Components = {
|
|
30
|
+
h1: ({ children, ...props }: any) => (
|
|
31
|
+
<h1 className="mt-6 mb-3 text-2xl font-semibold tracking-tight first:mt-0" {...props}>{children}</h1>
|
|
32
|
+
),
|
|
33
|
+
h2: ({ children, ...props }: any) => (
|
|
34
|
+
<h2 className="mt-6 mb-3 text-xl font-semibold tracking-tight first:mt-0" {...props}>{children}</h2>
|
|
35
|
+
),
|
|
36
|
+
h3: ({ children, ...props }: any) => (
|
|
37
|
+
<h3 className="mt-5 mb-2 text-lg font-semibold tracking-tight" {...props}>{children}</h3>
|
|
38
|
+
),
|
|
39
|
+
h4: ({ children, ...props }: any) => (
|
|
40
|
+
<h4 className="mt-4 mb-2 text-base font-semibold" {...props}>{children}</h4>
|
|
41
|
+
),
|
|
42
|
+
h5: ({ children, ...props }: any) => (
|
|
43
|
+
<h5 className="mt-3 mb-1 text-sm font-semibold uppercase tracking-wide text-muted-foreground" {...props}>{children}</h5>
|
|
44
|
+
),
|
|
45
|
+
h6: ({ children, ...props }: any) => (
|
|
46
|
+
<h6 className="mt-3 mb-1 text-sm font-semibold uppercase tracking-wide text-muted-foreground" {...props}>{children}</h6>
|
|
47
|
+
),
|
|
48
|
+
p: ({ children, ...props }: any) => (
|
|
49
|
+
<p className="mb-3 leading-relaxed" {...props}>{children}</p>
|
|
50
|
+
),
|
|
51
|
+
a: ({ children, href, ...props }: any) => (
|
|
52
|
+
<a href={href} target="_blank" rel="noreferrer" className="text-primary underline underline-offset-2 hover:text-primary/80" {...props}>{children}</a>
|
|
53
|
+
),
|
|
54
|
+
ul: ({ children, ...props }: any) => (
|
|
55
|
+
<ul className="mb-3 list-disc space-y-1 pl-6" {...props}>{children}</ul>
|
|
56
|
+
),
|
|
57
|
+
ol: ({ children, ...props }: any) => (
|
|
58
|
+
<ol className="mb-3 list-decimal space-y-1 pl-6" {...props}>{children}</ol>
|
|
59
|
+
),
|
|
60
|
+
li: ({ children, ...props }: any) => (
|
|
61
|
+
<li className="leading-relaxed" {...props}>{children}</li>
|
|
62
|
+
),
|
|
63
|
+
code: ({ children, className, ...props }: any) => {
|
|
64
|
+
const inline = !/language-/.test(className ?? "");
|
|
65
|
+
if (inline) {
|
|
66
|
+
return (
|
|
67
|
+
<code className="rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground" {...props}>{children}</code>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return (
|
|
71
|
+
<code className={`font-mono text-xs ${className ?? ""}`} {...props}>{children}</code>
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
pre: ({ children, ...props }: any) => (
|
|
75
|
+
<pre className="mb-3 overflow-x-auto rounded-md border bg-muted/50 p-4 text-xs leading-relaxed" {...props}>{children}</pre>
|
|
76
|
+
),
|
|
77
|
+
blockquote: ({ children, ...props }: any) => (
|
|
78
|
+
<blockquote className="mb-3 border-l-4 border-border pl-4 italic text-muted-foreground" {...props}>{children}</blockquote>
|
|
79
|
+
),
|
|
80
|
+
hr: () => <hr className="my-6 border-border" />,
|
|
81
|
+
table: ({ children, ...props }: any) => (
|
|
82
|
+
<div className="mb-3 overflow-x-auto">
|
|
83
|
+
<table className="w-full border-collapse text-xs" {...props}>{children}</table>
|
|
84
|
+
</div>
|
|
85
|
+
),
|
|
86
|
+
thead: ({ children, ...props }: any) => (
|
|
87
|
+
<thead className="border-b bg-muted/40 text-left" {...props}>{children}</thead>
|
|
88
|
+
),
|
|
89
|
+
th: ({ children, ...props }: any) => (
|
|
90
|
+
<th className="border border-border px-3 py-2 font-medium" {...props}>{children}</th>
|
|
91
|
+
),
|
|
92
|
+
td: ({ children, ...props }: any) => (
|
|
93
|
+
<td className="border border-border px-3 py-2 align-top" {...props}>{children}</td>
|
|
94
|
+
),
|
|
95
|
+
img: ({ src, alt, ...props }: any) => (
|
|
96
|
+
<img src={typeof src === "string" ? src : undefined} alt={alt ?? ""} className="my-3 max-w-full rounded-md border" {...props} />
|
|
97
|
+
),
|
|
98
|
+
strong: ({ children, ...props }: any) => (
|
|
99
|
+
<strong className="font-semibold text-foreground" {...props}>{children}</strong>
|
|
100
|
+
),
|
|
101
|
+
em: ({ children, ...props }: any) => (
|
|
102
|
+
<em className="italic" {...props}>{children}</em>
|
|
103
|
+
),
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
function MarkdownPreview({ source }: { source: string }) {
|
|
107
|
+
return (
|
|
108
|
+
<div className="max-w-3xl text-sm text-foreground/90">
|
|
109
|
+
<ReactMarkdown remarkPlugins={[remarkGfm]} components={MARKDOWN_COMPONENTS}>
|
|
110
|
+
{source}
|
|
111
|
+
</ReactMarkdown>
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
19
116
|
// fileType is set synchronously when activePath changes, but `content` only
|
|
20
117
|
// updates after the fetch resolves. That tick of stale content briefly
|
|
21
118
|
// renders inside the read-only branch, crashing JSON.parse if the previous
|
|
@@ -29,6 +126,97 @@ function prettyJsonOrRaw(content: string): string {
|
|
|
29
126
|
}
|
|
30
127
|
}
|
|
31
128
|
|
|
129
|
+
// Synthetic sidebar entry under Layer 4. It isn't a real file on disk —
|
|
130
|
+
// the semantic tokens live inside tokens.json's `theme` block — so it gets a
|
|
131
|
+
// sentinel path the component special-cases instead of routing through the
|
|
132
|
+
// file-content fetch. Keeps single-source-of-truth: the view reads the same
|
|
133
|
+
// tokens.json everything else builds from, never a duplicated export.
|
|
134
|
+
const SEMANTIC_VIEW = "semantic-tokens://resolved";
|
|
135
|
+
|
|
136
|
+
type SemanticToken = {
|
|
137
|
+
name: string;
|
|
138
|
+
light: string;
|
|
139
|
+
dark: string;
|
|
140
|
+
description?: string;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
function TokenSwatch({ value }: { value: string }) {
|
|
144
|
+
return (
|
|
145
|
+
<span
|
|
146
|
+
className="inline-block size-4 shrink-0 rounded border border-border align-middle"
|
|
147
|
+
style={{ backgroundColor: value }}
|
|
148
|
+
aria-hidden
|
|
149
|
+
/>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Read-only resolved view of the semantic layer: every named role components
|
|
154
|
+
// consume (--background, --primary, …) with its light + dark value. Sourced
|
|
155
|
+
// live from tokens.json → theme, so it can't drift from what ships.
|
|
156
|
+
function SemanticTokensView({ tokens }: { tokens: SemanticToken[] | null }) {
|
|
157
|
+
if (tokens === null) {
|
|
158
|
+
return (
|
|
159
|
+
<div className="flex-1 flex items-center justify-center text-muted-foreground">
|
|
160
|
+
<Loader2 className="h-4 w-4 animate-spin" strokeWidth={1.5} />
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
if (tokens.length === 0) {
|
|
165
|
+
return (
|
|
166
|
+
<div className="flex-1 flex items-center justify-center text-muted-foreground">
|
|
167
|
+
<p className="text-sm">No semantic tokens found in tokens.json → theme.</p>
|
|
168
|
+
</div>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
return (
|
|
172
|
+
<div className="flex-1 overflow-auto px-6 py-6">
|
|
173
|
+
<p className="mb-4 max-w-2xl text-sm text-muted-foreground">
|
|
174
|
+
The resolved semantic tokens — the named roles components consume,
|
|
175
|
+
mapped to their light and dark values. Sourced from{" "}
|
|
176
|
+
<code className="rounded bg-muted px-1 py-0.5 font-mono text-xs">tokens.json</code> →{" "}
|
|
177
|
+
<code className="rounded bg-muted px-1 py-0.5 font-mono text-xs">theme</code>. Read-only here;
|
|
178
|
+
edit values in tokens.json and run{" "}
|
|
179
|
+
<code className="rounded bg-muted px-1 py-0.5 font-mono text-xs">pnpm build:tokens</code>.
|
|
180
|
+
</p>
|
|
181
|
+
<div className="overflow-hidden rounded-md border">
|
|
182
|
+
<table className="w-full border-collapse text-xs">
|
|
183
|
+
<thead className="border-b bg-muted/40 text-left">
|
|
184
|
+
<tr>
|
|
185
|
+
<th className="px-3 py-2 font-medium">Token</th>
|
|
186
|
+
<th className="px-3 py-2 font-medium">Light</th>
|
|
187
|
+
<th className="px-3 py-2 font-medium">Dark</th>
|
|
188
|
+
</tr>
|
|
189
|
+
</thead>
|
|
190
|
+
<tbody>
|
|
191
|
+
{tokens.map((t) => (
|
|
192
|
+
<tr key={t.name} className="border-b align-top last:border-0">
|
|
193
|
+
<td className="px-3 py-2">
|
|
194
|
+
<span className="font-mono text-foreground">--{t.name}</span>
|
|
195
|
+
{t.description && (
|
|
196
|
+
<span className="mt-0.5 block text-muted-foreground">{t.description}</span>
|
|
197
|
+
)}
|
|
198
|
+
</td>
|
|
199
|
+
<td className="px-3 py-2">
|
|
200
|
+
<span className="flex items-center gap-2">
|
|
201
|
+
<TokenSwatch value={t.light} />
|
|
202
|
+
<span className="font-mono text-foreground/80">{t.light}</span>
|
|
203
|
+
</span>
|
|
204
|
+
</td>
|
|
205
|
+
<td className="px-3 py-2">
|
|
206
|
+
<span className="flex items-center gap-2">
|
|
207
|
+
<TokenSwatch value={t.dark} />
|
|
208
|
+
<span className="font-mono text-foreground/80">{t.dark}</span>
|
|
209
|
+
</span>
|
|
210
|
+
</td>
|
|
211
|
+
</tr>
|
|
212
|
+
))}
|
|
213
|
+
</tbody>
|
|
214
|
+
</table>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
32
220
|
export function LayersTab() {
|
|
33
221
|
const [layers, setLayers] = useState<LayerEntry[]>([]);
|
|
34
222
|
const [openLayers, setOpenLayers] = useState<Set<string>>(new Set());
|
|
@@ -39,6 +227,10 @@ export function LayersTab() {
|
|
|
39
227
|
const [commitMessage, setCommitMessage] = useState<string>("");
|
|
40
228
|
const [status, setStatus] = useState<SaveStatus>("idle");
|
|
41
229
|
const [statusMessage, setStatusMessage] = useState<string>("");
|
|
230
|
+
const [viewMode, setViewMode] = useState<ViewMode>("preview");
|
|
231
|
+
// null = loading; [] = loaded-but-empty. Only used by the synthetic
|
|
232
|
+
// semantic-tokens view.
|
|
233
|
+
const [semanticTokens, setSemanticTokens] = useState<SemanticToken[] | null>(null);
|
|
42
234
|
|
|
43
235
|
// Load tree
|
|
44
236
|
useEffect(() => {
|
|
@@ -58,6 +250,35 @@ export function LayersTab() {
|
|
|
58
250
|
if (!activePath) return;
|
|
59
251
|
setStatus("idle");
|
|
60
252
|
setStatusMessage("");
|
|
253
|
+
|
|
254
|
+
// Synthetic semantic-tokens view: read tokens.json (the only non-layer
|
|
255
|
+
// path the file route allows) and pull the theme.light / theme.dark
|
|
256
|
+
// maps into a name → {light, dark} table. Always read-only.
|
|
257
|
+
if (activePath === SEMANTIC_VIEW) {
|
|
258
|
+
setFileType("read-only");
|
|
259
|
+
setSemanticTokens(null);
|
|
260
|
+
fetch(`/api/layers/file?path=${encodeURIComponent("packages/core/src/tokens.json")}`)
|
|
261
|
+
.then((r) => r.json())
|
|
262
|
+
.then((data) => {
|
|
263
|
+
try {
|
|
264
|
+
const parsed = JSON.parse(data.content ?? "{}");
|
|
265
|
+
const light = parsed?.theme?.light ?? {};
|
|
266
|
+
const dark = parsed?.theme?.dark ?? {};
|
|
267
|
+
const tokens: SemanticToken[] = Object.keys(light).map((name) => ({
|
|
268
|
+
name,
|
|
269
|
+
light: light[name]?.$value ?? "",
|
|
270
|
+
dark: dark[name]?.$value ?? "",
|
|
271
|
+
description: light[name]?.$description,
|
|
272
|
+
}));
|
|
273
|
+
setSemanticTokens(tokens);
|
|
274
|
+
} catch {
|
|
275
|
+
setSemanticTokens([]);
|
|
276
|
+
}
|
|
277
|
+
})
|
|
278
|
+
.catch(() => setSemanticTokens([]));
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
61
282
|
setFileType(getFileType(activePath));
|
|
62
283
|
fetch(`/api/layers/file?path=${encodeURIComponent(activePath)}`)
|
|
63
284
|
.then((r) => r.json())
|
|
@@ -136,8 +357,27 @@ export function LayersTab() {
|
|
|
136
357
|
{open && (
|
|
137
358
|
<div className="ml-5 border-l border-border">
|
|
138
359
|
{layer.files.map((file) => {
|
|
139
|
-
|
|
140
|
-
|
|
360
|
+
// Show the path relative to the layer root rather than
|
|
361
|
+
// only the basename. Without this, every layer with a
|
|
362
|
+
// sub-discipline (e.g. `research/`) shows two
|
|
363
|
+
// "README.md" entries that look identical in the
|
|
364
|
+
// sidebar — clicking either is a coin flip. The
|
|
365
|
+
// sub-folder prefix renders muted so the filename
|
|
366
|
+
// stays visually dominant.
|
|
367
|
+
//
|
|
368
|
+
// Derive the name from the real path basename. Most
|
|
369
|
+
// files live under the layer's slug dir, but a few are
|
|
370
|
+
// mounted in from elsewhere (e.g. tokens.json lives at
|
|
371
|
+
// packages/core/src/tokens.json), so slicing by slug
|
|
372
|
+
// length would chew the start off the name
|
|
373
|
+
// ("…/tokens.json" → "json"). Only show a folder prefix
|
|
374
|
+
// for files genuinely nested inside the layer dir.
|
|
375
|
+
const withinLayer = file.startsWith(`${layer.slug}/`);
|
|
376
|
+
const subPath = withinLayer ? file.slice(layer.slug.length + 1) : file;
|
|
377
|
+
const lastSlash = subPath.lastIndexOf("/");
|
|
378
|
+
const folderPrefix =
|
|
379
|
+
withinLayer && lastSlash >= 0 ? subPath.slice(0, lastSlash + 1) : "";
|
|
380
|
+
const fileName = file.slice(file.lastIndexOf("/") + 1);
|
|
141
381
|
const isActive = activePath === file;
|
|
142
382
|
return (
|
|
143
383
|
<button
|
|
@@ -152,11 +392,30 @@ export function LayersTab() {
|
|
|
152
392
|
>
|
|
153
393
|
<FileText className="h-3 w-3 shrink-0" />
|
|
154
394
|
<span className="truncate" title={subPath}>
|
|
155
|
-
{
|
|
395
|
+
{folderPrefix && (
|
|
396
|
+
<span className="text-muted-foreground/60">{folderPrefix}</span>
|
|
397
|
+
)}
|
|
398
|
+
<span>{fileName}</span>
|
|
156
399
|
</span>
|
|
157
400
|
</button>
|
|
158
401
|
);
|
|
159
402
|
})}
|
|
403
|
+
{layer.slug === "layer-4-semantic-tokens" && (
|
|
404
|
+
<button
|
|
405
|
+
type="button"
|
|
406
|
+
onClick={() => setActivePath(SEMANTIC_VIEW)}
|
|
407
|
+
className={`w-full flex items-center gap-2 pl-3 pr-2 py-1.5 text-xs rounded text-left ${
|
|
408
|
+
activePath === SEMANTIC_VIEW
|
|
409
|
+
? "bg-primary/10 text-foreground"
|
|
410
|
+
: "text-muted-foreground hover:text-foreground hover:bg-accent/40"
|
|
411
|
+
}`}
|
|
412
|
+
>
|
|
413
|
+
<Palette className="h-3 w-3 shrink-0" strokeWidth={1.5} />
|
|
414
|
+
<span className="truncate" title="Resolved semantic tokens">
|
|
415
|
+
Semantic tokens
|
|
416
|
+
</span>
|
|
417
|
+
</button>
|
|
418
|
+
)}
|
|
160
419
|
</div>
|
|
161
420
|
)}
|
|
162
421
|
</div>
|
|
@@ -179,22 +438,66 @@ export function LayersTab() {
|
|
|
179
438
|
<>
|
|
180
439
|
<header className="border-b px-6 py-3 flex items-center justify-between gap-4 shrink-0">
|
|
181
440
|
<div className="min-w-0">
|
|
182
|
-
<p className="text-xs text-muted-foreground font-mono truncate">
|
|
441
|
+
<p className="text-xs text-muted-foreground font-mono truncate">
|
|
442
|
+
{activePath === SEMANTIC_VIEW ? "packages/core/src/tokens.json → theme" : activePath}
|
|
443
|
+
</p>
|
|
183
444
|
<h2 className="text-base font-semibold truncate">
|
|
184
|
-
{activePath.split("/").pop()}
|
|
445
|
+
{activePath === SEMANTIC_VIEW ? "Semantic tokens" : activePath.split("/").pop()}
|
|
185
446
|
</h2>
|
|
186
447
|
</div>
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
448
|
+
<div className="flex items-center gap-3 shrink-0">
|
|
449
|
+
{isMarkdown(activePath) && (
|
|
450
|
+
<div
|
|
451
|
+
role="tablist"
|
|
452
|
+
aria-label="View mode"
|
|
453
|
+
className="inline-flex items-center gap-1 rounded-md border bg-muted/40 p-1"
|
|
454
|
+
>
|
|
455
|
+
<button
|
|
456
|
+
role="tab"
|
|
457
|
+
type="button"
|
|
458
|
+
aria-selected={viewMode === "preview"}
|
|
459
|
+
onClick={() => setViewMode("preview")}
|
|
460
|
+
className={`rounded px-3 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${
|
|
461
|
+
viewMode === "preview"
|
|
462
|
+
? "bg-background text-foreground shadow-xs"
|
|
463
|
+
: "text-muted-foreground hover:text-foreground"
|
|
464
|
+
}`}
|
|
465
|
+
>
|
|
466
|
+
Preview
|
|
467
|
+
</button>
|
|
468
|
+
<button
|
|
469
|
+
role="tab"
|
|
470
|
+
type="button"
|
|
471
|
+
aria-selected={viewMode === "code"}
|
|
472
|
+
onClick={() => setViewMode("code")}
|
|
473
|
+
className={`rounded px-3 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${
|
|
474
|
+
viewMode === "code"
|
|
475
|
+
? "bg-background text-foreground shadow-xs"
|
|
476
|
+
: "text-muted-foreground hover:text-foreground"
|
|
477
|
+
}`}
|
|
478
|
+
>
|
|
479
|
+
Code
|
|
480
|
+
</button>
|
|
481
|
+
</div>
|
|
482
|
+
)}
|
|
483
|
+
{dirty && (
|
|
484
|
+
<span className="text-xs text-muted-foreground">Unsaved</span>
|
|
485
|
+
)}
|
|
486
|
+
</div>
|
|
190
487
|
</header>
|
|
191
488
|
|
|
192
|
-
{
|
|
489
|
+
{activePath === SEMANTIC_VIEW ? (
|
|
490
|
+
<SemanticTokensView tokens={semanticTokens} />
|
|
491
|
+
) : fileType === "read-only" ? (
|
|
193
492
|
<div className="flex-1 rounded-none border-0 font-mono text-sm leading-relaxed overflow-auto bg-muted/30 p-6">
|
|
194
493
|
<pre className="whitespace-pre-wrap break-words text-foreground/80">
|
|
195
494
|
{prettyJsonOrRaw(content)}
|
|
196
495
|
</pre>
|
|
197
496
|
</div>
|
|
497
|
+
) : isMarkdown(activePath) && viewMode === "preview" ? (
|
|
498
|
+
<div className="flex-1 overflow-auto px-6 py-8">
|
|
499
|
+
<MarkdownPreview source={content} />
|
|
500
|
+
</div>
|
|
198
501
|
) : (
|
|
199
502
|
<Textarea
|
|
200
503
|
value={content}
|