docs: update AI Studio design token audits
Refresh design token inventory files to reflect the latest UI sizing and layout configurations from the sandbox prototype.
This commit is contained in:
1 parent
50449e96ad
commit
d39d9f92f9
139 files changed
+10982
-6
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import React from 'react';
|
||||
|
||||
export const Footer: React.FC = () => {
|
||||
return (
|
||||
<footer className="shrink-0 h-[26px] bg-[var(--bg-activity)] border-t border-[var(--border)] px-3 sm:px-4 flex items-center justify-between text-[10px] text-[var(--text-dim)] select-none">
|
||||
<div className="flex items-center gap-1.5 truncate min-w-0 pr-2">
|
||||
<span className="font-semibold text-[var(--text-muted)] tracking-tight">DataStack</span>
|
||||
<span className="text-[var(--border-strong)]">/</span>
|
||||
<span className="font-mono text-[9px] truncate">
|
||||
storage/data/{clientId}/{YYYY-MM-DD}.csv
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 font-mono text-[9.5px] shrink-0 ml-auto">
|
||||
<span className="flex items-center gap-1">
|
||||
<span className="w-1.5 h-1.5 bg-[var(--success)] inline-block" />
|
||||
<span className="text-[var(--text-muted)]">:4000</span>
|
||||
</span>
|
||||
<span className="text-[var(--border-strong)]">•</span>
|
||||
<span className="flex items-center gap-1">
|
||||
<span className="w-1.5 h-1.5 bg-[var(--accent)] inline-block" />
|
||||
<span className="text-[var(--text-muted)]">:3000</span>
|
||||
</span>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
|
||||
export default Footer;
|
||||
@@ -0,0 +1,44 @@
|
||||
'use client';
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { Navbar } from './Navbar';
|
||||
import { Sidebar } from './Sidebar';
|
||||
import { Footer } from './Footer';
|
||||
|
||||
interface MainLayoutProps {
|
||||
children: React.ReactNode;
|
||||
showSidebar?: boolean;
|
||||
}
|
||||
|
||||
export const MainLayout: React.FC<MainLayoutProps> = ({
|
||||
children,
|
||||
showSidebar = false,
|
||||
}) => {
|
||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex flex-col bg-[var(--bg-main)] text-[var(--text)] antialiased">
|
||||
<Navbar
|
||||
showSidebarToggle={showSidebar}
|
||||
onToggleSidebar={() => setSidebarOpen((prev) => !prev)}
|
||||
/>
|
||||
|
||||
<div className="flex-1 flex min-h-0 overflow-hidden">
|
||||
{showSidebar && (
|
||||
<Sidebar
|
||||
isOpen={sidebarOpen}
|
||||
onClose={() => setSidebarOpen(false)}
|
||||
/>
|
||||
)}
|
||||
<main className="flex-1 overflow-y-auto flex flex-col min-w-0">
|
||||
<div className="flex-1 p-2 sm:p-3.5 max-w-[1360px] w-full mx-auto">
|
||||
{children}
|
||||
</div>
|
||||
<Footer />
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default MainLayout;
|
||||
@@ -0,0 +1,141 @@
|
||||
'use client';
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import { Icon } from '@/components/ui/Icon';
|
||||
import { Button } from '@/components/ui/Button';
|
||||
|
||||
interface NavbarProps {
|
||||
onToggleSidebar?: () => void;
|
||||
showSidebarToggle?: boolean;
|
||||
}
|
||||
|
||||
export const Navbar: React.FC<NavbarProps> = ({
|
||||
onToggleSidebar,
|
||||
showSidebarToggle = false,
|
||||
}) => {
|
||||
const pathname = usePathname();
|
||||
const [theme, setTheme] = useState<'dark' | 'light'>('dark');
|
||||
|
||||
useEffect(() => {
|
||||
const saved = localStorage.getItem('datastack-theme') as 'dark' | 'light' | null;
|
||||
const initial = saved || 'dark';
|
||||
setTheme(initial);
|
||||
if (initial === 'light') {
|
||||
document.documentElement.classList.remove('dark');
|
||||
document.documentElement.classList.add('light');
|
||||
} else {
|
||||
document.documentElement.classList.add('dark');
|
||||
document.documentElement.classList.remove('light');
|
||||
}
|
||||
}, []);
|
||||
|
||||
const toggleTheme = () => {
|
||||
const nextTheme = theme === 'dark' ? 'light' : 'dark';
|
||||
setTheme(nextTheme);
|
||||
localStorage.setItem('datastack-theme', nextTheme);
|
||||
if (nextTheme === 'light') {
|
||||
document.documentElement.classList.remove('dark');
|
||||
document.documentElement.classList.add('light');
|
||||
} else {
|
||||
document.documentElement.classList.add('dark');
|
||||
document.documentElement.classList.remove('light');
|
||||
}
|
||||
};
|
||||
|
||||
const isVcon = pathname?.startsWith('/vcon');
|
||||
|
||||
return (
|
||||
<header className="h-[38px] shrink-0 bg-[var(--bg-activity)] border-b border-[var(--border)] px-3 sm:px-4 flex items-center justify-between z-40 select-none">
|
||||
{/* Left: Mobile hamburger + Brand */}
|
||||
<div className="flex items-center gap-2">
|
||||
{showSidebarToggle && (
|
||||
<button
|
||||
onClick={onToggleSidebar}
|
||||
className="md:hidden w-[26px] h-[26px] flex items-center justify-center text-[var(--text-muted)] hover:text-[var(--text)] border border-[var(--border)] bg-[var(--bg-elevated)] cursor-pointer"
|
||||
aria-label="Toggle Navigation"
|
||||
>
|
||||
<Icon name="Menu" size={13} />
|
||||
</button>
|
||||
)}
|
||||
|
||||
<Link href="/" className="flex items-center gap-1.5">
|
||||
<div className="w-[17px] h-[17px] bg-[var(--accent)] text-[var(--text-on-accent)] flex items-center justify-center text-[9.5px] font-bold">
|
||||
DS
|
||||
</div>
|
||||
<span className="text-[12px] font-semibold text-[var(--text)] tracking-tight">
|
||||
DataStack
|
||||
</span>
|
||||
<span className="hidden sm:inline text-[9px] text-[var(--text-dim)] font-mono border border-[var(--border)] px-1 py-0.2">
|
||||
v2.4
|
||||
</span>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Middle: Links */}
|
||||
<nav className="hidden sm:flex items-center gap-1 text-[11px]">
|
||||
<Link
|
||||
href="/"
|
||||
className={`px-2.5 py-1 transition-colors border-b-2 ${
|
||||
pathname === '/'
|
||||
? 'border-[var(--accent)] text-[var(--text)] font-medium'
|
||||
: 'border-transparent text-[var(--text-muted)] hover:text-[var(--text)]'
|
||||
}`}
|
||||
>
|
||||
Overview
|
||||
</Link>
|
||||
<Link
|
||||
href="/vcon/dashboard"
|
||||
className={`px-2.5 py-1 transition-colors border-b-2 flex items-center gap-1.5 ${
|
||||
isVcon
|
||||
? 'border-[var(--accent)] text-[var(--text)] font-medium'
|
||||
: 'border-transparent text-[var(--text-muted)] hover:text-[var(--text)]'
|
||||
}`}
|
||||
>
|
||||
<span>Admin Console</span>
|
||||
<span className="w-1.5 h-1.5 bg-[var(--success)] shrink-0" />
|
||||
</Link>
|
||||
<Link
|
||||
href="/vcon/export"
|
||||
className={`px-2.5 py-1 transition-colors border-b-2 ${
|
||||
pathname === '/vcon/export'
|
||||
? 'border-[var(--accent)] text-[var(--text)] font-medium'
|
||||
: 'border-transparent text-[var(--text-muted)] hover:text-[var(--text)]'
|
||||
}`}
|
||||
>
|
||||
CSV Exporter
|
||||
</Link>
|
||||
</nav>
|
||||
|
||||
{/* Right: Port Badges + Theme Toggle + Console Action */}
|
||||
<div className="flex items-center gap-1.5">
|
||||
<div className="hidden lg:flex items-center gap-1.5 text-[9.5px] text-[var(--text-dim)] font-mono border border-[var(--border)] px-1.5 py-0.5 bg-[var(--bg-main)]">
|
||||
<span className="w-1.5 h-1.5 bg-[var(--success)] inline-block" />
|
||||
<span>:4000</span>
|
||||
<span className="text-[var(--border-strong)]">|</span>
|
||||
<span className="w-1.5 h-1.5 bg-[var(--accent)] inline-block" />
|
||||
<span>:3000</span>
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={toggleTheme}
|
||||
aria-label="Toggle Theme"
|
||||
className="w-[26px] h-[26px] flex items-center justify-center border border-[var(--border)] bg-[var(--bg-elevated)] text-[var(--text-muted)] hover:text-[var(--text)] cursor-pointer"
|
||||
>
|
||||
<Icon name={theme === 'dark' ? 'Sun' : 'Moon'} size={12} />
|
||||
</button>
|
||||
|
||||
{!isVcon && (
|
||||
<Link href="/vcon/dashboard">
|
||||
<Button size="xs" variant="primary" icon="Terminal">
|
||||
/vcon/
|
||||
</Button>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
};
|
||||
|
||||
export default Navbar;
|
||||
@@ -0,0 +1,146 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Icon } from '@/components/ui/Icon';
|
||||
|
||||
interface SidebarProps {
|
||||
isOpen?: boolean;
|
||||
onClose?: () => void;
|
||||
}
|
||||
|
||||
export const Sidebar: React.FC<SidebarProps> = ({
|
||||
isOpen = false,
|
||||
onClose,
|
||||
}) => {
|
||||
const pathname = usePathname();
|
||||
|
||||
const navigation = [
|
||||
{
|
||||
group: 'Core Telemetry',
|
||||
items: [
|
||||
{ name: 'Dashboard', href: '/vcon/dashboard', icon: 'LayoutDashboard' },
|
||||
{ name: 'Live Data Sync', href: '/vcon/data', icon: 'Activity', badge: 'Live' },
|
||||
{ name: 'CSV Exporter', href: '/vcon/export', icon: 'Download' },
|
||||
],
|
||||
},
|
||||
{
|
||||
group: 'Management',
|
||||
items: [
|
||||
{ name: 'Client SDKs', href: '/vcon/clients', icon: 'Key' },
|
||||
{ name: 'CSV Storage & Disk', href: '/vcon/storage', icon: 'HardDrive' },
|
||||
{ name: 'Engine Settings', href: '/vcon/settings', icon: 'Sliders' },
|
||||
],
|
||||
},
|
||||
{
|
||||
group: 'Integration',
|
||||
items: [
|
||||
{ name: 'Python SDK Guide', href: '/vcon/sdk', icon: 'FileCode2' },
|
||||
{ name: 'Live Simulator', href: '/vcon/simulator', icon: 'Play' },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Mobile Backdrop */}
|
||||
{isOpen && (
|
||||
<div
|
||||
onClick={onClose}
|
||||
className="fixed inset-0 z-40 bg-black/60 md:hidden backdrop-blur-[1px]"
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Sidebar Container */}
|
||||
<aside
|
||||
className={cn(
|
||||
'fixed inset-y-0 left-0 z-50 md:static w-[210px] shrink-0 bg-[var(--bg-sidebar)] border-r border-[var(--border)] flex flex-col transition-transform duration-150 ease-in-out md:translate-x-0',
|
||||
isOpen ? 'translate-x-0' : '-translate-x-full'
|
||||
)}
|
||||
>
|
||||
{/* Top Header */}
|
||||
<div className="h-[38px] px-3 flex items-center justify-between border-b border-[var(--border)] bg-[var(--bg-activity)] shrink-0">
|
||||
<div className="flex items-center gap-1.5 min-w-0">
|
||||
<span className="w-1.5 h-1.5 bg-[var(--accent)] shrink-0" />
|
||||
<span className="text-[10.5px] font-semibold text-[var(--text)] tracking-wider uppercase truncate">
|
||||
VCON ADMIN
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="md:hidden text-[var(--text-dim)] hover:text-[var(--text)] p-1 cursor-pointer"
|
||||
aria-label="Close menu"
|
||||
>
|
||||
<Icon name="X" size={13} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Navigation items */}
|
||||
<div className="flex-1 overflow-y-auto p-1.5 flex flex-col gap-2">
|
||||
{navigation.map((section, idx) => (
|
||||
<div key={idx} className="flex flex-col gap-0.5">
|
||||
<span className="text-[9px] font-semibold text-[var(--text-dim)] uppercase tracking-wider px-2 py-0.5">
|
||||
{section.group}
|
||||
</span>
|
||||
<div className="flex flex-col gap-0.5">
|
||||
{section.items.map((item) => {
|
||||
const isActive = pathname === item.href;
|
||||
return (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
onClick={onClose}
|
||||
className={cn(
|
||||
'flex items-center justify-between px-2 py-1 text-[11px] transition-colors border',
|
||||
isActive
|
||||
? 'bg-[var(--accent-soft)] text-[var(--accent-hover)] font-medium border-[var(--accent)]'
|
||||
: 'border-transparent text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--bg-hover)]'
|
||||
)}
|
||||
>
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<Icon
|
||||
name={item.icon}
|
||||
size={12}
|
||||
className={isActive ? 'text-[var(--accent)]' : 'text-[var(--text-dim)]'}
|
||||
/>
|
||||
<span className="truncate">{item.name}</span>
|
||||
</div>
|
||||
{item.badge && (
|
||||
<span className="text-[8px] px-1 py-0.2 bg-[var(--success-soft)] text-[var(--success)] font-mono border border-[var(--success)] shrink-0">
|
||||
{item.badge}
|
||||
</span>
|
||||
)}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Footer info */}
|
||||
<div className="p-2 border-t border-[var(--border)] bg-[var(--bg-main)] text-[9.5px] text-[var(--text-dim)] font-mono flex flex-col gap-1 shrink-0">
|
||||
<div className="flex items-center justify-between">
|
||||
<span>Buffer Worker</span>
|
||||
<span className="text-[var(--success)] flex items-center gap-1 font-semibold">
|
||||
<span className="w-1.5 h-1.5 bg-[var(--success)] inline-block" />
|
||||
Active
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<span>Storage Engine</span>
|
||||
<span className="text-[var(--text-muted)]">json2csv</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<span>Auth Handshake</span>
|
||||
<span className="text-[var(--text-muted)]">JWT</span>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Sidebar;
|
||||
@@ -0,0 +1,15 @@
|
||||
# Layout Components Module Manifest
|
||||
|
||||
## Purpose
|
||||
Global layout shell, navigation, top bar, and admin sidebar complying with compact, zero-border-radius, zero-shadow design system.
|
||||
|
||||
## Components
|
||||
- **Navbar.tsx**: Top titlebar with brand, quick links, runtime port indicator (:4000/:3000), and dark/light theme switcher.
|
||||
- **Sidebar.tsx**: Dedicated `/vcon/` admin console sidebar with mobile drawer support, grouped telemetry & management links.
|
||||
- **Footer.tsx**: System runtime status line with storage convention display and port allocations.
|
||||
- **MainLayout.tsx**: Viewport-bounded responsive shell with mobile backdrop and scrolling main container.
|
||||
|
||||
## Dependencies
|
||||
- `components/ui`
|
||||
- `next/link`
|
||||
- `next/navigation`
|
||||
@@ -0,0 +1,68 @@
|
||||
import React from 'react';
|
||||
import { Card } from '@/components/ui/Card';
|
||||
import { Icon } from '@/components/ui/Icon';
|
||||
|
||||
export const Architecture: React.FC = () => {
|
||||
return (
|
||||
<div className="flex flex-col gap-1.5 py-1">
|
||||
<div className="flex items-center justify-between border-b border-[var(--border)] pb-1">
|
||||
<h2 className="text-[11px] font-semibold text-[var(--text)] uppercase tracking-wider">
|
||||
Pipeline Flow
|
||||
</h2>
|
||||
<span className="text-[9px] text-[var(--text-dim)] font-mono">:4000 ➔ :3000</span>
|
||||
</div>
|
||||
|
||||
<Card compact className="p-2.5 flex flex-col gap-2 font-mono text-[10px] bg-[var(--bg-elevated)]">
|
||||
{/* Desktop Flow: 5 items */}
|
||||
<div className="hidden md:grid md:grid-cols-5 gap-1.5 items-center text-center">
|
||||
<div className="p-1.5 border border-[var(--border)] bg-[var(--bg-main)] flex flex-col items-center gap-0.5">
|
||||
<Icon name="FileCode" size={12} className="text-[var(--accent)]" />
|
||||
<span className="font-semibold text-[var(--text)]">Python SDK</span>
|
||||
</div>
|
||||
|
||||
<div className="text-[var(--text-dim)] flex items-center justify-center gap-1">
|
||||
<span className="text-[9px] px-1.5 py-0.2 border border-[var(--border)] bg-[var(--bg-main)] flex items-center gap-0.5">
|
||||
<span>JWT</span>
|
||||
<Icon name="ArrowRight" size={9} />
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="p-1.5 border border-[var(--border-strong)] bg-[var(--bg-main)] flex flex-col items-center gap-0.5">
|
||||
<Icon name="Radio" size={12} className="text-[var(--accent)]" />
|
||||
<span className="font-semibold text-[var(--text)]">Express Ingest (:4000)</span>
|
||||
</div>
|
||||
|
||||
<div className="text-[var(--text-dim)] flex items-center justify-center gap-1">
|
||||
<span className="text-[9px] px-1.5 py-0.2 border border-[var(--border)] bg-[var(--bg-main)] flex items-center gap-0.5">
|
||||
<span>Buffer</span>
|
||||
<Icon name="ArrowRight" size={9} />
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="p-1.5 border border-[var(--border)] bg-[var(--bg-main)] flex flex-col items-center gap-0.5">
|
||||
<Icon name="HardDrive" size={12} className="text-[var(--success)]" />
|
||||
<span className="font-semibold text-[var(--text)]">CSV Storage (Disk)</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Mobile Flow: Vertical */}
|
||||
<div className="flex md:hidden flex-col gap-1">
|
||||
<div className="p-1.5 border border-[var(--border)] bg-[var(--bg-main)] flex items-center justify-between">
|
||||
<span className="font-semibold text-[var(--text)]">1. Python SDK</span>
|
||||
<span className="text-[8.5px] text-[var(--text-dim)]">Client</span>
|
||||
</div>
|
||||
<div className="p-1.5 border border-[var(--border-strong)] bg-[var(--bg-main)] flex items-center justify-between">
|
||||
<span className="font-semibold text-[var(--text)]">2. Express (:4000)</span>
|
||||
<span className="text-[8.5px] text-[var(--accent)]">Ingest</span>
|
||||
</div>
|
||||
<div className="p-1.5 border border-[var(--border)] bg-[var(--bg-main)] flex items-center justify-between">
|
||||
<span className="font-semibold text-[var(--text)]">3. CSV Files</span>
|
||||
<span className="text-[8.5px] text-[var(--success)]">Rotated</span>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Architecture;
|
||||
@@ -0,0 +1,67 @@
|
||||
import React from 'react';
|
||||
import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/Card';
|
||||
import { Icon } from '@/components/ui/Icon';
|
||||
|
||||
export const Features: React.FC = () => {
|
||||
const items = [
|
||||
{
|
||||
icon: 'Zap',
|
||||
title: 'Decoupled Runtime Split',
|
||||
desc: 'Port 4000 WebSocket intake; Port 3000 Web & export.',
|
||||
},
|
||||
{
|
||||
icon: 'HardDrive',
|
||||
title: 'CSV File Persistence',
|
||||
desc: 'Streams directly to rotated CSV files on disk (Zero DB inserts).',
|
||||
},
|
||||
{
|
||||
icon: 'ShieldCheck',
|
||||
title: 'JWT SDK Authentication',
|
||||
desc: 'Signed tokens verify client IDs and rate limits on handshake.',
|
||||
},
|
||||
{
|
||||
icon: 'Cpu',
|
||||
title: 'In-Memory Buffer',
|
||||
desc: 'Aggregates 500 records or 2000ms intervals before async disk flush.',
|
||||
},
|
||||
{
|
||||
icon: 'CheckCheck',
|
||||
title: 'Idempotency Dedup',
|
||||
desc: 'Rejects duplicate clientId + eventId in 5-minute sliding TTL window.',
|
||||
},
|
||||
{
|
||||
icon: 'FileCode2',
|
||||
title: 'Python Client SDK',
|
||||
desc: 'datastack-sdk package with auto-reconnection and batch streaming.',
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1.5 py-1">
|
||||
<div className="flex items-center justify-between border-b border-[var(--border)] pb-1">
|
||||
<h2 className="text-[11px] font-semibold text-[var(--text)] uppercase tracking-wider">
|
||||
Platform Architecture
|
||||
</h2>
|
||||
<span className="text-[9px] text-[var(--text-dim)] font-mono">6 SUBSYSTEMS</span>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-1.5">
|
||||
{items.map((item, idx) => (
|
||||
<Card key={idx} compact className="flex flex-col gap-0.5 p-2">
|
||||
<CardHeader className="p-0 pb-0.5 mb-0 border-b-0 flex items-center gap-1.5">
|
||||
<div className="p-0.5 bg-[var(--bg-main)] text-[var(--accent)] border border-[var(--border-strong)] shrink-0">
|
||||
<Icon name={item.icon} size={11} />
|
||||
</div>
|
||||
<CardTitle className="text-[11px]">{item.title}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="p-0 text-[10px] text-[var(--text-muted)] leading-tight">
|
||||
{item.desc}
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Features;
|
||||
@@ -0,0 +1,90 @@
|
||||
'use client';
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { Button } from '@/components/ui/Button';
|
||||
import { Card } from '@/components/ui/Card';
|
||||
import { Icon } from '@/components/ui/Icon';
|
||||
|
||||
export const Hero: React.FC = () => {
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
const handleCopy = () => {
|
||||
navigator.clipboard.writeText('pip install ./sdk-python');
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2.5 py-1">
|
||||
{/* Title */}
|
||||
<div className="flex flex-col gap-1">
|
||||
<h1 className="text-[16px] sm:text-[18px] font-semibold tracking-tight text-[var(--text)]">
|
||||
Realtime Data Collection Platform
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
{/* Actions */}
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
<Link href="/vcon/dashboard">
|
||||
<Button size="xs" variant="primary" icon="Terminal">
|
||||
Console (/vcon/)
|
||||
</Button>
|
||||
</Link>
|
||||
<Link href="/vcon/data">
|
||||
<Button size="xs" variant="secondary" icon="Activity">
|
||||
Live Stream
|
||||
</Button>
|
||||
</Link>
|
||||
<div className="flex items-center gap-1.5 border border-[var(--border)] bg-[var(--bg-elevated)] px-2 py-0.5 text-[10px] font-mono text-[var(--text)]">
|
||||
<span className="text-[var(--text-dim)]">$</span>
|
||||
<span>pip install ./sdk-python</span>
|
||||
<button
|
||||
onClick={handleCopy}
|
||||
className="text-[var(--text-dim)] hover:text-[var(--text)] ml-0.5 cursor-pointer"
|
||||
aria-label="Copy install command"
|
||||
>
|
||||
<Icon name={copied ? 'Check' : 'Copy'} size={11} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 4 Clean Metric Cards */}
|
||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-1.5 pt-0.5">
|
||||
<Card compact className="p-2 flex flex-col gap-0.5 bg-[var(--bg-elevated)]">
|
||||
<div className="flex items-center justify-between text-[8.5px] uppercase tracking-wider text-[var(--text-dim)] font-medium">
|
||||
<span>Ingestion</span>
|
||||
<Icon name="Radio" size={11} className="text-[var(--accent)]" />
|
||||
</div>
|
||||
<span className="text-[12.5px] font-semibold text-[var(--text)] font-mono">:4000 (ws)</span>
|
||||
</Card>
|
||||
|
||||
<Card compact className="p-2 flex flex-col gap-0.5 bg-[var(--bg-elevated)]">
|
||||
<div className="flex items-center justify-between text-[8.5px] uppercase tracking-wider text-[var(--text-dim)] font-medium">
|
||||
<span>Web & API</span>
|
||||
<Icon name="LayoutDashboard" size={11} className="text-[var(--accent)]" />
|
||||
</div>
|
||||
<span className="text-[12.5px] font-semibold text-[var(--text)] font-mono">:3000 (http)</span>
|
||||
</Card>
|
||||
|
||||
<Card compact className="p-2 flex flex-col gap-0.5 bg-[var(--bg-elevated)]">
|
||||
<div className="flex items-center justify-between text-[8.5px] uppercase tracking-wider text-[var(--text-dim)] font-medium">
|
||||
<span>Storage Engine</span>
|
||||
<Icon name="HardDrive" size={11} className="text-[var(--accent)]" />
|
||||
</div>
|
||||
<span className="text-[12.5px] font-semibold text-[var(--text)] font-mono">Rotated CSV</span>
|
||||
</Card>
|
||||
|
||||
<Card compact className="p-2 flex flex-col gap-0.5 bg-[var(--bg-elevated)]">
|
||||
<div className="flex items-center justify-between text-[8.5px] uppercase tracking-wider text-[var(--text-dim)] font-medium">
|
||||
<span>Buffer Limit</span>
|
||||
<Icon name="Cpu" size={11} className="text-[var(--accent)]" />
|
||||
</div>
|
||||
<span className="text-[12.5px] font-semibold text-[var(--text)] font-mono">500 rows / 2s</span>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Hero;
|
||||
@@ -0,0 +1,9 @@
|
||||
# Sections Manifest
|
||||
|
||||
## Purpose
|
||||
Modular section blocks used in landing page and documentation views.
|
||||
|
||||
## Sections
|
||||
- `Hero.tsx`: Headline, technical metrics, quick start buttons
|
||||
- `Features.tsx`: Subsystem cards with icons and descriptions
|
||||
- `Architecture.tsx`: Visual diagram of decoupled port 4000/3000 runtime and data flow.
|
||||
@@ -0,0 +1,80 @@
|
||||
import React from 'react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Icon } from './Icon';
|
||||
|
||||
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
variant?: 'primary' | 'secondary' | 'ghost' | 'danger' | 'icon';
|
||||
size?: 'default' | 'sm' | 'xs' | 'icon';
|
||||
icon?: string;
|
||||
iconPosition?: 'left' | 'right';
|
||||
loading?: boolean;
|
||||
}
|
||||
|
||||
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
(
|
||||
{
|
||||
children,
|
||||
className,
|
||||
variant = 'secondary',
|
||||
size = 'default',
|
||||
icon,
|
||||
iconPosition = 'left',
|
||||
loading = false,
|
||||
disabled,
|
||||
...props
|
||||
},
|
||||
ref
|
||||
) => {
|
||||
const baseStyles =
|
||||
'inline-flex items-center justify-center font-normal transition-colors select-none cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed border border-transparent whitespace-nowrap outline-none';
|
||||
|
||||
const variantStyles = {
|
||||
primary:
|
||||
'bg-[var(--accent)] text-[var(--text-on-accent)] hover:bg-[var(--accent-hover)] border-[var(--accent)]',
|
||||
secondary:
|
||||
'bg-[var(--bg-elevated)] text-[var(--text)] border-[var(--border-strong)] hover:bg-[var(--bg-hover)]',
|
||||
ghost:
|
||||
'bg-transparent text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--bg-hover)] border-transparent',
|
||||
danger:
|
||||
'bg-transparent text-[var(--danger)] border-[var(--danger)] hover:bg-[var(--danger-soft)]',
|
||||
icon:
|
||||
'bg-transparent text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--bg-hover)] border-transparent p-0',
|
||||
};
|
||||
|
||||
const sizeStyles = {
|
||||
default: 'h-[32px] px-[14px] text-[12.5px] gap-[7px]',
|
||||
sm: 'h-[27px] px-[10px] text-[11.5px] gap-[5px]',
|
||||
xs: 'h-[24px] px-[7px] text-[10.5px] gap-[4px]',
|
||||
icon: 'w-[30px] h-[30px] p-0',
|
||||
};
|
||||
|
||||
return (
|
||||
<button
|
||||
ref={ref}
|
||||
disabled={disabled || loading}
|
||||
className={cn(
|
||||
baseStyles,
|
||||
variantStyles[variant],
|
||||
size === 'icon' ? sizeStyles.icon : sizeStyles[size],
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{loading ? (
|
||||
<Icon name="Loader2" size={size === 'sm' || size === 'xs' ? 12 : 14} className="animate-spin" />
|
||||
) : (
|
||||
icon && iconPosition === 'left' && (
|
||||
<Icon name={icon} size={size === 'sm' || size === 'xs' ? 12 : 14} />
|
||||
)
|
||||
)}
|
||||
{children && <span>{children}</span>}
|
||||
{!loading && icon && iconPosition === 'right' && (
|
||||
<Icon name={icon} size={size === 'sm' || size === 'xs' ? 12 : 14} />
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
Button.displayName = 'Button';
|
||||
export default Button;
|
||||
@@ -0,0 +1,100 @@
|
||||
import React from 'react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
variant?: 'default' | 'subtle' | 'dashed' | 'active';
|
||||
compact?: boolean;
|
||||
}
|
||||
|
||||
export const Card: React.FC<CardProps> = ({
|
||||
children,
|
||||
variant = 'default',
|
||||
compact = false,
|
||||
className,
|
||||
...props
|
||||
}) => {
|
||||
const variantStyles = {
|
||||
default: 'bg-[var(--bg-elevated)] border border-[var(--border)] text-[var(--text)]',
|
||||
subtle: 'bg-[var(--bg-main)] border border-[var(--border)] text-[var(--text)]',
|
||||
dashed: 'bg-[var(--bg-main)] border border-dashed border-[var(--border-strong)] text-[var(--text)]',
|
||||
active: 'bg-[var(--accent-soft)] border border-[var(--accent)] text-[var(--text)]',
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'transition-colors',
|
||||
variantStyles[variant],
|
||||
compact ? 'p-2.5' : 'p-3.5 sm:p-4',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const CardHeader: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => (
|
||||
<div
|
||||
className={cn(
|
||||
'flex items-center justify-between gap-2.5 pb-2.5 mb-2.5 border-b border-[var(--border)]',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
export const CardTitle: React.FC<React.HTMLAttributes<HTMLHeadingElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => (
|
||||
<h3 className={cn('text-[13px] font-semibold text-[var(--text)] leading-tight', className)} {...props}>
|
||||
{children}
|
||||
</h3>
|
||||
);
|
||||
|
||||
export const CardDescription: React.FC<React.HTMLAttributes<HTMLParagraphElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => (
|
||||
<p className={cn('text-[11px] text-[var(--text-muted)] leading-normal', className)} {...props}>
|
||||
{children}
|
||||
</p>
|
||||
);
|
||||
|
||||
export const CardContent: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => (
|
||||
<div className={cn('text-[12px]', className)} {...props}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
export const CardFooter: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => (
|
||||
<div
|
||||
className={cn(
|
||||
'flex items-center justify-between gap-2 pt-2.5 mt-2.5 border-t border-[var(--border)] text-[11px]',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
export default Card;
|
||||
@@ -0,0 +1,61 @@
|
||||
import React from 'react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export const Form: React.FC<React.FormHTMLAttributes<HTMLFormElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => (
|
||||
<form className={cn('flex flex-col gap-3', className)} {...props}>
|
||||
{children}
|
||||
</form>
|
||||
);
|
||||
|
||||
export const FormField: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => (
|
||||
<div className={cn('flex flex-col gap-1 w-full', className)} {...props}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
export const FormRow: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => (
|
||||
<div className={cn('grid grid-cols-1 sm:grid-cols-2 gap-3 w-full', className)} {...props}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
export const FormSwitch: React.FC<{
|
||||
label: string;
|
||||
checked: boolean;
|
||||
onChange: (checked: boolean) => void;
|
||||
description?: string;
|
||||
disabled?: boolean;
|
||||
}> = ({ label, checked, onChange, description, disabled = false }) => (
|
||||
<label
|
||||
className={cn(
|
||||
'flex items-center justify-between p-2.5 border border-[var(--border)] bg-[var(--bg-main)] cursor-pointer select-none transition-colors hover:bg-[var(--bg-hover)]',
|
||||
disabled && 'opacity-50 cursor-not-allowed'
|
||||
)}
|
||||
>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-[12px] font-medium text-[var(--text)]">{label}</span>
|
||||
{description && <span className="text-[10.5px] text-[var(--text-dim)]">{description}</span>}
|
||||
</div>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={checked}
|
||||
disabled={disabled}
|
||||
onChange={(e) => onChange(e.target.checked)}
|
||||
className="w-4 h-4 accent-[var(--accent)] cursor-pointer"
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
|
||||
export default Form;
|
||||
@@ -0,0 +1,36 @@
|
||||
import React from 'react';
|
||||
import * as LucideIcons from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export type IconName = keyof typeof LucideIcons;
|
||||
|
||||
interface IconProps {
|
||||
name: string;
|
||||
size?: number;
|
||||
className?: string;
|
||||
color?: string;
|
||||
}
|
||||
|
||||
export const Icon: React.FC<IconProps> = ({
|
||||
name,
|
||||
size = 14,
|
||||
className,
|
||||
color,
|
||||
}) => {
|
||||
const LucideIcon = (LucideIcons as unknown as Record<string, React.ComponentType<{ size?: number; className?: string; style?: React.CSSProperties }>>)[name];
|
||||
|
||||
if (!LucideIcon) {
|
||||
const Fallback = LucideIcons.Activity;
|
||||
return <Fallback size={size} className={cn('shrink-0 text-current', className)} style={{ color }} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<LucideIcon
|
||||
size={size}
|
||||
className={cn('shrink-0 text-current transition-colors', className)}
|
||||
style={{ color }}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default Icon;
|
||||
@@ -0,0 +1,136 @@
|
||||
import React from 'react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Icon } from './Icon';
|
||||
|
||||
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||
label?: string;
|
||||
error?: string;
|
||||
icon?: string;
|
||||
compact?: boolean;
|
||||
}
|
||||
|
||||
export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
||||
({ label, error, icon, compact = false, className, id, ...props }, ref) => {
|
||||
const inputId = id || (label ? label.toLowerCase().replace(/\s+/g, '-') : undefined);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1 w-full text-left">
|
||||
{label && (
|
||||
<label
|
||||
htmlFor={inputId}
|
||||
className="text-[10.5px] font-semibold text-[var(--text-muted)] uppercase tracking-wider"
|
||||
>
|
||||
{label}
|
||||
</label>
|
||||
)}
|
||||
<div className="relative flex items-center w-full">
|
||||
{icon && (
|
||||
<div className="absolute left-2.5 flex items-center pointer-events-none text-[var(--text-dim)]">
|
||||
<Icon name={icon} size={13} />
|
||||
</div>
|
||||
)}
|
||||
<input
|
||||
id={inputId}
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'w-full bg-[var(--bg-main)] text-[var(--text)] border border-[var(--border-strong)] placeholder:text-[var(--text-dim)] transition-colors focus:outline-none focus:border-[var(--accent)] disabled:opacity-50 disabled:cursor-not-allowed',
|
||||
compact ? 'h-[28px] px-2 text-[11px]' : 'h-[32px] px-2.5 text-[12px]',
|
||||
icon && 'pl-8',
|
||||
error && 'border-[var(--danger)]',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
{error && <span className="text-[10.5px] text-[var(--danger)]">{error}</span>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
Input.displayName = 'Input';
|
||||
|
||||
export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
||||
label?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
||||
({ label, error, className, id, ...props }, ref) => {
|
||||
const textareaId = id || (label ? label.toLowerCase().replace(/\s+/g, '-') : undefined);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1 w-full text-left">
|
||||
{label && (
|
||||
<label
|
||||
htmlFor={textareaId}
|
||||
className="text-[10.5px] font-semibold text-[var(--text-muted)] uppercase tracking-wider"
|
||||
>
|
||||
{label}
|
||||
</label>
|
||||
)}
|
||||
<textarea
|
||||
id={textareaId}
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'w-full bg-[var(--bg-main)] text-[var(--text)] border border-[var(--border-strong)] p-2.5 text-[12px] placeholder:text-[var(--text-dim)] focus:outline-none focus:border-[var(--accent)] min-h-[64px] resize-y font-mono',
|
||||
error && 'border-[var(--danger)]',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
{error && <span className="text-[10.5px] text-[var(--danger)]">{error}</span>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
Textarea.displayName = 'Textarea';
|
||||
|
||||
export interface SelectProps extends React.SelectHTMLAttributes<HTMLSelectElement> {
|
||||
label?: string;
|
||||
error?: string;
|
||||
compact?: boolean;
|
||||
options?: { value: string; label: string }[];
|
||||
}
|
||||
|
||||
export const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
|
||||
({ label, error, compact = false, options, children, className, id, ...props }, ref) => {
|
||||
const selectId = id || (label ? label.toLowerCase().replace(/\s+/g, '-') : undefined);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1 w-full text-left">
|
||||
{label && (
|
||||
<label
|
||||
htmlFor={selectId}
|
||||
className="text-[10.5px] font-semibold text-[var(--text-muted)] uppercase tracking-wider"
|
||||
>
|
||||
{label}
|
||||
</label>
|
||||
)}
|
||||
<select
|
||||
id={selectId}
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'w-full bg-[var(--bg-main)] text-[var(--text)] border border-[var(--border-strong)] focus:outline-none focus:border-[var(--accent)] cursor-pointer',
|
||||
compact ? 'h-[28px] px-1.5 text-[11px]' : 'h-[32px] px-2 text-[11.5px]',
|
||||
error && 'border-[var(--danger)]',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{options
|
||||
? options.map((opt) => (
|
||||
<option key={opt.value} value={opt.value} className="bg-[var(--bg-elevated)] text-[var(--text)]">
|
||||
{opt.label}
|
||||
</option>
|
||||
))
|
||||
: children}
|
||||
</select>
|
||||
{error && <span className="text-[10.5px] text-[var(--danger)]">{error}</span>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
Select.displayName = 'Select';
|
||||
@@ -0,0 +1,89 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Icon } from './Icon';
|
||||
import { Button } from './Button';
|
||||
|
||||
export interface ModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
title: string;
|
||||
description?: string;
|
||||
children: React.ReactNode;
|
||||
footer?: React.ReactNode;
|
||||
maxWidth?: 'sm' | 'md' | 'lg';
|
||||
}
|
||||
|
||||
export const Modal: React.FC<ModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
title,
|
||||
description,
|
||||
children,
|
||||
footer,
|
||||
maxWidth = 'md',
|
||||
}) => {
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && isOpen) {
|
||||
onClose();
|
||||
}
|
||||
};
|
||||
if (isOpen) {
|
||||
document.body.style.overflow = 'hidden';
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
}
|
||||
return () => {
|
||||
document.body.style.overflow = '';
|
||||
window.removeEventListener('keydown', handleKeyDown);
|
||||
};
|
||||
}, [isOpen, onClose]);
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
const maxWidthStyles = {
|
||||
sm: 'max-w-[440px]',
|
||||
md: 'max-w-[520px]',
|
||||
lg: 'max-w-[640px]',
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-3.5 bg-black/60 backdrop-blur-[1px]">
|
||||
<div
|
||||
className={cn(
|
||||
'w-full bg-[var(--bg-elevated)] border border-[var(--border-strong)] text-[var(--text)] flex flex-col max-h-[min(84dvh,680px)] overflow-hidden animate-in fade-in zoom-in-95 duration-100',
|
||||
maxWidthStyles[maxWidth]
|
||||
)}
|
||||
>
|
||||
<div className="flex items-start justify-between gap-3 p-3.5 sm:px-4 sm:py-3.5 border-b border-[var(--border)] shrink-0">
|
||||
<div className="min-w-0">
|
||||
<h2 className="text-[14px] font-semibold text-[var(--text)] leading-tight">{title}</h2>
|
||||
{description && (
|
||||
<p className="text-[11px] text-[var(--text-muted)] mt-1">{description}</p>
|
||||
)}
|
||||
</div>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
onClick={onClose}
|
||||
aria-label="Close dialog"
|
||||
className="w-7 h-7 text-[var(--text-dim)] hover:text-[var(--text)]"
|
||||
>
|
||||
<Icon name="X" size={14} />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="p-3.5 sm:p-4 overflow-y-auto flex-1 text-[12px] flex flex-col gap-3">
|
||||
{children}
|
||||
</div>
|
||||
|
||||
{footer && (
|
||||
<div className="flex items-center justify-end gap-2 p-3 sm:px-4 border-t border-[var(--border)] bg-[var(--bg-sidebar)] shrink-0">
|
||||
{footer}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Modal;
|
||||
@@ -0,0 +1,108 @@
|
||||
import React from 'react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export const TableWrap: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => (
|
||||
<div
|
||||
className={cn(
|
||||
'w-full overflow-x-auto border border-[var(--border)] bg-[var(--bg-elevated)]',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
export const Table: React.FC<React.TableHTMLAttributes<HTMLTableElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => (
|
||||
<table
|
||||
className={cn(
|
||||
'w-full min-w-[540px] border-collapse text-left text-[11px] whitespace-nowrap',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</table>
|
||||
);
|
||||
|
||||
export const TableHeader: React.FC<React.HTMLAttributes<HTMLTableSectionElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => (
|
||||
<thead
|
||||
className={cn(
|
||||
'bg-[var(--bg-sidebar)] border-b border-[var(--border)] text-[9.5px] font-semibold text-[var(--text-dim)] uppercase tracking-wider',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</thead>
|
||||
);
|
||||
|
||||
export const TableBody: React.FC<React.HTMLAttributes<HTMLTableSectionElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => <tbody className={cn('divide-y divide-[var(--border)]', className)} {...props}>{children}</tbody>;
|
||||
|
||||
export const TableRow: React.FC<React.HTMLAttributes<HTMLTableRowElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => (
|
||||
<tr
|
||||
className={cn(
|
||||
'transition-colors hover:bg-[var(--bg-hover)] text-[var(--text)]',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</tr>
|
||||
);
|
||||
|
||||
export const TableHead: React.FC<React.ThHTMLAttributes<HTMLTableCellElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => (
|
||||
<th className={cn('px-2.5 py-1.5 font-medium', className)} {...props}>
|
||||
{children}
|
||||
</th>
|
||||
);
|
||||
|
||||
export const TableCell: React.FC<React.TdHTMLAttributes<HTMLTableCellElement>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => (
|
||||
<td className={cn('px-2.5 py-1.5 text-[var(--text-muted)] align-middle', className)} {...props}>
|
||||
{children}
|
||||
</td>
|
||||
);
|
||||
|
||||
export const TableEmpty: React.FC<{ colSpan: number; message?: string }> = ({
|
||||
colSpan,
|
||||
message = 'No data available',
|
||||
}) => (
|
||||
<tr>
|
||||
<td
|
||||
colSpan={colSpan}
|
||||
className="px-3 py-6 text-center text-[10.5px] text-[var(--text-dim)] italic"
|
||||
>
|
||||
{message}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
|
||||
export default Table;
|
||||
@@ -0,0 +1,39 @@
|
||||
import React from 'react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface TextProps extends React.HTMLAttributes<HTMLElement> {
|
||||
as?: 'h1' | 'h2' | 'h3' | 'h4' | 'p' | 'span' | 'label' | 'code' | 'div';
|
||||
variant?: 'h1' | 'h2' | 'h3' | 'body' | 'muted' | 'dim' | 'label' | 'code' | 'badge';
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export const Text: React.FC<TextProps> = ({
|
||||
as: Component = 'p',
|
||||
variant = 'body',
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}) => {
|
||||
const variantStyles = {
|
||||
h1: 'text-[18px] font-semibold tracking-tight text-[var(--text)]',
|
||||
h2: 'text-[15px] font-semibold text-[var(--text)]',
|
||||
h3: 'text-[13px] font-medium text-[var(--text)]',
|
||||
body: 'text-[12.5px] font-normal text-[var(--text)]',
|
||||
muted: 'text-[11.5px] font-normal text-[var(--text-muted)]',
|
||||
dim: 'text-[10.5px] font-normal text-[var(--text-dim)]',
|
||||
label: 'text-[11px] font-medium uppercase tracking-wider text-[var(--text-dim)]',
|
||||
code: 'text-[11px] font-mono text-[var(--accent)] bg-[var(--bg-hover)] px-1.5 py-0.5 border border-[var(--border)]',
|
||||
badge: 'text-[10px] font-medium px-1.5 py-0.5 border border-[var(--border)] text-[var(--text-muted)] inline-flex items-center gap-1',
|
||||
};
|
||||
|
||||
return (
|
||||
<Component
|
||||
className={cn(variantStyles[variant], className)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</Component>
|
||||
);
|
||||
};
|
||||
|
||||
export default Text;
|
||||
@@ -0,0 +1,121 @@
|
||||
'use client';
|
||||
|
||||
import React, { createContext, useContext, useState, useCallback } from 'react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Icon } from './Icon';
|
||||
|
||||
export type ToastType = 'success' | 'error' | 'warning' | 'info';
|
||||
|
||||
export interface ToastMessage {
|
||||
id: string;
|
||||
type: ToastType;
|
||||
title: string;
|
||||
message?: string;
|
||||
duration?: number;
|
||||
}
|
||||
|
||||
interface ToastContextType {
|
||||
toast: (options: Omit<ToastMessage, 'id'>) => void;
|
||||
success: (title: string, message?: string) => void;
|
||||
error: (title: string, message?: string) => void;
|
||||
warning: (title: string, message?: string) => void;
|
||||
info: (title: string, message?: string) => void;
|
||||
}
|
||||
|
||||
const ToastContext = createContext<ToastContextType | undefined>(undefined);
|
||||
|
||||
export const ToastProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
const [toasts, setToasts] = useState<ToastMessage[]>([]);
|
||||
|
||||
const removeToast = useCallback((id: string) => {
|
||||
setToasts((prev) => prev.filter((t) => t.id !== id));
|
||||
}, []);
|
||||
|
||||
const addToast = useCallback(
|
||||
({ type = 'info', title, message, duration = 3500 }: Omit<ToastMessage, 'id'>) => {
|
||||
const id = `${Date.now()}-${Math.random().toString(36).substring(2, 7)}`;
|
||||
setToasts((prev) => [...prev, { id, type, title, message, duration }]);
|
||||
|
||||
if (duration > 0) {
|
||||
setTimeout(() => {
|
||||
removeToast(id);
|
||||
}, duration);
|
||||
}
|
||||
},
|
||||
[removeToast]
|
||||
);
|
||||
|
||||
const success = useCallback((title: string, message?: string) => addToast({ type: 'success', title, message }), [addToast]);
|
||||
const error = useCallback((title: string, message?: string) => addToast({ type: 'error', title, message }), [addToast]);
|
||||
const warning = useCallback((title: string, message?: string) => addToast({ type: 'warning', title, message }), [addToast]);
|
||||
const info = useCallback((title: string, message?: string) => addToast({ type: 'info', title, message }), [addToast]);
|
||||
|
||||
return (
|
||||
<ToastContext.Provider value={{ toast: addToast, success, error, warning, info }}>
|
||||
{children}
|
||||
<div className="fixed bottom-4 right-4 z-[9999] flex flex-col gap-2 max-w-[340px] pointer-events-none">
|
||||
{toasts.map((t) => {
|
||||
const typeBorder = {
|
||||
success: 'border-l-[3px] border-l-[var(--success)]',
|
||||
error: 'border-l-[3px] border-l-[var(--danger)]',
|
||||
warning: 'border-l-[3px] border-l-[var(--warning)]',
|
||||
info: 'border-l-[3px] border-l-[var(--accent)]',
|
||||
}[t.type];
|
||||
|
||||
const typeIcon = {
|
||||
success: 'CheckCircle2',
|
||||
error: 'AlertCircle',
|
||||
warning: 'AlertTriangle',
|
||||
info: 'Info',
|
||||
}[t.type];
|
||||
|
||||
const iconColor = {
|
||||
success: 'var(--success)',
|
||||
error: 'var(--danger)',
|
||||
warning: 'var(--warning)',
|
||||
info: 'var(--accent)',
|
||||
}[t.type];
|
||||
|
||||
return (
|
||||
<div
|
||||
key={t.id}
|
||||
className={cn(
|
||||
'pointer-events-auto flex items-start gap-2.5 p-3 bg-[var(--bg-elevated)] border border-[var(--border-strong)] text-[var(--text)] text-[12px] transition-all',
|
||||
typeBorder
|
||||
)}
|
||||
>
|
||||
<div className="mt-0.5 shrink-0">
|
||||
<Icon name={typeIcon} size={14} color={iconColor} />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="font-medium text-[var(--text)] leading-tight">{t.title}</div>
|
||||
{t.message && (
|
||||
<div className="text-[11px] text-[var(--text-muted)] mt-0.5 leading-normal break-words">
|
||||
{t.message}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
onClick={() => removeToast(t.id)}
|
||||
className="shrink-0 text-[var(--text-dim)] hover:text-[var(--text)] p-0.5 cursor-pointer"
|
||||
aria-label="Dismiss toast"
|
||||
>
|
||||
<Icon name="X" size={12} />
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</ToastContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useToast = () => {
|
||||
const context = useContext(ToastContext);
|
||||
if (!context) {
|
||||
throw new Error('useToast must be used within a ToastProvider');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
||||
export default ToastProvider;
|
||||
@@ -0,0 +1,9 @@
|
||||
export * from './Button';
|
||||
export * from './Input';
|
||||
export * from './Card';
|
||||
export * from './Modal';
|
||||
export * from './Table';
|
||||
export * from './Form';
|
||||
export * from './Text';
|
||||
export * from './Icon';
|
||||
export * from './Toast';
|
||||
@@ -0,0 +1,19 @@
|
||||
# UI Components Module Manifest
|
||||
|
||||
## Purpose
|
||||
Unified, zero-pill, zero-shadow compact UI design system following the DataStack design guidelines.
|
||||
|
||||
## Components
|
||||
- **Button.tsx**: Standardised buttons with size variants (default 32px, sm 27px, xs 24px, icon 30px), zero border-radius, outline focus.
|
||||
- **Input.tsx**: Inputs, Textareas, and Selects with consistent border token and Segoe UI typography.
|
||||
- **Card.tsx**: Structured data container surfaces with zero radius, 1px subtle borders, and header/content/footer partitions.
|
||||
- **Modal.tsx**: Accessible dialogs with key listener (Escape), backdrop blur, and flexible action footers.
|
||||
- **Table.tsx**: Compact fixed data tables for real-time streams, client listings, and export jobs.
|
||||
- **Form.tsx**: Form wrappers, switch toggles, and multi-column row layouts.
|
||||
- **Text.tsx**: Typography engine providing hierarchy (h1, h2, h3, body, muted, dim, label, code, badge).
|
||||
- **Icon.tsx**: Lucide-react wrapper for icon rendering.
|
||||
- **Toast.tsx**: Real-time notification and error/success/warning report system.
|
||||
|
||||
## Dependencies
|
||||
- `lucide-react`
|
||||
- `@/lib/utils` (clsx + tailwind-merge)
|
||||
Reference in new issue
Block a user