"use client"; import { Badge } from "@suphark/ui/components/ui/badge"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@suphark/ui/components/ui/card"; import { Kbd, KbdGroup } from "@suphark/ui/components/ui/kbd"; import { TYPOGRAPHY_ROLES } from "@suphark/ui/lib/typography"; import { AlignLeft, Check, Copy, Info, Palette, Type } from "lucide-react"; import * as React from "react"; export function ShowcaseFoundations() { const [copiedToken, setCopiedToken] = React.useState(null); const copyToClipboard = (text: string) => { navigator.clipboard.writeText(text); setCopiedToken(text); setTimeout(() => setCopiedToken(null), 2000); }; const coreTokens = [ { name: "Background", class: "bg-background text-foreground border", token: "var(--background)", tailwind: "bg-background / text-foreground", usage: "Canvas หลักของหน้าเว็บ และสีข้อความตั้งต้น", }, { name: "Card", class: "bg-card text-card-foreground border", token: "var(--card)", tailwind: "bg-card / text-card-foreground", usage: "พื้นผิวของ Panels, Table Containers, และ Modal Surfaces", }, { name: "Primary", class: "bg-primary text-primary-foreground", token: "var(--primary)", tailwind: "bg-primary / text-primary-foreground", usage: "Primary actions, ปุ่มเน้นหลัก, Active Tab, และ Brand Accent", }, { name: "Secondary", class: "bg-secondary text-secondary-foreground border", token: "var(--secondary)", tailwind: "bg-secondary / text-secondary-foreground", usage: "Supporting actions, Secondary badges, และ Subtle highlight", }, { name: "Muted", class: "bg-muted text-muted-foreground border", token: "var(--muted)", tailwind: "bg-muted / text-muted-foreground", usage: "Skeleton placeholders, Subdued sections, Helper text", }, { name: "Destructive", class: "bg-destructive text-destructive-foreground", token: "var(--destructive)", tailwind: "bg-destructive / text-destructive", usage: "Irreversible actions, Delete confirmation, Error callouts", }, { name: "Success", class: "bg-success text-success-foreground", token: "var(--success)", tailwind: "bg-success / text-success-foreground", usage: "Approved status, Success badges, Positive rate variance", }, { name: "Info", class: "bg-info text-info-foreground", token: "var(--info)", tailwind: "bg-info / text-info-foreground / text-info", usage: "ข้อมูลประกอบ, รายการที่เลือก, ลิงก์ช่วยเหลือ — แทน sky-* ที่แอปเขียนเอง", }, { name: "Tone subtle (info / success / warning / destructive)", class: "bg-info-subtle text-info-subtle-foreground border border-info-border", token: "var(--{tone}-subtle) / var(--{tone}-border)", tailwind: "bg-{tone}-subtle / text-{tone}-subtle-foreground / border-{tone}-border", usage: "พื้นอ่อนของ Notice, StatusBadge, callout — สลับ dark ให้เอง ไม่ต้องใส่ dark: เอง", }, { name: "Border / Input / Ring", class: "bg-card text-foreground border-2 border-ring", token: "var(--border) / var(--ring)", tailwind: "border-border / border-input / ring-ring", usage: "เส้นขอบ component, input outline, และ accessible focus rings", }, ]; const sidebarTokens = [ { name: "Sidebar Background", class: "bg-sidebar text-sidebar-foreground border", token: "var(--sidebar)", }, { name: "Sidebar Primary", class: "bg-sidebar-primary text-sidebar-primary-foreground", token: "var(--sidebar-primary)", }, { name: "Sidebar Accent", class: "bg-sidebar-accent text-sidebar-accent-foreground border", token: "var(--sidebar-accent)", }, { name: "Sidebar Border", class: "bg-sidebar-border h-4 w-full rounded", token: "var(--sidebar-border)", }, ]; const chartTokens = [ { name: "Chart 1 (Orange/Amber)", class: "bg-chart-1 text-white", token: "var(--chart-1)" }, { name: "Chart 2 (Teal/Cyan)", class: "bg-chart-2 text-white", token: "var(--chart-2)" }, { name: "Chart 3 (Slate/Blue)", class: "bg-chart-3 text-white", token: "var(--chart-3)" }, { name: "Chart 4 (Yellow/Gold)", class: "bg-chart-4 text-black", token: "var(--chart-4)" }, { name: "Chart 5 (Red/Rose)", class: "bg-chart-5 text-white", token: "var(--chart-5)" }, ]; // ตัวอย่างข้อความของแต่ละบทบาท — ขนาด/ชื่อบทบาทมาจาก TYPOGRAPHY_ROLES (แหล่งเดียวกับ styles.css) const samples: Record = { "text-title-lg": "Bidding Package Review & Award", "text-title": "Vendor Qualification & Price Breakdown", "text-subtitle": "Material Specification & BOQ Rates", "text-body": "All bids submitted before the deadline are subject to procurement committee review.", "text-caption": "Last modified by procurement.manager@example.com • 15 mins ago", "text-label": "PROCUREMENT STATUS", }; const spatialRules = [ { title: "Flex Spacing over space-x/y", rule: "ใช้ flex flex-col gap-4 หรือ grid gap-4", reason: "Tailwind v4 และ modern layout รองรับ gap ได้ดีกว่า และไม่เจอปัญหามาร์จิ้นเพี้ยนเมื่อมี conditional children", }, { title: "Square Proportions (size-*)", rule: "ใช้ size-8, size-10 แทน w-8 h-8", reason: "กระชับ ชัดเจน และลดความผิดพลาดเรื่องอัตราส่วน 1:1 ของ Avatar, Icon Button และ Media boxes", }, { title: "Text Truncation & Flex Shrink", rule: "ใช้ min-w-0 truncate บน flex child", reason: "ป้องกันข้อความยาวล้นหน้าจอ (Text Overflow) ใน Table cell และ Toolbar", }, { title: "No Arbitrary Text Sizes", rule: "ใช้ text-xs / text-sm / text-base แทน text-xs", reason: "รักษา Vertical Rhythm และความสม่ำเสมอของสายตาทั้งระบบ", }, ]; return (
{/* Section Header */}
Foundations Tokens, Typography & Spatial Layout

ระบบโทเค็น ฟอนต์ และมิติพื้นฐาน

ควบคุมธีม Light / Dark mode และความสอดคล้องของหน้าจอทั้งหมดจากศูนย์กลางที่ globals.css

{/* Semantic Color Tokens */}

Semantic Color Tokens

คลิกที่การ์ดเพื่อ Copy ชื่อ Tailwind utility ไปใช้งาน

{coreTokens.map((token) => (
copyToClipboard(token.tailwind)} className="group relative flex flex-col gap-2.5 rounded-lg border bg-card p-3 shadow-2xs transition-all hover:border-primary/50 hover:shadow-xs cursor-pointer" >
{token.name} {copiedToken === token.tailwind ? ( ) : ( )}
{token.tailwind}

{token.usage}

))}
{/* Sidebar & Chart Tokens */}
{/* Sidebar Tokens */} Sidebar Palette Tokens โทเค็นสำหรับ Navigation Sidebar ทั้งโหมดพับและขยาย {sidebarTokens.map((item) => (
{item.name}
{item.token}
))}
{/* Chart Tokens */} Chart Palette Tokens ชุดสี 5 ลำดับสำหรับกราฟ Recharts และ Data Visualizations {chartTokens.map((item) => (
{item.name.slice(6, 7)}
chart-{item.name.slice(6, 7)}
))}
{/* Typography Scale */}

Typography Hierarchy (Noto Sans Thai Looped)

ลำดับชั้นของตัวอักษรที่รองรับทั้งภาษาไทยและอังกฤษอย่างคมชัดบนทุกขนาดหน้าจอ

{TYPOGRAPHY_ROLES.map((item) => (
{item.name} {item.className}
{item.mobile === item.desktop ? item.mobile : `${item.mobile} → ${item.desktop} (≥ 48rem)`}

{item.usage}

{samples[item.className]}
))}
{/* Spatial, Keyboard & Layout Rules */}
{/* Spatial Rules */} Spatial & Spacing Rules กฎเกณฑ์การจัดช่องว่างและสัดส่วนเลย์เอาต์ {spatialRules.map((rule) => (
{rule.title} {rule.rule}

{rule.reason}

))}
{/* Keyboard Shortcuts & Kbd Primitives */} Keyboard Shortcuts (Kbd Primitive) แสดงปุ่มคีย์ลัดสำหรับผู้ใช้และ Accessibility Navigation
Quick Search / Global Command ⌘ K
Save Form / Submit Package Ctrl S
Close Dialog / Clear Filter Esc
Next Table Row / Field Tab
); }