merge: integration/student-member-list 동기화 (design 레인 공용 컴포넌트 반영)
design 레인이 병렬로 완료한 Button/Input/Select/Table/Pagination/Modal/Field/ RadioGroup을 integration에서 받아와 학생 회원 화면의 타입 에러를 실제로 해소한다.
@ab2fce81f11653d920fd41d292d60ecb2ae32591
+++ components/ui/field.tsx
... | ... | @@ -0,0 +1,21 @@ |
| 1 | +import type { ReactNode } from "react"; | |
| 2 | + | |
| 3 | +interface FieldProps { | |
| 4 | + label: string; | |
| 5 | + children: ReactNode; | |
| 6 | + /** 배치(레이아웃) 조정용 클래스 패스스루만 허용 — 디자인 값 주입 금지. */ | |
| 7 | + className?: string; | |
| 8 | +} | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 폼 라벨 + 값 배치. `<label>`이 children을 함께 감싸 암시적 라벨 연결(implicit label)을 | |
| 12 | + * 제공한다 — 조회 팝업에서 readOnly `Input`을 감싸는 용도. | |
| 13 | + */ | |
| 14 | +export function Field({ label, children, className }: FieldProps) { | |
| 15 | + return ( | |
| 16 | + <label className={`flex flex-col gap-1 ${className ?? ""}`}> | |
| 17 | + <span className="text-label-md text-foreground-muted">{label}</span> | |
| 18 | + {children} | |
| 19 | + </label> | |
| 20 | + ); | |
| 21 | +} |
+++ components/ui/input.tsx
... | ... | @@ -0,0 +1,16 @@ |
| 1 | +import type { ComponentProps } from "react"; | |
| 2 | + | |
| 3 | +type InputProps = ComponentProps<"input">; | |
| 4 | + | |
| 5 | +/** 기본 텍스트 입력. `readOnly`일 때 배경 톤 + 기본 커서로 편집 불가 상태를 시각 구분한다. */ | |
| 6 | +export function Input({ className, readOnly, ...props }: InputProps) { | |
| 7 | + return ( | |
| 8 | + <input | |
| 9 | + readOnly={readOnly} | |
| 10 | + className={`h-10 w-full rounded-md border border-border px-3 text-body-md text-foreground placeholder:text-foreground-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:pointer-events-none disabled:opacity-50 ${ | |
| 11 | + readOnly ? "cursor-default bg-surface-muted" : "bg-surface" | |
| 12 | + } ${className ?? ""}`} | |
| 13 | + {...props} | |
| 14 | + /> | |
| 15 | + ); | |
| 16 | +} |
+++ components/ui/modal.tsx
... | ... | @@ -0,0 +1,62 @@ |
| 1 | +"use client"; | |
| 2 | + | |
| 3 | +import { useEffect, useId, type ReactNode } from "react"; | |
| 4 | +import { IconButton } from "@/components/ui/icon-button"; | |
| 5 | + | |
| 6 | +interface ModalProps { | |
| 7 | + title: string; | |
| 8 | + children: ReactNode; | |
| 9 | + footer?: ReactNode; | |
| 10 | + /** scrim 클릭·ESC·닫기 버튼에서 호출된다. 실제로 마운트 해제할지는 호출부(feature) 책임. */ | |
| 11 | + onClose: () => void; | |
| 12 | +} | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * 조회/입력 팝업 셸(scrim + 패널). 열림 여부는 호출부가 마운트/언마운트로 제어한다. | |
| 16 | + * alert.tsx(확인 다이얼로그)와 달리 폼 필드를 담는 용도라 ESC 키·scrim 클릭·닫기 버튼에서 | |
| 17 | + * onClose를 호출하는 상호작용을 자체적으로 가진다 — 그래서 이 컴포넌트만 'use client'. | |
| 18 | + * 포커스 트랩은 다루지 않는다(호출부 책임). | |
| 19 | + */ | |
| 20 | +export function Modal({ title, children, footer, onClose }: ModalProps) { | |
| 21 | + const titleId = useId(); | |
| 22 | + | |
| 23 | + useEffect(() => { | |
| 24 | + function handleKeyDown(event: KeyboardEvent) { | |
| 25 | + if (event.key === "Escape") { | |
| 26 | + onClose(); | |
| 27 | + } | |
| 28 | + } | |
| 29 | + document.addEventListener("keydown", handleKeyDown); | |
| 30 | + return () => { | |
| 31 | + document.removeEventListener("keydown", handleKeyDown); | |
| 32 | + }; | |
| 33 | + }, [onClose]); | |
| 34 | + | |
| 35 | + return ( | |
| 36 | + <div | |
| 37 | + className="fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4" | |
| 38 | + onClick={onClose} | |
| 39 | + > | |
| 40 | + <div | |
| 41 | + role="dialog" | |
| 42 | + aria-modal="true" | |
| 43 | + aria-labelledby={titleId} | |
| 44 | + onClick={(event) => event.stopPropagation()} | |
| 45 | + className="w-full max-w-lg animate-dialog-in rounded-xl bg-surface p-6 shadow-dialog" | |
| 46 | + > | |
| 47 | + <div className="flex items-center justify-between gap-4"> | |
| 48 | + <h2 id={titleId} className="text-title-lg text-foreground"> | |
| 49 | + {title} | |
| 50 | + </h2> | |
| 51 | + <IconButton label="닫기" onClick={onClose}> | |
| 52 | + <span aria-hidden="true" className="text-title-md leading-none"> | |
| 53 | + × | |
| 54 | + </span> | |
| 55 | + </IconButton> | |
| 56 | + </div> | |
| 57 | + <div className="mt-4">{children}</div> | |
| 58 | + {footer && <div className="mt-6 flex justify-end gap-2">{footer}</div>} | |
| 59 | + </div> | |
| 60 | + </div> | |
| 61 | + ); | |
| 62 | +} |
+++ components/ui/pagination.tsx
... | ... | @@ -0,0 +1,109 @@ |
| 1 | +import Link from "next/link"; | |
| 2 | +import type { ReactNode } from "react"; | |
| 3 | + | |
| 4 | +interface PaginationProps { | |
| 5 | + /** 1-based. */ | |
| 6 | + currentPage: number; | |
| 7 | + totalPages: number; | |
| 8 | + /** 각 페이지 번호로 이동할 href를 만들어 준다 — 라우팅은 소비처 책임. */ | |
| 9 | + buildHref: (page: number) => string; | |
| 10 | + /** 한 번에 보여줄 번호 개수. 기본 5. */ | |
| 11 | + windowSize?: number; | |
| 12 | +} | |
| 13 | + | |
| 14 | +const ITEM_CLASSES = | |
| 15 | + "inline-flex size-9 items-center justify-center rounded-md text-body-sm transition-colors duration-200"; | |
| 16 | +const ENABLED_CLASSES = "text-foreground-muted hover:bg-surface-muted hover:text-foreground"; | |
| 17 | +const DISABLED_CLASSES = "text-foreground-subtle opacity-50"; | |
| 18 | +const CURRENT_CLASSES = "bg-primary text-on-primary"; | |
| 19 | + | |
| 20 | +/** 현재 페이지를 중심으로 windowSize개 번호를 [1, totalPages] 범위 안에서 슬라이딩한다. */ | |
| 21 | +function getPageWindow(currentPage: number, totalPages: number, windowSize: number): number[] { | |
| 22 | + if (totalPages < 1) { | |
| 23 | + return []; | |
| 24 | + } | |
| 25 | + const half = Math.floor(windowSize / 2); | |
| 26 | + let start = Math.max(1, currentPage - half); | |
| 27 | + const end = Math.min(totalPages, start + windowSize - 1); | |
| 28 | + start = Math.max(1, end - windowSize + 1); | |
| 29 | + | |
| 30 | + const pages: number[] = []; | |
| 31 | + for (let page = start; page <= end; page += 1) { | |
| 32 | + pages.push(page); | |
| 33 | + } | |
| 34 | + return pages; | |
| 35 | +} | |
| 36 | + | |
| 37 | +interface PaginationItemProps { | |
| 38 | + disabled: boolean; | |
| 39 | + href: string; | |
| 40 | + label: string; | |
| 41 | + children: ReactNode; | |
| 42 | +} | |
| 43 | + | |
| 44 | +/** 처음·이전·다음·끝 이동 항목 — 비활성일 때는 링크 대신 aria-disabled span으로 렌더한다. */ | |
| 45 | +function PaginationItem({ disabled, href, label, children }: PaginationItemProps) { | |
| 46 | + if (disabled) { | |
| 47 | + return ( | |
| 48 | + <span aria-disabled="true" aria-label={label} className={`${ITEM_CLASSES} ${DISABLED_CLASSES}`}> | |
| 49 | + {children} | |
| 50 | + </span> | |
| 51 | + ); | |
| 52 | + } | |
| 53 | + return ( | |
| 54 | + <Link href={href} aria-label={label} className={`${ITEM_CLASSES} ${ENABLED_CLASSES}`}> | |
| 55 | + {children} | |
| 56 | + </Link> | |
| 57 | + ); | |
| 58 | +} | |
| 59 | + | |
| 60 | +/** | |
| 61 | + * 페이지네이션 — « ‹ [번호들] › ». 페이지 이동은 `next/link` href 기반이며 실제 라우팅(쿼리 | |
| 62 | + * 구성 등)은 `buildHref`를 통해 호출부(feature)가 책임진다. 첫/마지막 페이지에서는 처음·이전· | |
| 63 | + * 다음·끝 이동이 비활성 처리된다. | |
| 64 | + */ | |
| 65 | +export function Pagination({ | |
| 66 | + currentPage, | |
| 67 | + totalPages, | |
| 68 | + buildHref, | |
| 69 | + windowSize = 5, | |
| 70 | +}: PaginationProps) { | |
| 71 | + const pages = getPageWindow(currentPage, totalPages, windowSize); | |
| 72 | + const isFirst = currentPage <= 1; | |
| 73 | + const isLast = currentPage >= totalPages; | |
| 74 | + | |
| 75 | + return ( | |
| 76 | + <nav aria-label="페이지네이션" className="flex items-center justify-center gap-1"> | |
| 77 | + <PaginationItem disabled={isFirst} href={buildHref(1)} label="처음 페이지"> | |
| 78 | + « | |
| 79 | + </PaginationItem> | |
| 80 | + <PaginationItem | |
| 81 | + disabled={isFirst} | |
| 82 | + href={buildHref(Math.max(1, currentPage - 1))} | |
| 83 | + label="이전 페이지" | |
| 84 | + > | |
| 85 | + ‹ | |
| 86 | + </PaginationItem> | |
| 87 | + {pages.map((page) => ( | |
| 88 | + <Link | |
| 89 | + key={page} | |
| 90 | + href={buildHref(page)} | |
| 91 | + aria-current={page === currentPage ? "page" : undefined} | |
| 92 | + className={`${ITEM_CLASSES} ${page === currentPage ? CURRENT_CLASSES : ENABLED_CLASSES}`} | |
| 93 | + > | |
| 94 | + {page} | |
| 95 | + </Link> | |
| 96 | + ))} | |
| 97 | + <PaginationItem | |
| 98 | + disabled={isLast} | |
| 99 | + href={buildHref(Math.min(totalPages, currentPage + 1))} | |
| 100 | + label="다음 페이지" | |
| 101 | + > | |
| 102 | + › | |
| 103 | + </PaginationItem> | |
| 104 | + <PaginationItem disabled={isLast} href={buildHref(totalPages)} label="마지막 페이지"> | |
| 105 | + » | |
| 106 | + </PaginationItem> | |
| 107 | + </nav> | |
| 108 | + ); | |
| 109 | +} |
+++ components/ui/radio-group.tsx
... | ... | @@ -0,0 +1,40 @@ |
| 1 | +interface RadioGroupOption { | |
| 2 | + value: string; | |
| 3 | + label: string; | |
| 4 | +} | |
| 5 | + | |
| 6 | +interface RadioGroupProps { | |
| 7 | + name: string; | |
| 8 | + options: RadioGroupOption[]; | |
| 9 | + defaultValue?: string; | |
| 10 | + disabled?: boolean; | |
| 11 | +} | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 네이티브 라디오 그룹(비제어) — 폼 제출 시 `name` 필드로 선택값이 함께 전달된다. | |
| 15 | + * React 상태를 가지지 않으므로 `'use client'`가 필요 없다. | |
| 16 | + */ | |
| 17 | +export function RadioGroup({ name, options, defaultValue, disabled = false }: RadioGroupProps) { | |
| 18 | + return ( | |
| 19 | + <div role="radiogroup" className="flex items-center gap-4"> | |
| 20 | + {options.map((option) => ( | |
| 21 | + <label | |
| 22 | + key={option.value} | |
| 23 | + className={`flex items-center gap-2 text-body-md ${ | |
| 24 | + disabled ? "text-foreground-subtle opacity-50" : "text-foreground" | |
| 25 | + }`} | |
| 26 | + > | |
| 27 | + <input | |
| 28 | + type="radio" | |
| 29 | + name={name} | |
| 30 | + value={option.value} | |
| 31 | + defaultChecked={option.value === defaultValue} | |
| 32 | + disabled={disabled} | |
| 33 | + className="size-4 accent-primary" | |
| 34 | + /> | |
| 35 | + {option.label} | |
| 36 | + </label> | |
| 37 | + ))} | |
| 38 | + </div> | |
| 39 | + ); | |
| 40 | +} |
+++ components/ui/select.tsx
... | ... | @@ -0,0 +1,13 @@ |
| 1 | +import type { ComponentProps } from "react"; | |
| 2 | + | |
| 3 | +type SelectProps = ComponentProps<"select">; | |
| 4 | + | |
| 5 | +/** 네이티브 `<select>` 래퍼(라이브러리 미사용) — 브라우저 기본 표시(화살표 등)를 그대로 쓴다. */ | |
| 6 | +export function Select({ className, ...props }: SelectProps) { | |
| 7 | + return ( | |
| 8 | + <select | |
| 9 | + className={`h-10 rounded-md border border-border bg-surface px-3 text-body-md text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:pointer-events-none disabled:opacity-50 ${className ?? ""}`} | |
| 10 | + {...props} | |
| 11 | + /> | |
| 12 | + ); | |
| 13 | +} |
+++ 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?