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:
Md Najmul committed 2026-10-23 11:43:49 -05:00
1 parent 50449e96ad
commit d39d9f92f9
139 files changed
+10982 -6

No files matched your search

+80
View File
@@ -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;
+100
View File
@@ -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;
+61
View File
@@ -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;
+36
View File
@@ -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;
+136
View File
@@ -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';
+89
View File
@@ -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;
+108
View File
@@ -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;
+39
View File
@@ -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;
+121
View File
@@ -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;
+9
View File
@@ -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';
+19
View File
@@ -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)