feat: 테이블 공용 컴포넌트 추가
Co-Authored-By: Claude Opus 5
@31da77806b6b38134a2143066454d3a0beeb16ab
+++ components/ui/table.tsx
... | ... | @@ -0,0 +1,61 @@ |
| 1 | +import type { ReactNode } from "react"; | |
| 2 | + | |
| 3 | +interface TableProps { | |
| 4 | + children: ReactNode; | |
| 5 | + /** 배치(레이아웃) 조정용 클래스 패스스루만 허용 — 디자인 값 주입 금지. */ | |
| 6 | + className?: string; | |
| 7 | +} | |
| 8 | + | |
| 9 | +/** 테이블 컨테이너 — 가로 스크롤 래퍼(`overflow-x-auto`) + `<table>`. */ | |
| 10 | +export function Table({ children, className }: TableProps) { | |
| 11 | + return ( | |
| 12 | + <div className={`w-full overflow-x-auto ${className ?? ""}`}> | |
| 13 | + <table className="w-full border-collapse text-body-sm text-foreground">{children}</table> | |
| 14 | + </div> | |
| 15 | + ); | |
| 16 | +} | |
| 17 | + | |
| 18 | +interface TableSectionProps { | |
| 19 | + children: ReactNode; | |
| 20 | +} | |
| 21 | + | |
| 22 | +/** 테이블 헤더 영역(`<thead>`). */ | |
| 23 | +export function TableHead({ children }: TableSectionProps) { | |
| 24 | + return <thead className="bg-surface-muted">{children}</thead>; | |
| 25 | +} | |
| 26 | + | |
| 27 | +/** 테이블 본문 영역(`<tbody>`). */ | |
| 28 | +export function TableBody({ children }: TableSectionProps) { | |
| 29 | + return <tbody>{children}</tbody>; | |
| 30 | +} | |
| 31 | + | |
| 32 | +interface TableRowProps { | |
| 33 | + children: ReactNode; | |
| 34 | + className?: string; | |
| 35 | +} | |
| 36 | + | |
| 37 | +/** 테이블 행(`<tr>`) — 아래쪽 구분선을 기본으로 갖는다. */ | |
| 38 | +export function TableRow({ children, className }: TableRowProps) { | |
| 39 | + return <tr className={`border-b border-border ${className ?? ""}`}>{children}</tr>; | |
| 40 | +} | |
| 41 | + | |
| 42 | +interface TableCellProps { | |
| 43 | + children: ReactNode; | |
| 44 | + className?: string; | |
| 45 | +} | |
| 46 | + | |
| 47 | +/** 헤더 셀(`<th>`). */ | |
| 48 | +export function TableHeaderCell({ children, className }: TableCellProps) { | |
| 49 | + return ( | |
| 50 | + <th | |
| 51 | + className={`px-3 py-2 text-left text-label-md text-foreground-muted ${className ?? ""}`} | |
| 52 | + > | |
| 53 | + {children} | |
| 54 | + </th> | |
| 55 | + ); | |
| 56 | +} | |
| 57 | + | |
| 58 | +/** 본문 셀(`<td>`). */ | |
| 59 | +export function TableCell({ children, className }: TableCellProps) { | |
| 60 | + return <td className={`px-3 py-2 text-body-sm ${className ?? ""}`}>{children}</td>; | |
| 61 | +} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?