mirror of
https://github.com/hanzoai/ui.git
synced 2026-11-21 03:26:04 +00:00
build-v2's editor (MIT, from OSW Studio and DeepSite; attribution in NOTICE) as presentation with the data and the transport handed back to the host: Workspace and its bar (Views, ProjectChip, PageSelect), PreviewFrame, FileTree, FileTabs, Console, ModeSelect, Suggestions, Attachments and Feedback, with tree, log and bridge as their pure halves. The preview frames an http(s) address in a sandbox that never allows top navigation and grants its own origin only to a foreign page; the element bridge is opt-in, origin-pinned on both sides. Every file, path, log line and picked element renders as text. CodeEditor gains an accessible label, and the axe helper stops at frames, which are another document. Co-authored-by: Hanzo Dev <[email protected]>
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { useState } from 'react'
|
|
import { YStack } from '@hanzo/gui'
|
|
import { FileTree, type Entry } from '@hanzo/ui/agents'
|
|
|
|
const FILES = ['src/app.tsx', 'src/lib/api.ts', 'src/lib/auth.ts', 'public/logo.svg', 'package.json', 'README.md']
|
|
|
|
/** Flat — every path at once; the folders are the ones the paths imply, folders first. */
|
|
export function Flat() {
|
|
const [file, setFile] = useState<string | null>('src/lib/api.ts')
|
|
return (
|
|
<YStack width={280} height={260} borderWidth={1} borderColor="$borderColor" rounded="$4">
|
|
<FileTree files={FILES} value={file} onSelect={setFile} />
|
|
</YStack>
|
|
)
|
|
}
|
|
|
|
/** Lazy — one directory per call, the way a repository answers, read the first time a folder opens. */
|
|
export function Lazy() {
|
|
const load = async (dir: string): Promise<Entry[]> => {
|
|
await new Promise((r) => setTimeout(r, 300))
|
|
if (dir === '') return [{ path: 'cmd', kind: 'dir' }, { path: 'go.mod', kind: 'file' }]
|
|
if (dir === 'cmd') return [{ path: 'cmd/server', kind: 'dir' }]
|
|
return [{ path: `${dir}/main.go`, kind: 'file' }]
|
|
}
|
|
return (
|
|
<YStack width={280} height={220} borderWidth={1} borderColor="$borderColor" rounded="$4">
|
|
<FileTree load={load} />
|
|
</YStack>
|
|
)
|
|
}
|