fndn/ui

Showcase

Code editor

An editor window: files, tabs over the code, a terminal and problems panel, source control with a diff, a command palette and an assistant that proposes a fix.

Source

Only the system's components and token utilities; the layout is Tailwind.

showcases/code-editor/App.tsx
1/* A code editor (VS Code, Zed): an activity bar and a side view (explorer or source control), open
2 * files as attached tabs over the code, a terminal and problems panel below, an assistant on the
3 * right, a command palette on Ctrl/⌘ K or P and a status bar. Dense like the product: 24px tree
4 * and list rows, 28px tabs, 32px pane headers, 13px code that never wraps. Panels are a Splitter
5 * (drag, or arrow keys on a handle); a panel is open while its size is above zero, so the toggles
6 * and the handles share one state. Below 720px the app shows one view at a time, picked at the
7 * bottom. Shortcuts are bound on the app's root, so they work while the app has focus and leave
8 * the page's own keys alone.
9 *
10 * A rounded app: the page that hosts it has <html data-shape="rounded"> (index.json tells the
11 * docs site), so no button, toggle or switcher here names a shape, and its dialogs follow. */
12import { useCallback, useLayoutEffect, useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from "react";
13import { CheckCircle, Eye, File, FileText, Folder, GitBranch, MagnifyingGlass, Play, Sparkle, Terminal, Warning, XCircle } from "@phosphor-icons/react";
14import {
15 Button, CodeView, CommandPalette, Count, EmptyState, Kbd, ScrollArea, SegmentedControl, Splitter, Tabs, Toggle, TreeView,
16 type CommandPaletteItem, type TreeViewNode,
17} from "@fndn/react";
18import { Assistant } from "./Assistant";
19import { SourceControl } from "./SourceControl";
20import { BRANCH, CHANGES, FILES, PROBLEMS, PROJECT, RATE_LIMIT_FIXED, TREE, lineDiff, testRun, type Change } from "./data";
21
22const RATE_LIMIT = "src/middleware/rate-limit.ts";
23/** An open diff is a tab of its own, next to the file's: its value is the path with this prefix. */
24const DIFF = "diff:";
25const mod = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.userAgent) ? "⌘" : "Ctrl";
26/** A pane's title row: 32px, the height of the tab strip beside it, quiet small text. */
27const PANE_TITLE = "flex h-8 shrink-0 items-center px-3 text-xs font-medium text-ink-2";
28
29/** The size of an element (a callback ref: the element may come and go), measured before the
30 * first paint and on every change. */
31function useSize() {
32 const [size, setSize] = useState({ width: 0, height: 0 });
33 const observer = useRef<ResizeObserver>(null);
34 const ref = useCallback((el: HTMLElement | null) => {
35 observer.current?.disconnect();
36 if (!el) return;
37 setSize({ width: el.clientWidth, height: el.clientHeight });
38 observer.current = new ResizeObserver(([e]) => e && setSize({ width: e.contentRect.width, height: e.contentRect.height }));
39 observer.current.observe(el);
40 }, []);
41 return [ref, size] as const;
42}
43
44const fileIcon = (path: string) => (path.endsWith(".md") ? <FileText data-slot="icon" /> : <File data-slot="icon" />);
45const withIcons = (nodes: TreeViewNode[]): TreeViewNode[] =>
46 nodes.map((n) => (n.children
47 ? { ...n, icon: <Folder />, children: withIcons(n.children) }
48 : { ...n, icon: n.value.endsWith(".md") ? <FileText /> : <File /> }));
49const FILE_TREE = withIcons(TREE);
50const nameOf = (path: string) => path.split("/").pop()!;
51const pathOf = (tab: string) => (tab.startsWith(DIFF) ? tab.slice(DIFF.length) : tab);
52const language = (path: string) => (path.endsWith(".ts") ? "TypeScript" : path.endsWith(".json") ? "JSON" : "Markdown");
53
54/** A terminal line in vitest's colours: counts of failed red, passed green, marks in their tone;
55 * what vitest dims (labels, a file's test count, timings, the path) is ink-2 beside the ink of
56 * the output: two levels, and both are read, so neither is fainter than ink-2. PARTS also cuts
57 * out the labels and a file's test count, so a "1 failed" inside "(3 tests | 1 failed)" is
58 * dimmed with its count. */
59const TONES: [RegExp, string][] = [
60 [/^(\d+ failed|×|FAIL)$/, "text-red"],
61 [/^(\d+ passed|✓)$/, "text-green"],
62 [/^❯$/, "text-orange"],
63 [/^(Test Files|Tests|Duration|RUN|\(\d+(?: tests?)?(?: \| \d+ failed)?\)|\d+ms|\/home\/[\w/-]+)$/, "text-ink-2"],
64];
65const PARTS = /(\d+ failed|\d+ passed|×|✓|❯|FAIL|Test Files|Tests|Duration|RUN|\(\d+(?: tests?)?(?: \| \d+ failed)?\)|\d+ms|\/home\/[\w/-]+)/;
66function TerminalLine({ line }: { line: string }) {
67 if (line.startsWith("$ ")) return <div className="ps-[1ch] text-ink">{line}</div>;
68 if (!line) return <div>{" "}</div>;
69 return (
70 <div className="text-ink">
71 {line.split(PARTS).map((part, i) => {
72 const tone = TONES.find(([re]) => re.test(part))?.[1];
73 return tone ? <span key={i} className={tone}>{part}</span> : part;
74 })}
75 </div>
76 );
77}
78
79/** The terminal: opens at the start of the newest run (the first frame never scrolls), and a run
80 * added later is brought in at its first line, once the terminal is in view (it may be a hidden
81 * tab when the run is added). */
82function TerminalOutput({ lines }: { lines: string[] }) {
83 const output = useRef<HTMLPreElement>(null);
84 const shown = useRef(lines.length);
85 useLayoutEffect(() => {
86 const el = output.current;
87 const view = el?.closest<HTMLElement>("[data-slot=scroll-area-viewport]");
88 if (!el || !view) return;
89 const reveal = () => {
90 const count = el.children.length;
91 if (count === shown.current || !el.offsetHeight) return;
92 shown.current = count;
93 const rows = [...el.children] as HTMLElement[];
94 const start = rows.map((row) => row.textContent?.startsWith("$ ")).lastIndexOf(true);
95 view.scrollTop = start > 0 ? rows[start]!.offsetTop : 0;
96 };
97 reveal();
98 const ro = new ResizeObserver(reveal);
99 ro.observe(el);
100 return () => ro.disconnect();
101 }, [lines]);
102 return (
103 /* left to right on a right-to-left page too; long lines wrap at the pane's width, as a terminal
104 * wraps at its columns, so a line's start is never cut and nothing scrolls sideways */
105 <pre ref={output} className="relative px-3 py-2 font-mono text-xs leading-5 whitespace-pre-wrap wrap-anywhere [direction:ltr] [text-size-adjust:100%]">
106 {lines.map((line, i) => <TerminalLine key={i} line={line} />)}
107 </pre>
108 );
109}
110
111/** One panel open: the sizes it takes, the others sharing the rest. */
112const sideSizes = (side: boolean, assistant: boolean) => [side ? 23 : 0, 100 - (side ? 23 : 0) - (assistant ? 28 : 0), assistant ? 28 : 0];
113
114export default function App() {
115 const [root, { width }] = useSize();
116 const phone = width > 0 && width < 720;
117
118 /* the project */
119 const [files, setFiles] = useState(FILES);
120 const [changes, setChanges] = useState<Change[]>(CHANGES);
121 const [problems, setProblems] = useState(PROBLEMS);
122 const [terminal, setTerminal] = useState(() => testRun(false));
123 const [passing, setPassing] = useState(false);
124 const [ahead, setAhead] = useState(0);
125
126 /* the editor: open tabs (a path, or DIFF + path) and the active one */
127 const [open, setOpen] = useState([RATE_LIMIT, "test/rate-limit.test.ts", "src/routes/invoices.ts"]);
128 const [active, setActive] = useState(RATE_LIMIT);
129 const activePath = pathOf(active);
130 const diffOf = active.startsWith(DIFF) ? activePath : null;
131 /* the line the caret is on in each file, marked as the code block's current line */
132 const [caret, setCaret] = useState<Record<string, number>>({});
133 const [expanded, setExpanded] = useState(["src", "src/middleware", "test"]);
134
135 /* the layout */
136 const [side, setSide] = useState<"explorer" | "changes">("explorer");
137 const [sizes, setSizes] = useState(() => sideSizes(true, true));
138 const [rows, setRows] = useState([68, 32]);
139 const [panelTab, setPanelTab] = useState("terminal");
140 const [phoneView, setPhoneView] = useState("code");
141 const [palette, setPalette] = useState(false);
142 const sideOpen = sizes[0]! > 0, assistantOpen = sizes[2]! > 0, panelOpen = rows[1]! > 0;
143
144 const openTab = (tab: string) => {
145 setOpen((o) => (o.includes(tab) ? o : [...o, tab]));
146 setActive(tab);
147 setPhoneView("code");
148 };
149 const openFile = (path: string, line?: number) => {
150 openTab(path);
151 if (line) setCaret((c) => ({ ...c, [path]: line }));
152 };
153 const openDiff = (path: string) => { openTab(DIFF + path); setSide("changes"); };
154 const closeTab = (tab: string) => setOpen((o) => o.filter((t) => t !== tab));
155 const showSide = (view: "explorer" | "changes" | null) => {
156 if (view) setSide(view);
157 setSizes(sideSizes(!!view, assistantOpen));
158 if (view) setPhoneView(view === "explorer" ? "files" : "changes");
159 };
160 const showPanel = (show: boolean, tab?: string) => {
161 if (tab) setPanelTab(tab);
162 setRows(show ? [68, 32] : [100, 0]);
163 if (show) setPhoneView("panel");
164 };
165 const runTests = (fixed = files[RATE_LIMIT] === RATE_LIMIT_FIXED) => {
166 setTerminal((t) => [...t, "", ...testRun(fixed)]);
167 setPassing(fixed);
168 showPanel(true, "terminal");
169 };
170 const applyFix = (andTest: boolean) => {
171 setFiles((f) => ({ ...f, [RATE_LIMIT]: RATE_LIMIT_FIXED }));
172 /* appended, so the rows already there do not move */
173 setChanges((c) => (c.some((x) => x.path === RATE_LIMIT) ? c : [...c, { path: RATE_LIMIT, status: "modified", before: FILES[RATE_LIMIT]! }]));
174 setProblems((p) => p.filter((x) => x.fixedBy !== "rate-limit"));
175 openDiff(RATE_LIMIT);
176 if (andTest) runTests(true);
177 };
178 /* committed changes have no diff left: their tabs close, and the file's own tab takes over */
179 const commit = () => {
180 setChanges([]);
181 setOpen((o) => { const kept = o.filter((t) => !t.startsWith(DIFF)); return diffOf && !kept.includes(diffOf) ? [...kept, diffOf] : kept; });
182 if (diffOf) setActive(diffOf);
183 setAhead((n) => n + 1);
184 };
185
186 /* files are found by name or path; commands show their own shortcut */
187 const commands = useMemo((): CommandPaletteItem[] => [
188 ...Object.keys(files).map((path) => ({
189 value: `file:${path}`, label: nameOf(path), meta: path, group: "Files", keywords: [path],
190 icon: path.endsWith(".md") ? <FileText data-slot="icon" weight="bold" /> : <File data-slot="icon" weight="bold" />,
191 })),
192 { value: "run-tests", label: "Run tests", meta: "pnpm test", group: "Commands", icon: <Play data-slot="icon" weight="bold" /> },
193 { value: "explorer", label: "Show explorer", group: "View", shortcut: [mod, "B"], icon: <Eye data-slot="icon" weight="bold" /> },
194 { value: "changes", label: "Show source control", group: "View", keywords: ["git", "diff"], icon: <GitBranch data-slot="icon" weight="bold" /> },
195 { value: "terminal", label: "Show terminal", group: "View", shortcut: [mod, "J"], icon: <Terminal data-slot="icon" weight="bold" /> },
196 { value: "problems", label: "Show problems", group: "View", keywords: ["errors", "warnings"], icon: <Warning data-slot="icon" weight="bold" /> },
197 { value: "assistant", label: "Show assistant", group: "View", keywords: ["ai", "chat"], icon: <Sparkle data-slot="icon" weight="bold" /> },
198 ], [files]);
199 /* Quick Open's order: what was picked here first, then the open files (VS Code lists the
200 * recently opened files before the rest of the workspace) */
201 const [recent, setRecent] = useState<string[]>([]);
202 const recentShown = [...new Set([...recent, ...open.filter((t) => !t.startsWith(DIFF)).map((t) => `file:${t}`)])].slice(0, 5);
203 const run = (value: string) => {
204 setRecent((r) => [value, ...r.filter((v) => v !== value)].slice(0, 3));
205 if (value.startsWith("file:")) openFile(value.slice(5));
206 else if (value === "run-tests") runTests();
207 else if (value === "explorer" || value === "changes") showSide(value);
208 else if (value === "terminal" || value === "problems") showPanel(true, value);
209 else if (value === "assistant") { setSizes(sideSizes(sideOpen, true)); setPhoneView("assistant"); }
210 };
211 const onKeyDown = (e: KeyboardEvent) => {
212 if (!(e.ctrlKey || e.metaKey) || e.altKey) return;
213 const key = e.key.toLowerCase();
214 if (key === "k" || key === "p") { e.preventDefault(); e.stopPropagation(); setPalette(true); }
215 else if (key === "j") { e.preventDefault(); showPanel(!panelOpen); }
216 else if (key === "b") { e.preventDefault(); showSide(sideOpen ? null : side); }
217 };
218
219 /* ── the views ─────────────────────────────────────────── */
220
221 /* the pane is titled by its view; the project is the tree's own label, as VS Code's section */
222 const explorer = (
223 <div className="flex h-full min-w-0 flex-col bg-canvas" data-editor="explorer">
224 <div className={PANE_TITLE}>Explorer</div>
225 <ScrollArea className="min-h-0 flex-1">
226 <TreeView
227 className="px-1 pb-2" size="xs" label={PROJECT} items={FILE_TREE}
228 expandedValue={expanded} onExpandedValueChange={setExpanded}
229 selectedValue={diffOf ? [] : [activePath]}
230 onSelectedValueChange={(v) => v[0] && v[0] in files && openFile(v[0])}
231 />
232 </ScrollArea>
233 </div>
234 );
235
236 const sourceControl = (
237 <SourceControl changes={changes} selected={diffOf} branch={BRANCH} onSelect={openDiff} onCommit={commit} />
238 );
239
240 /* the editor: closable pill tabs in the pane's 32px header over a code view (no frame, no copy,
241 * no path; lines never wrap and the gutter stays while the code scrolls sideways). A strip with
242 * more files than room scrolls, fades its cut edge and lists every file in its menu */
243 const editorOf = (tab: string) => {
244 const path = pathOf(tab);
245 if (tab.startsWith(DIFF)) {
246 const change = changes.find((c) => c.path === path);
247 return <CodeView fill wrap={false} label={`${path} (working tree)`} diff={lineDiff(change?.before ?? files[path]!, files[path]!)} />;
248 }
249 return <CodeView fill wrap={false} label={path} value={files[path]!.join("\n")} currentLine={caret[path]} />;
250 };
251 const code = (
252 <div className="h-full bg-surface" data-editor="code">
253 {open.length ? (
254 <Tabs
255 variant="pill" closable fill inHeader headerClass="h-8 border-b border-line px-1" aria-label="Open files"
256 value={open.includes(active) ? active : open[0]} onValueChange={setActive} onClose={closeTab}
257 items={open.map((tab) => ({
258 value: tab,
259 label: tab.startsWith(DIFF) ? `${nameOf(pathOf(tab))} (working tree)` : nameOf(tab),
260 icon: tab.startsWith(DIFF) ? <GitBranch data-slot="icon" /> : fileIcon(tab),
261 content: editorOf(tab),
262 }))}
263 />
264 ) : (
265 <EmptyState className="h-full bg-surface" size="block" icon="file" title="No open files" hint={`${mod}+P opens one by name.`} />
266 )}
267 </div>
268 );
269
270 const errors = problems.filter((p) => p.severity === "error").length;
271 const warnings = problems.length - errors;
272 const problemTree: TreeViewNode[] = [...new Set(problems.map((p) => p.path))].map((path) => ({
273 value: path, label: nameOf(path), icon: <File />,
274 children: problems.filter((p) => p.path === path).map((p) => ({
275 value: p.value, label: `${p.message} [Ln ${p.line}, Col ${p.col}]`,
276 icon: p.severity === "error" ? <XCircle weight="fill" className="text-red" /> : <Warning className="text-orange" />,
277 })),
278 }));
279 const bottom = (
280 <div className="h-full bg-surface" data-editor="panel">
281 {/* fill: the panel under the strip takes the rest of the pane's height */}
282 <Tabs
283 fill variant="underline" inHeader headerClass="h-8 border-b border-line px-3 text-xs" aria-label="Panel"
284 value={panelTab} onValueChange={setPanelTab}
285 items={[
286 {
287 value: "terminal", label: "Terminal",
288 content: (
289 <ScrollArea className="h-full" data-editor="terminal">
290 <TerminalOutput lines={terminal} />
291 </ScrollArea>
292 ),
293 },
294 {
295 value: "problems",
296 label: <span className="flex items-center gap-1.5">Problems <Count size="sm">{String(problems.length)}</Count></span>,
297 content: (
298 <ScrollArea className="h-full" data-editor="problems">
299 {problems.length ? (
300 <TreeView
301 className="px-1 py-1" size="xs" aria-label="Problems" items={problemTree} expandedValue={problemTree.map((n) => n.value)}
302 selectedValue={[]}
303 onSelectedValueChange={(v) => { const p = problems.find((x) => x.value === v[0]); if (p) openFile(p.path, p.line); }}
304 />
305 ) : (
306 <EmptyState size="row" title="No problems in the workspace" />
307 )}
308 </ScrollArea>
309 ),
310 },
311 ]}
312 />
313 </div>
314 );
315
316 const assistant = <Assistant file={activePath} onApply={applyFix} onOpenDiff={openDiff} />;
317
318 /* the system's command palette; Ctrl/⌘ K and P are bound on the app's root (onKeyDown), so they
319 * work while the app has focus and leave the page's own ⌘K alone */
320 const paletteDialog = (
321 <CommandPalette
322 items={commands} recent={recentShown} limit={8} hotkey={false}
323 open={palette} onOpenChange={setPalette} onSelect={run}
324 label="Go to a file or run a command" placeholder="Go to a file or run a command…"
325 emptyTitle="Nothing matches" emptyHint="Try a file name, or a command such as Run tests."
326 />
327 );
328
329 /* ── phone: one view at a time ──────────────────────────── */
330 const views: Record<string, ReactNode> = { files: explorer, code, changes: sourceControl, panel: bottom, assistant };
331 const phoneLayout = (
332 <>
333 <header className="flex h-11 shrink-0 items-center gap-2 border-b border-line ps-3 pe-1.5">
334 <span className="min-w-0 flex-1 truncate text-sm font-semibold" title={`${PROJECT} · ${BRANCH}`}>{PROJECT}</span>
335 <Button variant="ghost" size="sm" square muted aria-label="Go to a file or run a command" icon={<MagnifyingGlass data-slot="icon" weight="bold" />} onClick={() => setPalette(true)} />
336 </header>
337 <div className="min-h-0 flex-1">{views[phoneView]}</div>
338 <nav aria-label="Views" className="shrink-0 border-t border-line p-2">
339 <SegmentedControl
340 fill size="md" aria-label="View" value={phoneView} onValueChange={setPhoneView}
341 options={[{ value: "files", label: "Files" }, { value: "code", label: "Code" }, { value: "changes", label: "Git" }, { value: "panel", label: "Terminal" }, { value: "assistant", label: "AI" }]}
342 />
343 </nav>
344 </>
345 );
346
347 /* ── desktop ───────────────────────────────────────────── */
348 const sideViews = [
349 { value: "explorer" as const, label: `Explorer (${mod}+B)`, Icon: Folder },
350 { value: "changes" as const, label: `Source control, ${changes.length === 1 ? "1 change" : `${changes.length} changes`}`, Icon: GitBranch },
351 ];
352 const desktopLayout = (
353 <>
354 {/* the title bar: the command center in the middle, the layout toggles at the end */}
355 <header className="grid h-9 shrink-0 grid-cols-[1fr_minmax(0,18rem)_1fr] items-center gap-3 border-b border-line bg-canvas px-2">
356 <span />
357 <span className="relative flex">
358 <Button variant="outline" size="sm" className="w-full justify-start pe-16 text-ink-3" icon={<MagnifyingGlass data-slot="icon" weight="bold" />} aria-keyshortcuts="Control+K Meta+K Control+P Meta+P" onClick={() => setPalette(true)} data-editor="palette-button">
359 Go to file or command
360 </Button>
361 <span className="pointer-events-none absolute inset-y-0 end-1.5 flex items-center" aria-hidden><Kbd keys={[mod, "K"]} /></span>
362 </span>
363 <span className="flex justify-end gap-0.5">
364 <Toggle variant="ghost" size="sm" square muted tooltip={`Panel (${mod}+J)`} pressed={panelOpen} onPressedChange={(on) => showPanel(on)} icon={<Terminal data-slot="icon" weight="bold" />} />
365 <Toggle variant="ghost" size="sm" square muted tooltip="Assistant" pressed={assistantOpen} onPressedChange={(on) => setSizes(sideSizes(sideOpen, on))} icon={<Sparkle data-slot="icon" weight="bold" />} />
366 </span>
367 </header>
368
369 <div className="flex min-h-0 flex-1">
370 {/* the activity bar: muted ghost toggles; the open view keeps the pressed fill */}
371 <nav aria-label="Side views" className="flex w-11 shrink-0 flex-col items-center gap-1 border-e border-line bg-canvas py-1.5">
372 <div role="toolbar" aria-orientation="vertical" aria-label="Side view" className="flex flex-col items-center gap-1">
373 {sideViews.map(({ value, label, Icon }) => (
374 <Toggle
375 key={value} data-value={value} variant="ghost" size="md" square muted tooltip={label}
376 pressed={sideOpen && side === value}
377 onPressedChange={(on) => showSide(on ? value : null)}
378 icon={<Icon data-slot="icon" weight="bold" />}
379 />
380 ))}
381 </div>
382 </nav>
383 <Splitter
384 className="min-w-0 flex-1" handleLabel="Resize the side views" size={sizes} onSizeChange={setSizes}
385 panels={[
386 { id: "side", minSize: 14, maxSize: 40, collapsible: true, content: sideOpen && (side === "explorer" ? explorer : sourceControl) },
387 {
388 id: "main", minSize: 30,
389 content: (
390 <Splitter
391 orientation="vertical" handleLabel="Resize the panel" size={rows} onSizeChange={setRows}
392 panels={[
393 { id: "editor", minSize: 30, content: code },
394 { id: "bottom", minSize: 15, collapsible: true, content: panelOpen && bottom },
395 ]}
396 />
397 ),
398 },
399 { id: "assistant", minSize: 22, maxSize: 45, collapsible: true, content: assistantOpen && assistant },
400 ]}
401 />
402 </div>
403
404 <footer className="flex h-6 shrink-0 items-center gap-3 border-t border-line bg-canvas px-2 text-xs text-ink-2" data-editor="status">
405 <span className="flex items-center gap-1"><GitBranch weight="bold" aria-hidden />{BRANCH}{ahead > 0 && ` ↑${ahead}`}</span>
406 <Button variant="ghost" size="xs" muted onClick={() => showPanel(true, "problems")} aria-label={`${errors} errors, ${warnings} warnings: show problems`}>
407 <span className="flex items-center gap-1 tabular-nums"><XCircle weight="fill" className={errors ? "text-red" : undefined} aria-hidden />{errors}<Warning weight="bold" className="ms-1.5" aria-hidden />{warnings}</span>
408 </Button>
409 {/* the test result as VS Code's status bar shows it: ink text after a glyph in its tone (a
410 * pill belongs in content); a press shows the run in the terminal */}
411 <Button variant="ghost" size="xs" muted onClick={() => showPanel(true, "terminal")} aria-label={`${passing ? "Tests passing" : "1 test failing"}: show the terminal`}>
412 <span className="flex items-center gap-1">
413 {passing ? <CheckCircle weight="fill" className="text-green" aria-hidden /> : <XCircle weight="fill" className="text-red" aria-hidden />}
414 {passing ? "Tests passing" : "1 test failing"}
415 </span>
416 </Button>
417 <span className="ms-auto flex items-center gap-3">
418 <span className="[unicode-bidi:plaintext]">{caret[activePath] ? `Ln ${caret[activePath]}` : `${(files[activePath] ?? []).length} lines`}</span>
419 <span className="[unicode-bidi:plaintext]">Spaces: 2</span>
420 <span>UTF-8</span>
421 <span>{language(activePath)}</span>
422 </span>
423 </footer>
424 </>
425 );
426
427 return (
428 <div ref={root} tabIndex={-1} onKeyDown={onKeyDown} className="flex h-full flex-col bg-page text-ink outline-none" data-editor="root" data-layout={phone ? "phone" : "desktop"}>
429 {phone ? phoneLayout : desktopLayout}
430 {paletteDialog}
431 </div>
432 );
433}