feat(web): React 19 + Vite + Tailwind v4 + shadcn foundation
- design tokens ported verbatim from the product design, data-theme light/dark - app shell: topbar, sidebar/rail/tabbar responsive nav, lang + theme menus - ui primitives (button/card/badge/dot/chip/tabs/dialog/sheet/toast/kv/seg/progress) - api client, reconnecting ws client, zustand stores, route guard to /connect - full zh/en dictionaries (key parity test), 32 vitest specs, dist committed
This commit is contained in:
1 parent
4e98ef8658
commit
5b55e622ea
63 files changed
+8466
No files matched your search
@@ -0,0 +1,178 @@
|
||||
import { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Icon, type IconName } from "@/components/icons";
|
||||
import { LangMenu } from "@/components/shared/lang-menu";
|
||||
import { ServerChip } from "@/components/shared/server-chip";
|
||||
import { ThemeMenu } from "@/components/shared/theme-menu";
|
||||
import { SidebarItem } from "@/components/ui/sidebar-item";
|
||||
import { api } from "@/lib/api";
|
||||
import { useConnectionStore } from "@/stores/connection";
|
||||
import { useSessionsStore } from "@/stores/sessions";
|
||||
import { useWorkspacesStore } from "@/stores/workspaces";
|
||||
import { Link, Outlet, useRouterState } from "@tanstack/react-router";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
interface NavItem {
|
||||
to: "/workspaces" | "/chat" | "/status";
|
||||
labelKey: string;
|
||||
icon: IconName;
|
||||
match: (pathname: string) => boolean;
|
||||
}
|
||||
|
||||
const NAV: NavItem[] = [
|
||||
{
|
||||
to: "/workspaces",
|
||||
labelKey: "nav.workspaces",
|
||||
icon: "folder",
|
||||
match: (p) => p === "/workspaces" || p.startsWith("/workspace/"),
|
||||
},
|
||||
{ to: "/chat", labelKey: "nav.chat", icon: "chat", match: (p) => p.startsWith("/chat") },
|
||||
{ to: "/status", labelKey: "nav.status", icon: "status", match: (p) => p.startsWith("/status") },
|
||||
];
|
||||
|
||||
function pageName(pathname: string): string {
|
||||
if (pathname.startsWith("/connect")) return "connect";
|
||||
if (pathname.startsWith("/status")) return "status";
|
||||
if (pathname.startsWith("/chat")) return "chat";
|
||||
return "workspaces";
|
||||
}
|
||||
|
||||
function RouteTitle({ pathname }: { pathname: string }) {
|
||||
const { t } = useTranslation();
|
||||
const server = useConnectionStore((state) => state.server);
|
||||
const workspaces = useWorkspacesStore((state) => state.items);
|
||||
const selectedSession = useSessionsStore((state) =>
|
||||
pathname.startsWith("/chat/") ? state.getSession(decodeURIComponent(pathname.slice("/chat/".length))) : undefined,
|
||||
);
|
||||
|
||||
const workspaceId = pathname.startsWith("/workspace/")
|
||||
? decodeURIComponent(pathname.slice("/workspace/".length))
|
||||
: selectedSession?.workspaceId;
|
||||
const workspace = workspaces.find((w) => w.workspaceId === workspaceId);
|
||||
|
||||
let crumbs: string[] = [];
|
||||
let title = t("nav.workspaces");
|
||||
|
||||
if (pathname.startsWith("/connect")) {
|
||||
title = t("connect.title");
|
||||
} else if (pathname.startsWith("/status")) {
|
||||
crumbs = server?.name ? [server.name] : [];
|
||||
title = t("nav.status");
|
||||
} else if (pathname === "/chat") {
|
||||
title = t("nav.chat");
|
||||
} else if (pathname.startsWith("/chat/")) {
|
||||
crumbs = workspace?.name ? [workspace.name] : [];
|
||||
title = selectedSession?.name ?? decodeURIComponent(pathname.slice("/chat/".length));
|
||||
} else if (pathname.startsWith("/workspace/")) {
|
||||
crumbs = [t("nav.workspaces")];
|
||||
title = workspace?.name ?? workspaceId ?? pathname;
|
||||
} else {
|
||||
crumbs = server?.name ? [server.name] : [];
|
||||
title = t("nav.workspaces");
|
||||
}
|
||||
|
||||
const parts = [...crumbs, title].filter((part): part is string => Boolean(part));
|
||||
return (
|
||||
<nav className="crumbs" aria-label={t("shell.navLabel")}>
|
||||
{parts.map((part, index) => {
|
||||
const last = index === parts.length - 1;
|
||||
return (
|
||||
<span key={`${part}-${index}`} className="contents">
|
||||
{index > 0 ? <span className="sep">/</span> : null}
|
||||
<span className={last ? "truncate" : undefined}>{part}</span>
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
function NavLinks({ pathname }: { pathname: string }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<>
|
||||
{NAV.map((item) => (
|
||||
<SidebarItem key={item.to} active={item.match(pathname)} asChild>
|
||||
<Link to={item.to}>
|
||||
<Icon name={item.icon} />
|
||||
<span>{t(item.labelKey)}</span>
|
||||
</Link>
|
||||
</SidebarItem>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function AppShell() {
|
||||
const { t } = useTranslation();
|
||||
const pathname = useRouterState({ select: (state) => state.location.pathname });
|
||||
const paired = useConnectionStore((state) => state.paired);
|
||||
const setServer = useConnectionStore((state) => state.setServer);
|
||||
const isConnect = pathname.startsWith("/connect");
|
||||
const page = pageName(pathname);
|
||||
|
||||
const info = useQuery({
|
||||
queryKey: ["info"],
|
||||
queryFn: ({ signal }) => api.info(signal),
|
||||
enabled: paired && !isConnect,
|
||||
staleTime: 30_000,
|
||||
retry: 1,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (info.data) setServer(info.data);
|
||||
}, [info.data, setServer]);
|
||||
|
||||
useEffect(() => {
|
||||
document.body.dataset.page = page;
|
||||
}, [page]);
|
||||
|
||||
return (
|
||||
<div className="shell bg-background text-foreground">
|
||||
<header className="topbar">
|
||||
<Link to="/workspaces" className="brand">
|
||||
<img
|
||||
className="brand__logo"
|
||||
src="/pi2-nvim.png"
|
||||
alt=""
|
||||
width={24}
|
||||
height={24}
|
||||
decoding="async"
|
||||
/>
|
||||
<span className="brand__text">pi2.nvim</span>
|
||||
</Link>
|
||||
<RouteTitle pathname={pathname} />
|
||||
<div className="spacer" />
|
||||
<div className="actions">
|
||||
{isConnect ? null : <ServerChip />}
|
||||
<LangMenu />
|
||||
<ThemeMenu />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className="body">
|
||||
{isConnect ? null : (
|
||||
<>
|
||||
<aside className="sidebar">
|
||||
<div className="nav-label">{t("shell.navLabel")}</div>
|
||||
<NavLinks pathname={pathname} />
|
||||
</aside>
|
||||
<aside className="rail">
|
||||
<NavLinks pathname={pathname} />
|
||||
</aside>
|
||||
</>
|
||||
)}
|
||||
<main className="main">
|
||||
<Outlet />
|
||||
</main>
|
||||
</div>
|
||||
|
||||
{isConnect ? null : (
|
||||
<nav className="tabbar">
|
||||
<NavLinks pathname={pathname} />
|
||||
</nav>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
import {
|
||||
Activity,
|
||||
Ban,
|
||||
Boxes,
|
||||
Check,
|
||||
ChevronDown,
|
||||
ChevronRight,
|
||||
Circle,
|
||||
Clock,
|
||||
Copy,
|
||||
Cpu,
|
||||
Eye,
|
||||
File,
|
||||
Folder,
|
||||
GitBranch,
|
||||
Globe,
|
||||
HardDrive,
|
||||
Laptop,
|
||||
LayoutGrid,
|
||||
ListTodo,
|
||||
MemoryStick,
|
||||
MessageSquare,
|
||||
Monitor,
|
||||
Moon,
|
||||
MoreHorizontal,
|
||||
Pencil,
|
||||
Play,
|
||||
Plug,
|
||||
Plus,
|
||||
QrCode,
|
||||
RefreshCw,
|
||||
ScanLine,
|
||||
Search,
|
||||
Send,
|
||||
Server,
|
||||
Settings,
|
||||
Smartphone,
|
||||
Square,
|
||||
Sun,
|
||||
Tablet,
|
||||
Terminal,
|
||||
Trash2,
|
||||
TriangleAlert,
|
||||
X,
|
||||
Zap,
|
||||
} from "lucide-react";
|
||||
import type { ComponentType } from "react";
|
||||
|
||||
export type IconName =
|
||||
| "logo"
|
||||
| "server"
|
||||
| "plus"
|
||||
| "scan"
|
||||
| "qr"
|
||||
| "folder"
|
||||
| "chat"
|
||||
| "status"
|
||||
| "search"
|
||||
| "chevron-down"
|
||||
| "chevron-right"
|
||||
| "send"
|
||||
| "stop"
|
||||
| "x"
|
||||
| "check"
|
||||
| "alert"
|
||||
| "clock"
|
||||
| "cpu"
|
||||
| "mem"
|
||||
| "disk"
|
||||
| "model"
|
||||
| "phone"
|
||||
| "laptop"
|
||||
| "tablet"
|
||||
| "copy"
|
||||
| "revoke"
|
||||
| "refresh"
|
||||
| "play"
|
||||
| "terminal"
|
||||
| "todo"
|
||||
| "branch"
|
||||
| "eye"
|
||||
| "edit"
|
||||
| "trash"
|
||||
| "more"
|
||||
| "settings"
|
||||
| "sun"
|
||||
| "moon"
|
||||
| "monitor"
|
||||
| "dot"
|
||||
| "globe"
|
||||
| "plug"
|
||||
| "file"
|
||||
| "zap";
|
||||
|
||||
type IconComponent = ComponentType<{ size?: number | string; strokeWidth?: number; className?: string; "aria-hidden"?: boolean }>;
|
||||
|
||||
/** 1:1 name map for the prototype's `App.icon(name)` (Lucide, 24 viewBox, stroke 1.75). */
|
||||
const ICONS: Record<IconName, IconComponent> = {
|
||||
logo: LayoutGrid,
|
||||
server: Server,
|
||||
plus: Plus,
|
||||
scan: ScanLine,
|
||||
qr: QrCode,
|
||||
folder: Folder,
|
||||
chat: MessageSquare,
|
||||
status: Activity,
|
||||
search: Search,
|
||||
"chevron-down": ChevronDown,
|
||||
"chevron-right": ChevronRight,
|
||||
send: Send,
|
||||
stop: Square,
|
||||
x: X,
|
||||
check: Check,
|
||||
alert: TriangleAlert,
|
||||
clock: Clock,
|
||||
cpu: Cpu,
|
||||
mem: MemoryStick,
|
||||
disk: HardDrive,
|
||||
model: Boxes,
|
||||
phone: Smartphone,
|
||||
laptop: Laptop,
|
||||
tablet: Tablet,
|
||||
copy: Copy,
|
||||
revoke: Ban,
|
||||
refresh: RefreshCw,
|
||||
play: Play,
|
||||
terminal: Terminal,
|
||||
todo: ListTodo,
|
||||
branch: GitBranch,
|
||||
eye: Eye,
|
||||
edit: Pencil,
|
||||
trash: Trash2,
|
||||
more: MoreHorizontal,
|
||||
settings: Settings,
|
||||
sun: Sun,
|
||||
moon: Moon,
|
||||
monitor: Monitor,
|
||||
dot: Circle,
|
||||
globe: Globe,
|
||||
plug: Plug,
|
||||
file: File,
|
||||
zap: Zap,
|
||||
};
|
||||
|
||||
export interface IconProps {
|
||||
name: IconName;
|
||||
size?: number;
|
||||
strokeWidth?: number;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function Icon({ name, size = 16, strokeWidth = 1.75, className }: IconProps) {
|
||||
const Component = ICONS[name] ?? Circle;
|
||||
return <Component size={size} strokeWidth={strokeWidth} className={className} aria-hidden={true} />;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Modal } from "@/components/ui/dialog";
|
||||
|
||||
export interface ConfirmDialogProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
title: string;
|
||||
description?: string;
|
||||
confirmLabel?: string;
|
||||
cancelLabel?: string;
|
||||
danger?: boolean;
|
||||
onConfirm: () => void | Promise<void>;
|
||||
}
|
||||
|
||||
/** Destructive-action confirmation (base.css modal + two actions). */
|
||||
export function ConfirmDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
title,
|
||||
description,
|
||||
confirmLabel,
|
||||
cancelLabel,
|
||||
danger = true,
|
||||
onConfirm,
|
||||
}: ConfirmDialogProps) {
|
||||
const { t } = useTranslation();
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
async function confirm() {
|
||||
if (busy) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
await onConfirm();
|
||||
onOpenChange(false);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
open={open}
|
||||
onOpenChange={onOpenChange}
|
||||
title={title}
|
||||
footer={
|
||||
<>
|
||||
<Button variant="ghost" onClick={() => onOpenChange(false)} disabled={busy}>
|
||||
{cancelLabel ?? t("common.cancel")}
|
||||
</Button>
|
||||
<Button variant={danger ? "danger" : "primary"} onClick={() => void confirm()} disabled={busy}>
|
||||
{confirmLabel ?? t("common.confirm")}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{description ? <p className="muted">{description}</p> : null}
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { Empty as EmptyState, type EmptyProps } from "@/components/ui/empty";
|
||||
@@ -0,0 +1,72 @@
|
||||
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Icon } from "@/components/icons";
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
LANGUAGES,
|
||||
isLanguage,
|
||||
languageLabel,
|
||||
languageShort,
|
||||
setLanguage,
|
||||
type Language,
|
||||
} from "@/lib/i18n";
|
||||
|
||||
/** Topbar language menu (globe + current language + caret), persisted to `pi2-lang`. */
|
||||
export function LangMenu() {
|
||||
const { t, i18n } = useTranslation();
|
||||
const current: Language = isLanguage(i18n.language) ? i18n.language : "zh";
|
||||
|
||||
return (
|
||||
<DropdownMenu.Root>
|
||||
<DropdownMenu.Trigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn--sm btn--ghost lang-switch"
|
||||
title={t("shell.language")}
|
||||
aria-label={`${t("shell.language")}: ${languageLabel(current)}`}
|
||||
>
|
||||
<Icon name="globe" />
|
||||
<span className="lang-switch__full">{languageLabel(current)}</span>
|
||||
<span className="lang-switch__short">{languageShort(current)}</span>
|
||||
<span className="lang-switch__caret">
|
||||
<Icon name="chevron-down" />
|
||||
</span>
|
||||
</button>
|
||||
</DropdownMenu.Trigger>
|
||||
<DropdownMenu.Portal>
|
||||
<DropdownMenu.Content
|
||||
className="menu-popover"
|
||||
align="end"
|
||||
sideOffset={4}
|
||||
aria-label={t("shell.language")}
|
||||
>
|
||||
<DropdownMenu.RadioGroup
|
||||
value={current}
|
||||
onValueChange={(value) => {
|
||||
if (isLanguage(value)) void setLanguage(value);
|
||||
}}
|
||||
>
|
||||
{LANGUAGES.map((language) => {
|
||||
const active = language === current;
|
||||
return (
|
||||
<DropdownMenu.RadioItem
|
||||
key={language}
|
||||
value={language}
|
||||
className={cn("menu__item", active && "is-active")}
|
||||
>
|
||||
<span className="grow">{languageLabel(language)}</span>
|
||||
{active ? (
|
||||
<span className="menu__check">
|
||||
<Icon name="check" />
|
||||
</span>
|
||||
) : null}
|
||||
</DropdownMenu.RadioItem>
|
||||
);
|
||||
})}
|
||||
</DropdownMenu.RadioGroup>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Portal>
|
||||
</DropdownMenu.Root>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import * as React from "react";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export interface PageHeaderProps {
|
||||
title: React.ReactNode;
|
||||
subtitle?: React.ReactNode;
|
||||
/** Right-hand actions (buttons, links). */
|
||||
actions?: React.ReactNode;
|
||||
/** Optional extra row under the subtitle. */
|
||||
children?: React.ReactNode;
|
||||
size?: "default" | "lg";
|
||||
/** Title used for `document.title` when `title` is not a plain string. */
|
||||
docTitle?: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared page header from workspaces.html/status.html:
|
||||
* h1 + muted subtitle, actions on the right (wrapping under <600px).
|
||||
*/
|
||||
export function PageHeader({ title, subtitle, actions, children, size = "default", docTitle, className }: PageHeaderProps) {
|
||||
useEffect(() => {
|
||||
if (typeof document === "undefined") return;
|
||||
const label = docTitle ?? (typeof title === "string" ? title : "");
|
||||
document.title = label ? `${label} — pi2.nvim` : "pi2.nvim";
|
||||
}, [docTitle, title]);
|
||||
|
||||
return (
|
||||
<header className={cn("page-head", size === "lg" && "page-head--lg", className)}>
|
||||
<div className="page-head__text">
|
||||
<h1 className="page-head__title">{title}</h1>
|
||||
{subtitle ? <p className="page-head__sub">{subtitle}</p> : null}
|
||||
{children}
|
||||
</div>
|
||||
{actions ? <div className="page-head__actions">{actions}</div> : null}
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { useEffect, useReducer } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { currentLanguage, localeFor } from "@/lib/i18n";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type Translator = (key: string, params?: Record<string, unknown>) => string;
|
||||
|
||||
/** Relative time exactly as `App.fmt.rel` (just now / N minutes / N hours / N days). */
|
||||
export function formatRelative(ts: number, t: Translator, now = Date.now()): string {
|
||||
const seconds = Math.max(0, (now - ts) / 1000);
|
||||
if (seconds < 60) return t("time.justNow");
|
||||
if (seconds < 3600) return t("time.minutesAgo", { n: Math.floor(seconds / 60) });
|
||||
if (seconds < 86400) return t("time.hoursAgo", { n: Math.floor(seconds / 3600) });
|
||||
return t("time.daysAgo", { n: Math.floor(seconds / 86400) });
|
||||
}
|
||||
|
||||
export interface RelativeTimeProps {
|
||||
ts: number | null | undefined;
|
||||
className?: string;
|
||||
/** Refresh once a minute (default true). */
|
||||
live?: boolean;
|
||||
}
|
||||
|
||||
export function RelativeTime({ ts, className, live = true }: RelativeTimeProps) {
|
||||
const { t } = useTranslation();
|
||||
const [, tick] = useReducer((n: number) => n + 1, 0);
|
||||
|
||||
useEffect(() => {
|
||||
if (!live) return;
|
||||
const timer = setInterval(tick, 30_000);
|
||||
return () => clearInterval(timer);
|
||||
}, [live]);
|
||||
|
||||
if (ts == null || !Number.isFinite(ts)) return <span className={cn("muted", className)}>—</span>;
|
||||
|
||||
return (
|
||||
<time
|
||||
className={className}
|
||||
dateTime={new Date(ts).toISOString()}
|
||||
title={new Date(ts).toLocaleString(localeFor(currentLanguage()))}
|
||||
>
|
||||
{formatRelative(ts, t)}
|
||||
</time>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { StatusDot, serverDotClass } from "@/components/ui/status-dot";
|
||||
import type { InfoResponse } from "@/lib/api";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useConnectionStore } from "@/stores/connection";
|
||||
|
||||
export interface ServerChipProps {
|
||||
server?: InfoResponse | null;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Single-server identity chip in the topbar: status dot + server name + hostname,
|
||||
* linking to /status. Never a server picker (single-server invariant).
|
||||
*/
|
||||
export function ServerChip({ server: override, className }: ServerChipProps) {
|
||||
const { t } = useTranslation();
|
||||
const stored = useConnectionStore((state) => state.server);
|
||||
const server = override ?? stored;
|
||||
|
||||
const name = server?.name ?? "pi2.nvim";
|
||||
const hostname =
|
||||
server?.hostname ?? (typeof window !== "undefined" ? window.location.hostname || "localhost" : "localhost");
|
||||
const status = server?.status ?? "offline";
|
||||
const dot = serverDotClass(status);
|
||||
const dotStatus = dot.replace("dot--", "") as "ok" | "attention" | "exited" | "idle";
|
||||
|
||||
return (
|
||||
<Link
|
||||
to="/status"
|
||||
className={cn("server-chip", className)}
|
||||
title={t("shell.serverChip", { name })}
|
||||
>
|
||||
<StatusDot status={dotStatus} title={t(`state.${status}`)} />
|
||||
<span className="server-chip__name">{name}</span>
|
||||
<span className="server-chip__host mono">{hostname}</span>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { useTheme } from "next-themes";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Seg, type SegOption } from "@/components/ui/seg";
|
||||
|
||||
type ThemeValue = "light" | "dark" | "system";
|
||||
|
||||
const THEMES: ThemeValue[] = ["light", "dark", "system"];
|
||||
|
||||
function isThemeValue(value: string | undefined): value is ThemeValue {
|
||||
return value === "light" || value === "dark" || value === "system";
|
||||
}
|
||||
|
||||
/** Topbar light/dark/system segment; next-themes persists it to `pi2-theme`. */
|
||||
export function ThemeMenu() {
|
||||
const { t } = useTranslation();
|
||||
const { theme, setTheme } = useTheme();
|
||||
const [mounted, setMounted] = useState(false);
|
||||
|
||||
useEffect(() => setMounted(true), []);
|
||||
|
||||
const value: ThemeValue = mounted && isThemeValue(theme) ? theme : "system";
|
||||
const options: SegOption<ThemeValue>[] = THEMES.map((item) => ({
|
||||
value: item,
|
||||
label: t(`shell.${item}`),
|
||||
}));
|
||||
|
||||
return (
|
||||
<Seg
|
||||
value={value}
|
||||
options={options}
|
||||
onChange={setTheme}
|
||||
ariaLabel={t("shell.theme")}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export const badgeVariants = cva("badge", {
|
||||
variants: {
|
||||
tone: {
|
||||
default: "",
|
||||
ok: "badge--ok",
|
||||
warn: "badge--warn",
|
||||
err: "badge--err",
|
||||
info: "badge--info",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
tone: "default",
|
||||
},
|
||||
});
|
||||
|
||||
export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement>, VariantProps<typeof badgeVariants> {}
|
||||
|
||||
export function Badge({ className, tone, ...props }: BadgeProps) {
|
||||
return <span className={cn(badgeVariants({ tone }), className)} {...props} />;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { Slot } from "@radix-ui/react-slot";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export const buttonVariants = cva("btn", {
|
||||
variants: {
|
||||
variant: {
|
||||
default: "",
|
||||
primary: "btn--primary",
|
||||
ghost: "btn--ghost",
|
||||
danger: "btn--danger",
|
||||
},
|
||||
size: {
|
||||
default: "",
|
||||
sm: "btn--sm",
|
||||
icon: "btn--icon",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
});
|
||||
|
||||
export interface ButtonProps
|
||||
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||||
VariantProps<typeof buttonVariants> {
|
||||
asChild?: boolean;
|
||||
}
|
||||
|
||||
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(
|
||||
{ className, variant, size, asChild = false, type, ...props },
|
||||
ref,
|
||||
) {
|
||||
const Comp = asChild ? Slot : "button";
|
||||
return (
|
||||
<Comp
|
||||
ref={ref}
|
||||
className={cn(buttonVariants({ variant, size }), className)}
|
||||
{...(!asChild ? { type: type ?? "button" } : {})}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement> & { hover?: boolean }>(
|
||||
function Card({ className, hover = false, ...props }, ref) {
|
||||
return <div ref={ref} className={cn("card", hover && "card--hover", className)} {...props} />;
|
||||
},
|
||||
);
|
||||
|
||||
export function CardHeader({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn("card__head", className)} {...props} />;
|
||||
}
|
||||
|
||||
export function CardTitle({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn("card__title", className)} {...props} />;
|
||||
}
|
||||
|
||||
export function CardSub({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn("card__sub", className)} {...props} />;
|
||||
}
|
||||
|
||||
export const Panel = React.forwardRef<HTMLElement, React.HTMLAttributes<HTMLElement>>(function Panel(
|
||||
{ className, ...props },
|
||||
ref,
|
||||
) {
|
||||
return <section ref={ref} className={cn("panel", className)} {...props} />;
|
||||
});
|
||||
|
||||
export function PanelHead({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn("panel__head", className)} {...props} />;
|
||||
}
|
||||
|
||||
export function PanelBody({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn("panel__body", className)} {...props} />;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function Chip({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) {
|
||||
return <span className={cn("chip", className)} {...props} />;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
||||
import { X } from "lucide-react";
|
||||
import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export const Dialog = DialogPrimitive.Root;
|
||||
export const DialogTrigger = DialogPrimitive.Trigger;
|
||||
export const DialogClose = DialogPrimitive.Close;
|
||||
|
||||
export interface ModalProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
title: React.ReactNode;
|
||||
description?: React.ReactNode;
|
||||
children?: React.ReactNode;
|
||||
footer?: React.ReactNode;
|
||||
/** `wide` is the content overlay (≥60vw) used for subagent conversations. */
|
||||
size?: "default" | "wide";
|
||||
className?: string;
|
||||
contentClassName?: string;
|
||||
}
|
||||
|
||||
/** Radix dialog styled as the base.css `.modal-backdrop > .modal` (bottom sheet <600px). */
|
||||
export function Modal({
|
||||
open,
|
||||
onOpenChange,
|
||||
title,
|
||||
description,
|
||||
children,
|
||||
footer,
|
||||
size = "default",
|
||||
className,
|
||||
contentClassName,
|
||||
}: ModalProps) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<DialogPrimitive.Root open={open} onOpenChange={onOpenChange}>
|
||||
<DialogPrimitive.Portal>
|
||||
<DialogPrimitive.Overlay className={cn("modal-backdrop", className)} />
|
||||
<DialogPrimitive.Content
|
||||
className={cn("modal", size === "wide" && "modal--wide", "modal-content", contentClassName)}
|
||||
>
|
||||
<DialogPrimitive.Title asChild>
|
||||
<h3>
|
||||
<span>{title}</span>
|
||||
<DialogPrimitive.Close asChild>
|
||||
<button type="button" className="btn btn--ghost btn--sm" aria-label={t("common.close")}>
|
||||
<X size={16} aria-hidden="true" />
|
||||
</button>
|
||||
</DialogPrimitive.Close>
|
||||
</h3>
|
||||
</DialogPrimitive.Title>
|
||||
{description ? (
|
||||
<DialogPrimitive.Description className="muted">{description}</DialogPrimitive.Description>
|
||||
) : null}
|
||||
{children}
|
||||
{footer ? <div className="modal-actions">{footer}</div> : null}
|
||||
</DialogPrimitive.Content>
|
||||
</DialogPrimitive.Portal>
|
||||
</DialogPrimitive.Root>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export interface EmptyProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
||||
icon?: React.ReactNode;
|
||||
title?: React.ReactNode;
|
||||
description?: React.ReactNode;
|
||||
action?: React.ReactNode;
|
||||
}
|
||||
|
||||
export function Empty({ icon, title, description, action, className, children, ...props }: EmptyProps) {
|
||||
return (
|
||||
<div className={cn("empty", className)} {...props}>
|
||||
{icon}
|
||||
{title ? <div className="t">{title}</div> : null}
|
||||
{description ? <p className="muted">{description}</p> : null}
|
||||
{children}
|
||||
{action ? <div className="mt-4 flex justify-center">{action}</div> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(function Input(
|
||||
{ className, type = "text", ...props },
|
||||
ref,
|
||||
) {
|
||||
return <input ref={ref} type={type} className={cn("input", className)} {...props} />;
|
||||
});
|
||||
|
||||
export const Textarea = React.forwardRef<HTMLTextAreaElement, React.ComponentProps<"textarea">>(function Textarea(
|
||||
{ className, ...props },
|
||||
ref,
|
||||
) {
|
||||
return <textarea ref={ref} className={cn("textarea", className)} {...props} />;
|
||||
});
|
||||
|
||||
export interface FieldProps {
|
||||
label: React.ReactNode;
|
||||
htmlFor?: string;
|
||||
hint?: React.ReactNode;
|
||||
error?: React.ReactNode;
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
/** Label + control + hint/error (base.css `.field`). */
|
||||
export function Field({ label, htmlFor, hint, error, className, children }: FieldProps) {
|
||||
return (
|
||||
<div className={cn("field", error && "field--invalid", className)}>
|
||||
<label htmlFor={htmlFor}>{label}</label>
|
||||
{children}
|
||||
{error ? (
|
||||
<div className="hint is-err" role="alert">
|
||||
{error}
|
||||
</div>
|
||||
) : hint ? (
|
||||
<div className="hint">{hint}</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export interface KVProps {
|
||||
label: React.ReactNode;
|
||||
children?: React.ReactNode;
|
||||
/** Render the value with the mono font. */
|
||||
mono?: boolean;
|
||||
className?: string;
|
||||
valueClassName?: string;
|
||||
}
|
||||
|
||||
/** Key/value row from base.css (`.kv > k + v`); rendered with spans for valid JSX. */
|
||||
export function KV({ label, children, mono, className, valueClassName }: KVProps) {
|
||||
return (
|
||||
<div className={cn("kv", className)}>
|
||||
<span className="kv-key">{label}</span>
|
||||
<span className={cn("kv-val", mono && "mono", valueClassName)}>{children}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function KVList({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn("kv-list", className)} {...props} />;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export interface ProgressProps {
|
||||
value: number;
|
||||
max?: number;
|
||||
tone?: "default" | "warn" | "err";
|
||||
size?: "default" | "lg";
|
||||
className?: string;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
export function Progress({ value, max = 100, tone = "default", size = "default", className, label }: ProgressProps) {
|
||||
const pct = max > 0 ? Math.max(0, Math.min(100, (value / max) * 100)) : 0;
|
||||
return (
|
||||
<div
|
||||
className={cn("progress", tone === "warn" && "progress--warn", tone === "err" && "progress--err", size === "lg" && "progress--lg", className)}
|
||||
role="progressbar"
|
||||
aria-valuenow={Math.round(pct)}
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-label={label}
|
||||
>
|
||||
<i style={{ width: `${pct}%` }} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export interface SegOption<T extends string> {
|
||||
value: T;
|
||||
label: React.ReactNode;
|
||||
}
|
||||
|
||||
export interface SegProps<T extends string> {
|
||||
value: T;
|
||||
options: readonly SegOption<T>[];
|
||||
onChange: (value: T) => void;
|
||||
ariaLabel?: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
/** Segmented control (base.css `.seg > button.active`). */
|
||||
export function Seg<T extends string>({ value, options, onChange, ariaLabel, className }: SegProps<T>) {
|
||||
return (
|
||||
<div className={cn("seg", className)} role="group" aria-label={ariaLabel}>
|
||||
{options.map((option) => (
|
||||
<button
|
||||
key={option.value}
|
||||
type="button"
|
||||
className={option.value === value ? "active" : undefined}
|
||||
aria-pressed={option.value === value}
|
||||
onClick={() => onChange(option.value)}
|
||||
>
|
||||
{option.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import * as SelectPrimitive from "@radix-ui/react-select";
|
||||
import { Check, ChevronDown } from "lucide-react";
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export const Select = SelectPrimitive.Root;
|
||||
export const SelectGroup = SelectPrimitive.Group;
|
||||
export const SelectValue = SelectPrimitive.Value;
|
||||
|
||||
export const SelectTrigger = React.forwardRef<
|
||||
React.ComponentRef<typeof SelectPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
||||
>(function SelectTrigger({ className, children, ...props }, ref) {
|
||||
return (
|
||||
<SelectPrimitive.Trigger ref={ref} className={cn("select select-trigger", className)} {...props}>
|
||||
{children}
|
||||
<SelectPrimitive.Icon asChild>
|
||||
<ChevronDown size={14} aria-hidden="true" />
|
||||
</SelectPrimitive.Icon>
|
||||
</SelectPrimitive.Trigger>
|
||||
);
|
||||
});
|
||||
|
||||
export const SelectContent = React.forwardRef<
|
||||
React.ComponentRef<typeof SelectPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
||||
>(function SelectContent({ className, children, position = "popper", ...props }, ref) {
|
||||
return (
|
||||
<SelectPrimitive.Portal>
|
||||
<SelectPrimitive.Content
|
||||
ref={ref}
|
||||
position={position}
|
||||
sideOffset={4}
|
||||
className={cn("select-content", className)}
|
||||
{...props}
|
||||
>
|
||||
<SelectPrimitive.Viewport className="select-viewport">{children}</SelectPrimitive.Viewport>
|
||||
</SelectPrimitive.Content>
|
||||
</SelectPrimitive.Portal>
|
||||
);
|
||||
});
|
||||
|
||||
export const SelectItem = React.forwardRef<
|
||||
React.ComponentRef<typeof SelectPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
||||
>(function SelectItem({ className, children, ...props }, ref) {
|
||||
return (
|
||||
<SelectPrimitive.Item ref={ref} className={cn("select-item", className)} {...props}>
|
||||
<span className="select-item__indicator">
|
||||
<SelectPrimitive.ItemIndicator>
|
||||
<Check size={14} aria-hidden="true" />
|
||||
</SelectPrimitive.ItemIndicator>
|
||||
</span>
|
||||
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
||||
</SelectPrimitive.Item>
|
||||
);
|
||||
});
|
||||
|
||||
export const SelectLabel = React.forwardRef<
|
||||
React.ComponentRef<typeof SelectPrimitive.Label>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
||||
>(function SelectLabel({ className, ...props }, ref) {
|
||||
return <SelectPrimitive.Label ref={ref} className={cn("px-3 py-1 text-xs text-muted-foreground", className)} {...props} />;
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
import * as React from "react";
|
||||
import { Drawer } from "vaul";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export const Sheet = Drawer.Root;
|
||||
export const SheetTrigger = Drawer.Trigger;
|
||||
export const SheetClose = Drawer.Close;
|
||||
export const SheetTitle = Drawer.Title;
|
||||
export const SheetDescription = Drawer.Description;
|
||||
|
||||
export interface SheetContentProps extends React.ComponentPropsWithoutRef<typeof Drawer.Content> {
|
||||
showHandle?: boolean;
|
||||
}
|
||||
|
||||
/** Mobile drawer (vaul), visually aligned with the design's `.sheet`. */
|
||||
export function SheetContent({ className, children, showHandle = true, ...props }: SheetContentProps) {
|
||||
return (
|
||||
<Drawer.Portal>
|
||||
<Drawer.Overlay className="sheet-overlay" />
|
||||
<Drawer.Content className={cn("sheet-content", className)} {...props}>
|
||||
{showHandle ? <div className="sheet-handle" aria-hidden="true" /> : null}
|
||||
{children}
|
||||
</Drawer.Content>
|
||||
</Drawer.Portal>
|
||||
);
|
||||
}
|
||||
|
||||
export function SheetHeader({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn("mb-4 flex flex-col gap-1", className)} {...props} />;
|
||||
}
|
||||
|
||||
export function SheetFooter({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn("mt-5 flex justify-end gap-2", className)} {...props} />;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Slot } from "@radix-ui/react-slot";
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export interface SidebarItemProps extends React.HTMLAttributes<HTMLElement> {
|
||||
active?: boolean;
|
||||
asChild?: boolean;
|
||||
}
|
||||
|
||||
/** Sidebar / rail / tabbar navigation row; compose the link or button as a child. */
|
||||
export function SidebarItem({ active, asChild = false, className, children, ...props }: SidebarItemProps) {
|
||||
const Comp = asChild ? Slot : "a";
|
||||
return (
|
||||
<Comp className={cn("nav-item", active && "active", className)} aria-current={active ? "page" : undefined} {...props}>
|
||||
{children}
|
||||
</Comp>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function Spinner({ className, label }: { className?: string; label?: string }) {
|
||||
return <span className={cn("spinner", className)} role="status" aria-label={label} />;
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
/** Status-dot vocabulary from the design's `:PiSessions` state matrix. */
|
||||
export type DotStatus = "busy" | "compacting" | "idle" | "ok" | "err" | "attention" | "exited";
|
||||
|
||||
export const DOT_CLASS: Record<DotStatus, string> = {
|
||||
busy: "dot--busy",
|
||||
compacting: "dot--compacting",
|
||||
idle: "dot--idle",
|
||||
ok: "dot--ok",
|
||||
err: "dot--err",
|
||||
attention: "dot--attention",
|
||||
exited: "dot--exited",
|
||||
};
|
||||
|
||||
export type ServerStatus = "online" | "degraded" | "offline";
|
||||
|
||||
/** Server / connection status mapping (online → ok, degraded → attention, else exited). */
|
||||
export function serverDotClass(status: ServerStatus | string | null | undefined): string {
|
||||
if (status === "online") return DOT_CLASS.ok;
|
||||
if (status === "degraded" || status === "attention" || status === "compacting") return DOT_CLASS.attention;
|
||||
if (status === "offline" || status === "exited" || status === "unpaired") return DOT_CLASS.exited;
|
||||
if (status === "busy" || status === "connecting" || status === "pairing") return DOT_CLASS.busy;
|
||||
return DOT_CLASS.idle;
|
||||
}
|
||||
|
||||
export type SubagentStatus = "active" | "completed" | "failed" | "interrupted" | "dormant";
|
||||
|
||||
export function subagentDotClass(status: SubagentStatus | string): string {
|
||||
switch (status) {
|
||||
case "active":
|
||||
return DOT_CLASS.busy;
|
||||
case "completed":
|
||||
return DOT_CLASS.ok;
|
||||
case "failed":
|
||||
return DOT_CLASS.err;
|
||||
case "interrupted":
|
||||
return DOT_CLASS.attention;
|
||||
case "dormant":
|
||||
return DOT_CLASS.exited;
|
||||
default:
|
||||
return DOT_CLASS.idle;
|
||||
}
|
||||
}
|
||||
|
||||
export type SessionStatus = "starting" | "busy" | "compacting" | "idle" | "exited" | "interrupted" | "attention" | "done" | "error";
|
||||
|
||||
export function sessionDotClass(status: SessionStatus | string): string {
|
||||
switch (status) {
|
||||
case "busy":
|
||||
case "starting":
|
||||
return DOT_CLASS.busy;
|
||||
case "compacting":
|
||||
return DOT_CLASS.compacting;
|
||||
case "interrupted":
|
||||
case "attention":
|
||||
return DOT_CLASS.attention;
|
||||
case "done":
|
||||
return DOT_CLASS.ok;
|
||||
case "error":
|
||||
return DOT_CLASS.err;
|
||||
case "exited":
|
||||
return DOT_CLASS.exited;
|
||||
case "idle":
|
||||
return DOT_CLASS.idle;
|
||||
default:
|
||||
return DOT_CLASS.idle;
|
||||
}
|
||||
}
|
||||
|
||||
export interface StatusDotProps {
|
||||
status: DotStatus;
|
||||
title?: string;
|
||||
className?: string;
|
||||
/** Decorative by default; pass a title to expose the state to assistive tech. */
|
||||
"aria-hidden"?: boolean;
|
||||
}
|
||||
|
||||
export function StatusDot({ status, title, className, ...rest }: StatusDotProps) {
|
||||
return (
|
||||
<span
|
||||
className={cn("dot", DOT_CLASS[status], className)}
|
||||
title={title}
|
||||
aria-label={title}
|
||||
aria-hidden={title ? undefined : true}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export const Tabs = TabsPrimitive.Root;
|
||||
|
||||
export const TabsList = React.forwardRef<
|
||||
React.ComponentRef<typeof TabsPrimitive.List>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
||||
>(function TabsList({ className, ...props }, ref) {
|
||||
return <TabsPrimitive.List ref={ref} className={cn("tabs", className)} {...props} />;
|
||||
});
|
||||
|
||||
export const TabsTrigger = React.forwardRef<
|
||||
React.ComponentRef<typeof TabsPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
||||
>(function TabsTrigger({ className, ...props }, ref) {
|
||||
return <TabsPrimitive.Trigger ref={ref} className={cn("tab", className)} {...props} />;
|
||||
});
|
||||
|
||||
export const TabsContent = React.forwardRef<
|
||||
React.ComponentRef<typeof TabsPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
||||
>(function TabsContent({ className, ...props }, ref) {
|
||||
return <TabsPrimitive.Content ref={ref} className={cn("mt-3 outline-none", className)} {...props} />;
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Toaster as SonnerToaster, toast } from "sonner";
|
||||
|
||||
export { toast };
|
||||
|
||||
/** App-wide toast host (sonner), styled with the design tokens in app.css. */
|
||||
export function Toaster() {
|
||||
return (
|
||||
<SonnerToaster
|
||||
position="bottom-right"
|
||||
theme="system"
|
||||
richColors={false}
|
||||
closeButton={false}
|
||||
duration={2600}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function Toolbar({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn("toolbar", className)} role="toolbar" {...props} />;
|
||||
}
|
||||
Reference in new issue
Block a user