diff --git a/biome.json b/biome.json index 1e75750..43ceb67 100644 --- a/biome.json +++ b/biome.json @@ -1,7 +1,7 @@ { "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", "vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true }, - "files": { "includes": ["**", "!src/components/ui"] }, + "files": { "includes": ["**", "!src/components/ui", "!.claude"] }, "formatter": { "indentStyle": "space", "indentWidth": 2, "lineWidth": 110 }, "javascript": { "formatter": { "quoteStyle": "single" } }, "css": { "parser": { "tailwindDirectives": true } }, diff --git a/package.json b/package.json index 8f88c3e..e36b166 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,8 @@ "format": "biome check --write ." }, "dependencies": { + "@fontsource-variable/geist-mono": "^5.3.0", + "@fontsource-variable/inter": "^5.3.0", "@holistics/anfra-sdk": "0.14.2", "@hono/node-server": "^2.1.4", "class-variance-authority": "^0.7.1", @@ -34,6 +36,7 @@ "react-dom": "^19.3.0", "react-resizable-panels": "^4.14.4", "tailwind-merge": "^3.7.0", + "tw-animate-css": "^1.4.0", "yaml": "^2.9.1" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cd6e962..7a0c891 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,12 @@ importers: .: dependencies: + '@fontsource-variable/geist-mono': + specifier: ^5.3.0 + version: 5.3.0 + '@fontsource-variable/inter': + specifier: ^5.3.0 + version: 5.3.0 '@holistics/anfra-sdk': specifier: 0.14.2 version: 0.14.2(esbuild@0.28.2) @@ -44,6 +50,9 @@ importers: tailwind-merge: specifier: ^3.7.0 version: 3.7.0 + tw-animate-css: + specifier: ^1.4.0 + version: 1.4.0 yaml: specifier: ^2.9.1 version: 2.9.1 @@ -315,6 +324,12 @@ packages: '@floating-ui/utils@0.2.12': resolution: {integrity: sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==} + '@fontsource-variable/geist-mono@5.3.0': + resolution: {integrity: sha512-vBbuwDEo9AkrqADMXOrlAR3DFcJi4/JxeuU43FoiQERnNwsfXNnvxvReZG02cQKmyk4DZkZdBZX3oTDvy2zBAw==} + + '@fontsource-variable/inter@5.3.0': + resolution: {integrity: sha512-OupL48va4JNofb97w6NYeF9S7W/kHNKM0Er8Dem5nqi4jeOLrVJDoE8tZEpnMJmtkvNbB1EIPPwHcdkF6b1oUA==} + '@holistics/anfra-sdk@0.14.2': resolution: {integrity: sha512-TcwOYNhpbZAYevd8vTuiEIKFrvkKnysVC6ZDNmNBwjLGaD8dkkoFZDtZINecTUZ95qL9vRRQHdk1YlhIBoGiZQ==} peerDependencies: @@ -1656,6 +1671,9 @@ packages: engines: {node: '>=18.0.0'} hasBin: true + tw-animate-css@1.4.0: + resolution: {integrity: sha512-7bziOlRqH0hJx80h/3mbicLW7o8qLsH5+RaLR2t+OHM3D0JlWGODQKQ4cxbK7WlvmUxpcj6Kgu6EKqjrGFe3QQ==} + typescript@5.9.3: resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} engines: {node: '>=14.17'} @@ -1880,6 +1898,10 @@ snapshots: '@floating-ui/utils@0.2.12': {} + '@fontsource-variable/geist-mono@5.3.0': {} + + '@fontsource-variable/inter@5.3.0': {} + '@holistics/anfra-sdk@0.14.2(esbuild@0.28.2)': dependencies: openapi-fetch: 0.17.0 @@ -3192,6 +3214,8 @@ snapshots: optionalDependencies: fsevents: 2.3.3 + tw-animate-css@1.4.0: {} + typescript@5.9.3: {} undici-types@8.9.0: {} diff --git a/src/App.tsx b/src/App.tsx index 0026825..27285b6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,9 +1,11 @@ -import { Ellipsis, RotateCw } from 'lucide-react'; +import { CircleAlert, Ellipsis, Info, LoaderCircle, RotateCw } from 'lucide-react'; import { type CSSProperties, useCallback, useEffect, useRef, useState } from 'react'; +import { AppIcon, EndorsedMark } from '@/components/app-icon'; import { AppInfo } from '@/components/app-info'; import { AppSidebar } from '@/components/app-sidebar'; import { CommandPalette } from '@/components/command-palette'; import { DataAppStage } from '@/components/data-app-stage'; +import { ErrorAlert } from '@/components/error-alert'; import { Home } from '@/components/home'; import { PluginPanel } from '@/components/plugin-panel'; import { PromptPanel } from '@/components/prompt-panel'; @@ -18,18 +20,19 @@ import { } from '@/components/ui/dropdown-menu'; import { Kbd, KbdGroup } from '@/components/ui/kbd'; import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@/components/ui/resizable'; -import { Separator } from '@/components/ui/separator'; import { SidebarInset, SidebarProvider, SidebarTrigger } from '@/components/ui/sidebar'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'; import { VersionsPanel } from '@/components/versions-panel'; import { type Command, type DatasetDescriptor, + designTheme, loadCatalog, type Mounted, type Rendering, setPluginTheme, } from '@/data-app'; +import { isPlainClick } from '@/lib/click'; import { chromeCommands, commandIcon, commandIcons } from '@/lib/commands'; import { catalog, @@ -104,24 +107,12 @@ export function App() { void refreshDatasets(); }, [refreshCatalog, refreshDatasets]); - // The plugins' UI (the panel's tabs, the menu and card in the frame) follows the page's theme. + // The plugins' UI (the panel's tabs, the menu and card in the frame) follows the page's theme: the SDK + // reads each token from the anfra-design property on the page (re-run when the scheme changes). useEffect(() => { - const style = getComputedStyle(document.documentElement); - const read = (name: string) => style.getPropertyValue(name).trim() || undefined; - setPluginTheme({ - scheme: theme, - tokens: { - 'color-bg': read('--background'), - 'color-fg': read('--foreground'), - 'color-muted': read('--muted-foreground'), - 'color-border': read('--border'), - // The neutral theme has no accent colour; links and selection in the tabs take indigo. - 'color-accent': theme === 'dark' ? '#a5b4fc' : '#4f46e5', - 'color-danger': read('--destructive'), - radius: read('--radius'), - font: getComputedStyle(document.body).fontFamily || undefined, - }, - }); + setPluginTheme( + designTheme(theme === 'dark' ? 'dark' : 'light', getComputedStyle(document.documentElement)), + ); }, [theme]); // Deep links: the address follows the open Data App, and back and forward follow the address. @@ -271,13 +262,13 @@ export function App() { let content: React.ReactNode; if (error) { - content = {error}; + content = {error}; } else if (!path) { - content = entries ? : Loading…; + content = entries ? : ; } else if (entries && !app) { - content = moved ? Loading… : No Data App at {path}.; + content = moved ? : select('')} />; } else if (!datasets || !app) { - content = Loading…; + content = ; } else { content = ( - -
+ +
@@ -308,11 +299,17 @@ export function App() { - -

{app?.label ?? 'anfra demo'}

+ {app && } + {/* An app's name is the page's heading; elsewhere the bar is navigation, and the page has its own. */} + {app ? ( +

{app.label}

+ ) : ( + anfra demo + )} + {app?.endorsed && } {app && } {path && ( -
+
setRevision((n) => n + 1)}> @@ -355,7 +352,6 @@ export function App() { onClick={() => !state.disabled && run(command)} text={textOf(command)} shortcut={command.shortcut} - className={cn(state.disabled && 'cursor-not-allowed opacity-50')} > @@ -450,19 +446,59 @@ function ToastMessage({ toast, onDone }: { toast: Toast; onDone: () => void }) {
- {toast.text} + {toast.tone === 'error' ? ( + + ) : ( + + )} + {toast.text} +
+ ); +} + +/** Something on its way: the stage's spinner, as anfra Cloud's. */ +function Loading() { + return ( +
+
); } -function Message({ children }: { children: React.ReactNode }) { - return
{children}
; +/** A link to a Data App that isn't in the repo. */ +function Missing({ path, onHome }: { path: string; onHome: () => void }) { + return ( + + ); +} + +/** The page's own failure, as a danger alert at the top of the stage. */ +function ErrorMessage({ children }: { children: React.ReactNode }) { + return ( +
+ {children} +
+ ); } /** An icon button; with `text` it carries a visible label beside the icon, and with `shortcut` its tooltip shows the keys to press. */ @@ -481,9 +517,9 @@ function ToolbarButton({ - - {app.description &&

{app.description}

} + + {app.description &&

{app.description}

} - {app.path} + {app.path} {app.endorsed && ( - Endorsed + Endorsed )} @@ -45,7 +45,9 @@ export function AppInfo({ app }: { app: App }) { function Row({ label, children }: { label: string; children: ReactNode }) { return (
- {label} + + {label} + {children}
); diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsx index 38efbef..518da12 100644 --- a/src/components/app-sidebar.tsx +++ b/src/components/app-sidebar.tsx @@ -1,10 +1,9 @@ import { ChevronRight, Folder } from 'lucide-react'; import { type MouseEvent, useEffect, useRef, useState } from 'react'; import { AnfraStatus } from '@/components/anfra-status'; -import { AppIcon } from '@/components/app-icon'; +import { AppIcon, EndorsedMark } from '@/components/app-icon'; import { SidebarResizer } from '@/components/sidebar-resizer'; import { ThemeToggle } from '@/components/theme-toggle'; -import { Badge } from '@/components/ui/badge'; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'; import { Input } from '@/components/ui/input'; import { Kbd, KbdGroup } from '@/components/ui/kbd'; @@ -22,6 +21,7 @@ import { SidebarMenuSub, useSidebar, } from '@/components/ui/sidebar'; +import { isPlainClick } from '@/lib/click'; import { type Entry, type FolderEntry, filterEntries, foldersOf, urlOf } from '@/lib/host'; import { iconOf } from '@/lib/icons'; import { onShell } from '@/lib/shell'; @@ -125,14 +125,23 @@ export function AppSidebar({ entries, selected, onSelect }: Props) { (searching ? setSearched : setBrowsed)((prev) => ({ ...prev, [path]: open })); return ( + {/* The logomark, then the way home: anfra Cloud's org row. The mark is never set beside a typed "anfra". */} - - - anfra - - demo - - + + + + + anfra + Demo + + + + {/* On desktop, reach over the inset padding, so the scrollbar sits on the edge and the gap is inside it. */} @@ -173,16 +182,16 @@ export function AppSidebar({ entries, selected, onSelect }: Props) { /> ))} {entries?.length === 0 && ( -

No Data Apps in the repo's apps folder.

+

No Data Apps in the repo's apps folder

)} {entries && entries.length > 0 && shown?.length === 0 && ( -

Nothing matches.

+

Nothing matches

)}
- + @@ -201,24 +210,17 @@ function Item({ entry, selected, onSelect, isOpen, onToggle }: ItemProps) { if (entry.kind === 'app') { // A real link, so it opens in a new tab too; a plain click stays in the page. const onClick = (event: MouseEvent) => { - if (event.metaKey || event.ctrlKey || event.shiftKey || event.button !== 0) return; + if (!isPlainClick(event)) return; event.preventDefault(); onSelect(entry.path); }; return ( - + - - {entry.label} + + {entry.label} + {entry.endorsed && } @@ -234,7 +236,7 @@ function Item({ entry, selected, onSelect, isOpen, onToggle }: ItemProps) { > - + {entry.name} diff --git a/src/components/command-palette.tsx b/src/components/command-palette.tsx index 4befe48..de38be0 100644 --- a/src/components/command-palette.tsx +++ b/src/components/command-palette.tsx @@ -59,7 +59,7 @@ export function CommandPalette({ > - Nothing matches. + Nothing matches {app && ( @@ -78,8 +78,8 @@ export function CommandPalette({ > {command.title} - {state.pressed && On} - {state.disabled && {state.disabled}} + {state.pressed && On} + {state.disabled && {state.disabled}} {command.shortcut && } ); @@ -109,8 +109,12 @@ export function CommandPalette({ onSelect={run(() => onSelect(entry.path))} > - {entry.label} - {folder && {folder}} + {entry.label} + {folder && ( + + {folder} + + )} ); })} diff --git a/src/components/data-app-stage.tsx b/src/components/data-app-stage.tsx index adb7d51..b038989 100644 --- a/src/components/data-app-stage.tsx +++ b/src/components/data-app-stage.tsx @@ -1,4 +1,5 @@ import { useEffect, useRef, useState } from 'react'; +import { ErrorAlert } from '@/components/error-alert'; import { type DatasetDescriptor, type Mounted, mount } from '@/data-app'; interface Props { @@ -49,8 +50,8 @@ export function DataAppStage({ path, label, datasets, onMount }: Props) {
{error && ( -
- {error} +
+ {error}
)}
diff --git a/src/components/error-alert.tsx b/src/components/error-alert.tsx new file mode 100644 index 0000000..58e1136 --- /dev/null +++ b/src/components/error-alert.tsx @@ -0,0 +1,14 @@ +import { CircleAlert } from 'lucide-react'; + +/** The page's own failure, as a danger alert. */ +export function ErrorAlert({ children }: { children: React.ReactNode }) { + return ( +
+ +

{children}

+
+ ); +} diff --git a/src/components/home.tsx b/src/components/home.tsx index c283fa3..4d52972 100644 --- a/src/components/home.tsx +++ b/src/components/home.tsx @@ -1,7 +1,8 @@ import { ChevronRight, Folder } from 'lucide-react'; import type { MouseEvent } from 'react'; -import { AppIcon } from '@/components/app-icon'; +import { AppIcon, EndorsedMark } from '@/components/app-icon'; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'; +import { isPlainClick } from '@/lib/click'; import { type AppEntry, type Entry, urlOf } from '@/lib/host'; import { iconOf } from '@/lib/icons'; @@ -53,14 +54,16 @@ export function Home({ entries, onSelect }: Props) { const groups = categories(entries, '', ''); if (groups.length === 0) { return ( -
- No Data Apps in the repo's apps folder. +
+

No Data Apps yet

+

The repo's apps folder has none

); } return ( -
-
+
+
+

Data Apps

{groups.map((group) => ( ))} @@ -74,15 +77,15 @@ function Group({ group, onSelect }: { group: Category; onSelect: (path: string) return (
- - - + + + {group.name || 'Apps'} - {group.apps.length} + {group.apps.length} {group.description && ( -

{group.description}

+

{group.description}

)}
{group.apps.map((app) => ( @@ -98,7 +101,7 @@ function Group({ group, onSelect }: { group: Category; onSelect: (path: string) function AppCard({ app, onSelect }: { app: AppEntry; onSelect: (path: string) => void }) { // A real link, so it opens in a new tab too; a plain click stays in the page. const onClick = (event: MouseEvent) => { - if (event.metaKey || event.ctrlKey || event.shiftKey || event.button !== 0) return; + if (!isPlainClick(event)) return; event.preventDefault(); onSelect(app.path); }; @@ -106,26 +109,23 @@ function AppCard({ app, onSelect }: { app: AppEntry; onSelect: (path: string) => {app.image && ( )} - - + + - {app.label} - {app.path} + {app.label} + {app.path} + {app.endorsed && } ); diff --git a/src/components/plugin-panel.tsx b/src/components/plugin-panel.tsx index ba9b908..8ba3b94 100644 --- a/src/components/plugin-panel.tsx +++ b/src/components/plugin-panel.tsx @@ -90,7 +90,7 @@ export function PluginPanel({ panel, tabs, commands, stateOf, onRun }: Props) { return (
-
-
+
+
{blocksOf(prompt.prompt)}