diff --git a/apps/web/README.md b/apps/web/README.md deleted file mode 100644 index c300135..0000000 --- a/apps/web/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# React + TypeScript + Vite - -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. - -Currently, two official plugins are available: - -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs) -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) - -## React Compiler - -The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). - -## Expanding the ESLint configuration - -If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: - -```js -export default defineConfig([ - globalIgnores(['dist']), - { - files: ['**/*.{ts,tsx}'], - extends: [ - // Other configs... - - // Remove tseslint.configs.recommended and replace with this - tseslint.configs.recommendedTypeChecked, - // Alternatively, use this for stricter rules - tseslint.configs.strictTypeChecked, - // Optionally, add this for stylistic rules - tseslint.configs.stylisticTypeChecked, - - // Other configs... - ], - languageOptions: { - parserOptions: { - project: ['./tsconfig.node.json', './tsconfig.app.json'], - tsconfigRootDir: import.meta.dirname, - }, - // other options... - }, - }, -]) - -``` - -You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: - -```js -// eslint.config.js -import reactX from 'eslint-plugin-react-x' -import reactDom from 'eslint-plugin-react-dom' - -export default defineConfig([ - globalIgnores(['dist']), - { - files: ['**/*.{ts,tsx}'], - extends: [ - // Other configs... - // Enable lint rules for React - reactX.configs['recommended-typescript'], - // Enable lint rules for React DOM - reactDom.configs.recommended, - ], - languageOptions: { - parserOptions: { - project: ['./tsconfig.node.json', './tsconfig.app.json'], - tsconfigRootDir: import.meta.dirname, - }, - // other options... - }, - }, -]) - -``` diff --git a/apps/web/eslint.config.js b/apps/web/eslint.config.js index ef614d2..4b7f5c4 100644 --- a/apps/web/eslint.config.js +++ b/apps/web/eslint.config.js @@ -19,4 +19,12 @@ export default defineConfig([ globals: globals.browser, }, }, + { + // StyleSeed 엔진 (벤더 코드) — shadcn식 variant export·matchMedia 구독 패턴 허용 + files: ['src/components/ui/**', 'src/motion/**'], + rules: { + 'react-refresh/only-export-components': 'off', + 'react-hooks/set-state-in-effect': 'off', + }, + }, ]) diff --git a/apps/web/index.html b/apps/web/index.html index 050ad51..39550cf 100644 --- a/apps/web/index.html +++ b/apps/web/index.html @@ -4,8 +4,8 @@ - - persona-lenz + + PersonaLenz
diff --git a/apps/web/package.json b/apps/web/package.json index 80e9109..642ebe4 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -12,13 +12,39 @@ }, "dependencies": { "@persona-lenz/shared": "workspace:*", + "@radix-ui/react-accordion": "^1.2.3", + "@radix-ui/react-avatar": "^1.1.3", + "@radix-ui/react-checkbox": "^1.1.4", + "@radix-ui/react-dialog": "^1.1.6", + "@radix-ui/react-dropdown-menu": "^2.1.6", + "@radix-ui/react-label": "^2.1.2", + "@radix-ui/react-popover": "^1.1.6", + "@radix-ui/react-progress": "^1.1.2", + "@radix-ui/react-radio-group": "^1.2.3", + "@radix-ui/react-scroll-area": "^1.2.3", + "@radix-ui/react-select": "^2.1.6", + "@radix-ui/react-separator": "^1.1.2", + "@radix-ui/react-slot": "^1.1.2", + "@radix-ui/react-switch": "^1.1.3", + "@radix-ui/react-tabs": "^1.1.3", + "@radix-ui/react-toggle": "^1.1.2", + "@radix-ui/react-toggle-group": "^1.1.2", + "@radix-ui/react-tooltip": "^1.1.8", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "framer-motion": "^12.23.0", + "lucide-react": "^0.487.0", "react": "^19.2.7", "react-dom": "^19.2.7", + "react-hook-form": "^7.55.0", "react-router-dom": "^7.18.1", - "recharts": "^3.9.1" + "recharts": "^3.9.1", + "tailwind-merge": "^3.2.0", + "tw-animate-css": "^1.3.8" }, "devDependencies": { "@eslint/js": "^10.0.1", + "@tailwindcss/vite": "^4.1.0", "@types/node": "^24.13.2", "@types/react": "^19.2.17", "@types/react-dom": "^19.2.3", @@ -27,6 +53,7 @@ "eslint-plugin-react-hooks": "^7.1.1", "eslint-plugin-react-refresh": "^0.5.3", "globals": "^17.7.0", + "tailwindcss": "^4.1.0", "typescript": "~6.0.2", "typescript-eslint": "^8.62.0", "vite": "^8.1.1" diff --git a/apps/web/src/App.css b/apps/web/src/App.css deleted file mode 100644 index 74a8621..0000000 --- a/apps/web/src/App.css +++ /dev/null @@ -1,720 +0,0 @@ -.app-shell { - min-height: 100svh; - display: flex; - flex-direction: column; -} - -.app-header { - min-height: 72px; - display: flex; - align-items: center; - justify-content: space-between; - gap: 24px; - padding: 0 32px; - border-bottom: 1px solid var(--border); - background: color-mix(in srgb, var(--surface) 86%, transparent); - backdrop-filter: blur(14px); - position: sticky; - top: 0; - z-index: 10; -} - -.brand { - min-width: 0; - display: inline-flex; - align-items: center; - gap: 12px; - color: var(--text-strong); - text-decoration: none; -} - -.brand-mark { - width: 40px; - height: 40px; - display: inline-grid; - place-items: center; - border: 1px solid var(--accent); - border-radius: 8px; - color: var(--accent); - font-size: 13px; - font-weight: 800; -} - -.brand-copy { - min-width: 0; - display: grid; - gap: 2px; -} - -.brand-copy strong, -.brand-copy span { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.brand-copy strong { - font-size: 15px; -} - -.brand-copy span { - color: var(--text-muted); - font-size: 12px; -} - -.header-status, -.status-pill { - display: inline-flex; - align-items: center; - min-height: 28px; - max-width: 100%; - padding: 0 10px; - border: 1px solid var(--border); - border-radius: 999px; - color: var(--text-muted); - font-size: 12px; - font-weight: 700; - line-height: 1; - text-transform: uppercase; - white-space: nowrap; -} - -.app-main { - width: min(1180px, calc(100% - 32px)); - flex: 1; - margin: 0 auto; - padding: 48px 0; -} - -.riot-disclaimer { - padding: 18px 32px 24px; - border-top: 1px solid var(--border); - color: var(--text-subtle); - font-size: 12px; - line-height: 1.55; -} - -.home-view { - display: grid; - grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr); - gap: 32px; - align-items: start; -} - -.home-copy, -.analysis-form, -.progress-panel, -.chart-section, -.champion-section, -.insight-section, -.similar-section, -.dashboard-summary { - border: 1px solid var(--border); - border-radius: 8px; - background: var(--surface); -} - -.home-copy { - min-height: 430px; - display: flex; - flex-direction: column; - justify-content: space-between; - padding: 36px; -} - -.eyebrow { - margin: 0 0 12px; - color: var(--accent); - font-size: 12px; - font-weight: 800; - letter-spacing: 0; - text-transform: uppercase; -} - -.lead-copy { - max-width: 740px; - margin: 0; - color: var(--text-muted); - font-size: 16px; - line-height: 1.7; -} - -.home-facts { - display: grid; - grid-template-columns: repeat(3, minmax(0, 1fr)); - gap: 12px; - margin: 36px 0 0; -} - -.home-facts div, -.summary-stat { - min-width: 0; - padding: 14px; - border: 1px solid var(--border); - border-radius: 8px; - background: var(--surface-soft); -} - -.home-facts dt, -.summary-stat span, -.progress-meta span, -.champion-copy span { - display: block; - color: var(--text-subtle); - font-size: 12px; - font-weight: 700; - line-height: 1.4; - text-transform: uppercase; -} - -.home-facts dd, -.summary-stat strong, -.progress-meta strong { - display: block; - margin: 6px 0 0; - color: var(--text-strong); - font-size: 15px; - line-height: 1.35; -} - -.analysis-form { - display: grid; - gap: 18px; - padding: 24px; -} - -.form-header, -.section-heading { - display: flex; - align-items: center; - justify-content: space-between; - gap: 16px; -} - -.field { - display: grid; - gap: 8px; -} - -.field span { - color: var(--text-muted); - font-size: 13px; - font-weight: 700; -} - -.field input { - width: 100%; - min-height: 48px; - box-sizing: border-box; - border: 1px solid var(--border-strong); - border-radius: 8px; - background: var(--surface-soft); - color: var(--text-strong); - font: inherit; - outline: none; - padding: 0 14px; -} - -.field input:focus { - border-color: var(--accent); - box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent); -} - -.primary-action, -.secondary-action { - min-height: 44px; - display: inline-flex; - align-items: center; - justify-content: center; - border: 1px solid transparent; - border-radius: 8px; - font-size: 14px; - font-weight: 800; - text-decoration: none; - white-space: nowrap; - cursor: pointer; -} - -.primary-action { - background: var(--accent); - color: #07110e; - padding: 0 18px; -} - -.primary-action:disabled { - cursor: not-allowed; - opacity: 0.55; -} - -.secondary-action { - border-color: var(--border-strong); - background: var(--surface-soft); - color: var(--text-strong); - padding: 0 16px; -} - -.message { - margin: 0; - border-radius: 8px; - padding: 12px 14px; - font-size: 14px; - line-height: 1.55; -} - -.message-error { - border: 1px solid color-mix(in srgb, var(--danger) 52%, var(--border)); - background: color-mix(in srgb, var(--danger) 13%, var(--surface)); - color: var(--danger-strong); -} - -.message-warning { - border: 1px solid color-mix(in srgb, var(--warning) 52%, var(--border)); - background: color-mix(in srgb, var(--warning) 13%, var(--surface)); - color: var(--warning-strong); -} - -.progress-view { - display: grid; - place-items: center; - min-height: calc(100svh - 240px); -} - -.progress-panel { - width: min(760px, 100%); - padding: 32px; -} - -.progress-meter { - height: 12px; - margin: 28px 0 18px; - overflow: hidden; - border-radius: 999px; - background: var(--surface-soft); -} - -.progress-meter span { - display: block; - height: 100%; - border-radius: inherit; - background: var(--accent); - transition: width 200ms ease; -} - -.progress-meta { - display: grid; - grid-template-columns: repeat(3, minmax(0, 1fr)); - gap: 12px; - margin-bottom: 18px; -} - -.progress-meta div { - min-width: 0; - padding: 14px; - border: 1px solid var(--border); - border-radius: 8px; - background: var(--surface-soft); -} - -.action-row { - display: flex; - flex-wrap: wrap; - gap: 12px; - margin-top: 20px; -} - -.dashboard-view { - display: grid; - gap: 20px; -} - -.dashboard-summary { - display: grid; - grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr); - gap: 28px; - align-items: end; - padding: 28px; -} - -.summary-stat-grid { - display: grid; - grid-template-columns: repeat(3, minmax(0, 1fr)); - gap: 10px; -} - -.chart-section, -.champion-section, -.insight-section, -.similar-section { - padding: 24px; -} - -.radar-frame { - min-height: 380px; - margin-top: 18px; -} - -.insight-grid { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 20px; -} - -.metric-card-list { - display: grid; - grid-template-columns: 1fr; - gap: 10px; - margin-top: 16px; -} - -.metric-card { - min-width: 0; - display: grid; - gap: 8px; - border: 1px solid var(--border); - border-radius: 8px; - background: var(--surface-soft); - padding: 14px; -} - -.metric-card-heading { - min-width: 0; - display: flex; - align-items: start; - justify-content: space-between; - gap: 12px; -} - -.metric-card-heading h3 { - min-width: 0; - margin: 0; - font-size: 15px; - line-height: 1.35; -} - -.metric-card-heading strong { - flex: 0 0 auto; - color: var(--text-strong); - font-size: 22px; - line-height: 1; -} - -.metric-card p { - margin: 0; - color: var(--text-muted); - font-size: 13px; - line-height: 1.45; -} - -.metric-card > span { - color: var(--text-muted); - font-size: 12px; - font-weight: 700; - line-height: 1.35; - text-transform: uppercase; -} - -.champion-list { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 10px; - margin-top: 16px; -} - -.champion-row { - min-width: 0; - display: flex; - align-items: center; - gap: 12px; - border: 1px solid var(--border); - border-radius: 8px; - background: var(--surface-soft); - padding: 12px; -} - -.champion-icon { - width: 44px; - height: 44px; - flex: 0 0 44px; - border-radius: 8px; - background: var(--border); - object-fit: cover; -} - -.champion-placeholder { - display: inline-block; - border: 1px solid var(--border-strong); -} - -.champion-copy { - min-width: 0; - display: grid; - gap: 4px; -} - -.champion-copy strong { - overflow: hidden; - color: var(--text-strong); - font-size: 15px; - text-overflow: ellipsis; - white-space: nowrap; -} - -.section-copy { - margin: 8px 0 0; - color: var(--text-muted); - font-size: 14px; - line-height: 1.55; -} - -.similar-message { - margin-top: 16px; -} - -.similar-table-wrap { - margin-top: 18px; - overflow-x: auto; -} - -.similar-table-wrap:focus-visible { - outline: 3px solid color-mix(in srgb, var(--accent) 42%, transparent); - outline-offset: 3px; -} - -.similar-table { - width: 100%; - min-width: 780px; - border-collapse: separate; - border-spacing: 0 10px; -} - -.similar-table th { - padding: 0 12px; - color: var(--text-subtle); - font-size: 12px; - font-weight: 800; - line-height: 1.3; - text-align: left; - text-transform: uppercase; -} - -.similar-table td { - min-width: 0; - padding: 14px 12px; - border-block: 1px solid var(--border); - background: var(--surface-soft); - vertical-align: top; -} - -.similar-table td:first-child { - border-left: 1px solid var(--border); - border-radius: 8px 0 0 8px; -} - -.similar-table td:last-child { - border-right: 1px solid var(--border); - border-radius: 0 8px 8px 0; -} - -.similar-player, -.similar-score, -.similar-metric-groups, -.similar-metric-group { - min-width: 0; - display: grid; - gap: 6px; -} - -.similar-player strong, -.similar-score strong, -.similar-chip strong { - overflow: hidden; - color: var(--text-strong); - text-overflow: ellipsis; - white-space: nowrap; -} - -.similar-player span, -.similar-score span, -.similar-chip span, -.similar-metric-group > span, -.similar-empty { - color: var(--text-subtle); - font-size: 12px; - font-weight: 700; - line-height: 1.35; -} - -.similar-score strong { - font-size: 22px; - line-height: 1; -} - -.similar-chip-list { - display: flex; - flex-wrap: wrap; - gap: 6px; - margin: 0; - padding: 0; - list-style: none; -} - -.similar-chip { - max-width: 100%; - display: inline-flex; - align-items: center; - gap: 6px; - border: 1px solid var(--border); - border-radius: 999px; - background: var(--surface); - padding: 5px 8px; -} - -.similar-chip strong { - min-width: 0; -} - -.similar-chip span { - flex: 0 0 auto; - white-space: nowrap; -} - -.similar-chip-accent { - border-color: color-mix(in srgb, var(--accent) 48%, var(--border)); -} - -.similar-chip-muted { - background: color-mix(in srgb, var(--surface) 74%, var(--surface-soft)); -} - -.similar-tier-badge { - justify-self: start; - border: 1px solid color-mix(in srgb, var(--accent) 48%, var(--border)); - border-radius: 999px; - padding: 3px 8px; - color: var(--text-strong); - font-size: 11px; - font-weight: 700; - line-height: 1.2; -} - -.empty-view { - min-height: calc(100svh - 240px); - display: grid; - place-content: center; - justify-items: start; - gap: 18px; -} - -.empty-copy { - margin: 16px 0 0; - color: var(--text-muted); -} - -.skeleton { - position: relative; - overflow: hidden; - border-radius: 8px; - background: var(--surface); -} - -.skeleton::after { - content: ''; - position: absolute; - inset: 0; - background: linear-gradient( - 90deg, - transparent, - color-mix(in srgb, var(--text-muted) 10%, transparent), - transparent - ); - animation: skeleton-sheen 1.4s linear infinite; -} - -.skeleton-title { - width: min(420px, 100%); - height: 92px; -} - -.skeleton-grid { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 20px; -} - -.skeleton-panel { - min-height: 280px; -} - -@keyframes skeleton-sheen { - from { - transform: translateX(-100%); - } - - to { - transform: translateX(100%); - } -} - -@media (max-width: 900px) { - .app-main { - width: min(100% - 24px, 720px); - padding: 32px 0; - } - - .home-view, - .dashboard-summary, - .insight-grid, - .champion-list, - .skeleton-grid { - grid-template-columns: 1fr; - } - - .home-copy { - min-height: auto; - } - - .summary-stat-grid { - grid-template-columns: repeat(3, minmax(0, 1fr)); - } -} - -@media (max-width: 640px) { - .app-header { - min-height: auto; - align-items: flex-start; - flex-direction: column; - padding: 16px; - } - - .header-status { - display: none; - } - - .home-copy, - .analysis-form, - .progress-panel, - .chart-section, - .champion-section, - .insight-section, - .similar-section, - .dashboard-summary { - padding: 18px; - } - - .home-facts, - .progress-meta, - .summary-stat-grid, - .metric-card-list { - grid-template-columns: 1fr; - } - - .form-header, - .section-heading { - align-items: flex-start; - flex-direction: column; - } - - .radar-frame { - margin-inline: -8px; - } -} diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx deleted file mode 100644 index 33e19e7..0000000 --- a/apps/web/src/App.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import { Suspense, lazy } from 'react'; -import { BrowserRouter, Link, Route, Routes } from 'react-router-dom'; -import './App.css'; -import { HomePage } from './pages/HomePage'; -import { NotFoundPage } from './pages/NotFoundPage'; -import { ProgressPage } from './pages/ProgressPage'; - -const DashboardPage = lazy(() => - import('./pages/DashboardPage').then((module) => ({ - default: module.DashboardPage, - })), -); - -function App() { - return ( - -
-
- - - - persona-lenz - LoL 플레이스타일 분석 - - - Ranked Solo MVP -
- -
- }> - - } /> - } /> - } /> - } /> - - -
- - -
-
- ); -} - -function RouteFallback() { - return ( -
-
-
- ); -} - -export default App; diff --git a/apps/web/src/api/analysis.ts b/apps/web/src/api/analysis.ts deleted file mode 100644 index 74edfcd..0000000 --- a/apps/web/src/api/analysis.ts +++ /dev/null @@ -1,110 +0,0 @@ -import type { - AnalysisJobStatusDto, - AnalysisRequestAcceptedDto, - AnalysisRequestDto, - PlayerAnalysisDto, - SimilarPlayersDto, -} from '@persona-lenz/shared'; - -export class ApiClientError extends Error { - readonly status: number; - - constructor(message: string, status: number) { - super(message); - this.name = 'ApiClientError'; - this.status = status; - } -} - -const JSON_HEADERS = { - 'Content-Type': 'application/json', -} as const; - -async function fetchJson( - input: RequestInfo | URL, - init?: RequestInit, -): Promise { - const response = await fetch(input, init); - - if (!response.ok) { - throw new ApiClientError(await readErrorMessage(response), response.status); - } - - return (await response.json()) as T; -} - -async function readErrorMessage(response: Response): Promise { - const fallback = `요청 처리에 실패했습니다. (${response.status})`; - const contentType = response.headers.get('content-type') ?? ''; - - if (!contentType.includes('application/json')) { - const text = await response.text().catch(() => ''); - return text.trim() || fallback; - } - - const payload = await response.json().catch(() => undefined); - - if (!isRecord(payload) || !('message' in payload)) { - return fallback; - } - - const { message } = payload; - - if (Array.isArray(message)) { - return message.map(String).join(', '); - } - - return typeof message === 'string' && message.trim() ? message : fallback; -} - -function isRecord(value: unknown): value is Record { - return typeof value === 'object' && value !== null; -} - -export function getReadableErrorMessage(error: unknown): string { - if (error instanceof ApiClientError) { - return error.message; - } - - if (error instanceof Error) { - return error.message; - } - - return '알 수 없는 오류가 발생했습니다.'; -} - -export async function requestAnalysis( - payload: AnalysisRequestDto, -): Promise { - return fetchJson('/api/analysis/request', { - method: 'POST', - headers: JSON_HEADERS, - body: JSON.stringify(payload), - }); -} - -export async function getAnalysisJob( - jobId: string, -): Promise { - return fetchJson( - `/api/analysis/jobs/${encodeURIComponent(jobId)}`, - ); -} - -export async function getLatestPlayerAnalysis( - puuid: string, -): Promise { - return fetchJson( - `/api/players/${encodeURIComponent(puuid)}/analysis/latest`, - ); -} - -export async function getSimilarPlayers( - puuid: string, - limit = 10, -): Promise { - const params = new URLSearchParams({ limit: String(limit) }); - return fetchJson( - `/api/players/${encodeURIComponent(puuid)}/similar-players?${params}`, - ); -} diff --git a/apps/web/src/api/data-dragon.ts b/apps/web/src/api/data-dragon.ts deleted file mode 100644 index 4903ee4..0000000 --- a/apps/web/src/api/data-dragon.ts +++ /dev/null @@ -1,139 +0,0 @@ -const DATA_DRAGON_BASE_URL = 'https://ddragon.leagueoflegends.com'; -const CACHE_KEY = 'persona-lenz:data-dragon:champions:v1'; -const CACHE_TTL_MS = 24 * 60 * 60 * 1000; - -export interface ChampionSummary { - id: number; - imageUrl: string; - name: string; -} - -export interface ChampionCatalog { - champions: Record; - version: string; -} - -interface ChampionCatalogCache extends ChampionCatalog { - cachedAt: number; -} - -interface DataDragonChampion { - image: { - full: string; - }; - key: string; - name: string; -} - -interface DataDragonChampionResponse { - data: Record; -} - -export async function loadChampionCatalog(): Promise { - const cachedCatalog = readChampionCatalogCache(); - - if (cachedCatalog && Date.now() - cachedCatalog.cachedAt < CACHE_TTL_MS) { - return cachedCatalog; - } - - try { - const [latestVersion] = await fetchJson( - `${DATA_DRAGON_BASE_URL}/api/versions.json`, - ); - - if (!latestVersion) { - throw new Error('Data Dragon 버전 목록이 비어 있습니다.'); - } - - const championResponse = await fetchJson( - `${DATA_DRAGON_BASE_URL}/cdn/${latestVersion}/data/ko_KR/champion.json`, - ); - const champions = Object.values(championResponse.data).reduce< - Record - >((catalog, champion) => { - const championId = Number(champion.key); - - if (Number.isFinite(championId)) { - catalog[championId] = { - id: championId, - imageUrl: `${DATA_DRAGON_BASE_URL}/cdn/${latestVersion}/img/champion/${champion.image.full}`, - name: champion.name, - }; - } - - return catalog; - }, {}); - const catalog: ChampionCatalogCache = { - cachedAt: Date.now(), - champions, - version: latestVersion, - }; - - writeChampionCatalogCache(catalog); - - return catalog; - } catch (error) { - if (cachedCatalog) { - return cachedCatalog; - } - - throw error; - } -} - -function readChampionCatalogCache(): ChampionCatalogCache | null { - let rawCache: string | null; - - try { - rawCache = window.localStorage.getItem(CACHE_KEY); - } catch { - return null; - } - - if (!rawCache) { - return null; - } - - try { - const parsedCache = JSON.parse(rawCache) as Partial; - - if ( - typeof parsedCache.cachedAt === 'number' && - typeof parsedCache.version === 'string' && - parsedCache.champions && - typeof parsedCache.champions === 'object' - ) { - return parsedCache as ChampionCatalogCache; - } - } catch { - removeChampionCatalogCache(); - } - - return null; -} - -function writeChampionCatalogCache(catalog: ChampionCatalogCache): void { - try { - window.localStorage.setItem(CACHE_KEY, JSON.stringify(catalog)); - } catch { - // Champion metadata remains usable even when browser storage is restricted. - } -} - -function removeChampionCatalogCache(): void { - try { - window.localStorage.removeItem(CACHE_KEY); - } catch { - // Ignore storage failures. - } -} - -async function fetchJson(url: string): Promise { - const response = await fetch(url); - - if (!response.ok) { - throw new Error(`Data Dragon 요청에 실패했습니다. (${response.status})`); - } - - return (await response.json()) as T; -} diff --git a/apps/web/src/app/App.tsx b/apps/web/src/app/App.tsx new file mode 100644 index 0000000..091e6d7 --- /dev/null +++ b/apps/web/src/app/App.tsx @@ -0,0 +1,27 @@ +/* Scaffolded with StyleSeed · github.com/bitjaru/styleseed — safe to remove */ +import * as React from 'react' +import { Routes, Route } from 'react-router-dom' +import { HomePage } from '../pages/home' +import { AnalysisProgressPage } from '../pages/analysis-progress' + +// recharts를 포함한 대시보드는 무거우므로 분리 로딩 — 홈/진행 화면 첫 로드를 가볍게 유지 +const PlayerDashboardPage = React.lazy(() => + import('../pages/player-dashboard').then((module) => ({ default: module.PlayerDashboardPage })), +) + +export default function App() { + return ( + + } /> + } /> + }> + + + } + /> + + ) +} diff --git a/apps/web/src/components/dashboard/champion-pool-card.tsx b/apps/web/src/components/dashboard/champion-pool-card.tsx new file mode 100644 index 0000000..5964e4f --- /dev/null +++ b/apps/web/src/components/dashboard/champion-pool-card.tsx @@ -0,0 +1,52 @@ +import type { ChampionPoolEntryDto } from '@persona-lenz/shared' +import type { ChampionIndex } from '../../lib/ddragon' +import { championImageUrl } from '../../lib/ddragon' + +interface ChampionPoolCardProps { + championPool: ChampionPoolEntryDto[] + champions: ChampionIndex | null +} + +/** 분석 표본에 포함된 챔피언 풀 — 판수 내림차순 상위 5개 */ +export function ChampionPoolCard({ championPool, champions }: ChampionPoolCardProps) { + const entries = championPool.slice(0, 5) + + return ( +
+

챔피언 풀

+

이번 분석 표본에서 많이 플레이한 순이에요.

+
    + {entries.map((entry) => { + const champion = champions?.byId.get(entry.championId) + const winRate = entry.games > 0 ? Math.round((entry.wins / entry.games) * 100) : 0 + return ( +
  • + {champion && champions ? ( + + ) : ( + + )} +
    +

    + {champion?.name ?? `챔피언 #${entry.championId}`} +

    +

    + {entry.games}전 {entry.wins}승 +

    +
    + + {winRate} + % + +
  • + ) + })} +
+
+ ) +} diff --git a/apps/web/src/components/dashboard/metric-detail-tabs.tsx b/apps/web/src/components/dashboard/metric-detail-tabs.tsx new file mode 100644 index 0000000..88dfb02 --- /dev/null +++ b/apps/web/src/components/dashboard/metric-detail-tabs.tsx @@ -0,0 +1,66 @@ +import type { MetricId } from '@persona-lenz/shared' +import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs' +import { METRIC_BY_ID, METRIC_CATEGORIES, displayScore } from '../../lib/metrics' + +interface MetricDetailTabsProps { + playstyle: Partial> +} + +/** 39개 전체 지표를 6개 카테고리 탭으로 드릴다운. 막대는 상태가 아니라 크기이므로 중립색 */ +export function MetricDetailTabs({ playstyle }: MetricDetailTabsProps) { + const categories = METRIC_CATEGORIES.map((category) => ({ + ...category, + metrics: category.metricIds + .filter((metricId) => playstyle[metricId] != null) + .map((metricId) => ({ + metric: METRIC_BY_ID.get(metricId), + metricId, + score: displayScore(metricId, playstyle[metricId]!), + })), + })).filter((category) => category.metrics.length > 0) + + if (categories.length === 0) return null + + return ( +
+

전체 지표

+

+ 같은 포지션 기준으로 정규화한 0~100 점수예요. 낮을수록 좋은 지표는 반전해서 표시합니다. +

+ + + {categories.map((category) => ( + + {category.label} + + ))} + + {categories.map((category) => ( + +
    + {category.metrics.map(({ metric, metricId, score }) => ( +
  • +
    +

    {metric?.label ?? metricId}

    +

    {metric?.description}

    +
    +
    +
    +
    +
    + + {score} + +
    +
  • + ))} +
+
+ ))} +
+
+ ) +} diff --git a/apps/web/src/components/dashboard/metric-highlights.tsx b/apps/web/src/components/dashboard/metric-highlights.tsx new file mode 100644 index 0000000..67fe725 --- /dev/null +++ b/apps/web/src/components/dashboard/metric-highlights.tsx @@ -0,0 +1,58 @@ +import { TrendingDown, TrendingUp } from 'lucide-react' +import type { MetricValueDto } from '@persona-lenz/shared' +import { METRIC_BY_ID, displayScore } from '../../lib/metrics' + +interface MetricHighlightsProps { + strengths: MetricValueDto[] + weaknesses: MetricValueDto[] +} + +function HighlightList({ items, tone }: { items: MetricValueDto[]; tone: 'strength' | 'weakness' }) { + return ( +
    + {items.map(({ metricId, value }, index) => { + const metric = METRIC_BY_ID.get(metricId) + return ( +
  1. + + {index + 1} + +
    +

    {metric?.label ?? metricId}

    +

    {metric?.description}

    +
    + + {displayScore(metricId, value)} + +
  2. + ) + })} +
+ ) +} + +/** 강점/약점 Top 3 — direction 반영 점수(0~100)와 지표 설명을 함께 보여준다 */ +export function MetricHighlights({ strengths, weaknesses }: MetricHighlightsProps) { + return ( +
+
+

+ + 이런 플레이가 강해요 +

+ +
+
+

+ + 여기를 보완하면 좋아요 +

+ +
+
+ ) +} diff --git a/apps/web/src/components/dashboard/playstyle-radar.tsx b/apps/web/src/components/dashboard/playstyle-radar.tsx new file mode 100644 index 0000000..571d5f7 --- /dev/null +++ b/apps/web/src/components/dashboard/playstyle-radar.tsx @@ -0,0 +1,37 @@ +import { PolarAngleAxis, PolarGrid, PolarRadiusAxis, Radar, RadarChart, ResponsiveContainer } from 'recharts' +import type { CategoryScore } from '../../lib/metrics' + +interface PlaystyleRadarProps { + scores: CategoryScore[] +} + +/** 6개 카테고리 집계 점수를 보여주는 플레이스타일 레이더. 대시보드의 focal 요소 */ +export function PlaystyleRadar({ scores }: PlaystyleRadarProps) { + const data = scores.map(({ category, score }) => ({ + label: category.label, + score: score ?? 0, + })) + + return ( +
+ + + + + + + + +
+ ) +} diff --git a/apps/web/src/components/dashboard/similar-players-section.tsx b/apps/web/src/components/dashboard/similar-players-section.tsx new file mode 100644 index 0000000..eff8bde --- /dev/null +++ b/apps/web/src/components/dashboard/similar-players-section.tsx @@ -0,0 +1,104 @@ +import { Users } from 'lucide-react' +import type { SimilarPlayerDto } from '@persona-lenz/shared' +import type { ChampionIndex } from '../../lib/ddragon' +import { championImageUrl } from '../../lib/ddragon' +import { METRIC_BY_ID, ROLE_LABELS, formatTier } from '../../lib/metrics' + +interface SimilarPlayersSectionProps { + players: SimilarPlayerDto[] | null + champions: ChampionIndex | null +} + +function LeadChips({ player }: { player: SimilarPlayerDto }) { + if (player.strongerMetrics.length === 0) return null + return ( +
+ 이 플레이어가 앞서는 지표 + {player.strongerMetrics.slice(0, 3).map((lead) => ( + + {METRIC_BY_ID.get(lead.metricId)?.label ?? lead.metricId} +{Math.round(lead.lead * 100)} + + ))} +
+ ) +} + +/** 나와 비슷한 플레이스타일의 상위 티어 유저 비교 카드 목록 */ +export function SimilarPlayersSection({ players, champions }: SimilarPlayersSectionProps) { + return ( +
+

나와 비슷한 상위 티어 플레이어

+

+ 플레이스타일 벡터가 가까운 유저 중 더 높은 티어를 우선으로 보여드려요. +

+ + {players == null || players.length === 0 ? ( +
+ +

아직 비교 결과를 준비 중이에요

+

+ 비교 풀이 채워지면 자동으로 나타나요. 다음 분석 때 다시 확인해 주세요. +

+
+ ) : ( +
    + {players.map((player) => { + const name = player.riotId ? `${player.riotId.gameName}#${player.riotId.tagLine}` : player.displayId + const tier = formatTier(player.tier, player.division) + return ( +
  • +
    +

    {name}

    + {tier && ( + + {tier} + {player.leaguePoints != null ? ` · ${player.leaguePoints}LP` : ''} + + )} + {player.tierComparison === 'higher' && ( + + 상위 티어 + + )} + + 유사도 {Math.round(player.similarityScore * 100)} + % + +
    + +
    + {ROLE_LABELS[player.mainRole]} + + {player.sampleGameCount}게임 표본 + {champions && player.mainChampions.length > 0 && ( +
    + {player.mainChampions.slice(0, 3).map((entry) => { + const champion = champions.byId.get(entry.championId) + if (!champion) return null + return ( + {champion.name} + ) + })} +
    + )} +
    + + +
  • + ) + })} +
+ )} +
+ ) +} diff --git a/apps/web/src/components/patterns/bottom-nav.tsx b/apps/web/src/components/patterns/bottom-nav.tsx new file mode 100644 index 0000000..f0727b4 --- /dev/null +++ b/apps/web/src/components/patterns/bottom-nav.tsx @@ -0,0 +1,63 @@ +import * as React from "react" +import { cn } from "../ui/utils" +import type { LucideIcon } from "lucide-react" + +interface NavItem { + name: string + icon: LucideIcon + href?: string + onClick?: () => void +} + +interface BottomNavProps extends React.ComponentProps<"nav"> { + items: NavItem[] + activeIndex?: number + maxWidth?: string +} + +function BottomNav({ + items, + activeIndex = 0, + maxWidth = "430px", + className, + ...props +}: BottomNavProps) { + return ( + + ) +} + +export { BottomNav } +export type { BottomNavProps, NavItem } diff --git a/apps/web/src/components/patterns/briefing-carousel.tsx b/apps/web/src/components/patterns/briefing-carousel.tsx new file mode 100644 index 0000000..755e485 --- /dev/null +++ b/apps/web/src/components/patterns/briefing-carousel.tsx @@ -0,0 +1,76 @@ +import * as React from "react" +import { cn } from "../ui/utils" +import type { LucideIcon } from "lucide-react" + +interface BriefingItem { + icon: LucideIcon + badge: string + badgeColor: string + title: string + description: string +} + +interface BriefingCarouselProps extends React.ComponentProps<"div"> { + title?: string + items: BriefingItem[] + cardWidth?: string +} + +function BriefingCarousel({ + title, + items, + cardWidth = "280px", + className, + ...props +}: BriefingCarouselProps) { + return ( +
+ {title && ( +

+ {title} +

+ )} +
+ {items.map((item, index) => { + const IconComponent = item.icon + return ( +
+
+
+ + + {item.badge} + +
+

+ {item.title} +

+

+ {item.description} +

+
+
+ ) + })} +
+
+ ) +} + +export { BriefingCarousel } +export type { BriefingCarouselProps, BriefingItem } diff --git a/apps/web/src/components/patterns/chart-card.tsx b/apps/web/src/components/patterns/chart-card.tsx new file mode 100644 index 0000000..e5a7091 --- /dev/null +++ b/apps/web/src/components/patterns/chart-card.tsx @@ -0,0 +1,101 @@ +import * as React from "react" +import { cn } from "../ui/utils" + +interface ChartStat { + label: string + value: string | number + unit?: string +} + +interface ChartCardProps extends React.ComponentProps<"div"> { + title?: string + headerLeft?: React.ReactNode + periods?: string[] + activePeriod?: string + onPeriodChange?: (period: string) => void + stats?: ChartStat[] + statsColumns?: number +} + +function ChartCard({ + title, + headerLeft, + periods, + activePeriod, + onPeriodChange, + stats, + statsColumns = 3, + className, + children, + ...props +}: ChartCardProps) { + return ( +
+
+
+ {title && ( +

+ {title} +

+ )} + {headerLeft} +
+ + {periods && ( +
+ {periods.map((period) => ( + + ))} +
+ )} +
+ +
+ {children} +
+ + {stats && stats.length > 0 && ( +
+ {stats.map((stat) => ( +
+

+ {stat.label} +

+

+ {stat.value} + {stat.unit && {stat.unit}} +

+
+ ))} +
+ )} +
+ ) +} + +export { ChartCard } +export type { ChartCardProps, ChartStat } diff --git a/apps/web/src/components/patterns/donut-chart-card.tsx b/apps/web/src/components/patterns/donut-chart-card.tsx new file mode 100644 index 0000000..0487b98 --- /dev/null +++ b/apps/web/src/components/patterns/donut-chart-card.tsx @@ -0,0 +1,140 @@ +import * as React from "react" +import { cn } from "../ui/utils" + +interface DonutItem { + name: string + value: number + stock?: string | number + unit?: string +} + +interface BottomStat { + label: string + value: string | number + subLabel?: string +} + +interface DonutChartCardProps extends React.ComponentProps<"div"> { + title: string + centerValue?: string | number + centerUnit?: string + centerLabel?: string + items: DonutItem[] + selectedItem?: string | null + onItemSelect?: (name: string | null) => void + bottomStats?: BottomStat[] + bottomColumns?: number + chartElement: React.ReactNode +} + +function DonutChartCard({ + title, + centerValue, + centerUnit, + centerLabel, + items, + selectedItem, + onItemSelect, + bottomStats, + bottomColumns = 4, + chartElement, + className, + ...props +}: DonutChartCardProps) { + const grayColors = ["#D4D4D4", "#A8A8A8", "#8B8B8B", "#6B6B6B"] + + return ( +
+

+ {title} +

+ +
+
+ {chartElement} + {(centerValue !== undefined || centerLabel) && ( +
+
+ {centerValue !== undefined && ( +

+ {centerValue} + {centerUnit && {centerUnit}} +

+ )} + {centerLabel && ( +

+ {centerLabel} +

+ )} +
+
+ )} +
+ +
+ {items.map((item, index) => ( +
onItemSelect?.(selectedItem === item.name ? null : item.name)} + style={{ + opacity: selectedItem === null || selectedItem === undefined || selectedItem === item.name ? 1 : 0.3, + }} + > +
+
+ {item.name} +
+ {item.stock !== undefined && ( + + {item.stock} + {item.unit && {item.unit}} + + )} +
+ ))} +
+
+ + {bottomStats && bottomStats.length > 0 && ( +
+ {bottomStats.map((stat) => ( +
+

+ {stat.label} +

+

+ {stat.value} +

+ {stat.subLabel && ( +

{stat.subLabel}

+ )} +
+ ))} +
+ )} +
+ ) +} + +export { DonutChartCard } +export type { DonutChartCardProps, DonutItem, BottomStat } diff --git a/apps/web/src/components/patterns/empty-state.tsx b/apps/web/src/components/patterns/empty-state.tsx new file mode 100644 index 0000000..b3d3ed3 --- /dev/null +++ b/apps/web/src/components/patterns/empty-state.tsx @@ -0,0 +1,48 @@ +import * as React from "react" +import { cn } from "../ui/utils" +import type { LucideIcon } from "lucide-react" + +interface EmptyStateProps extends React.ComponentProps<"div"> { + icon?: LucideIcon + title: string + description?: string + action?: React.ReactNode +} + +function EmptyState({ + icon: Icon, + title, + description, + action, + className, + ...props +}: EmptyStateProps) { + return ( +
+ {Icon && ( +
+ +
+ )} +

+ {title} +

+ {description && ( +

+ {description} +

+ )} + {action} +
+ ) +} + +export { EmptyState } +export type { EmptyStateProps } diff --git a/apps/web/src/components/patterns/hero-card.tsx b/apps/web/src/components/patterns/hero-card.tsx new file mode 100644 index 0000000..e8063f0 --- /dev/null +++ b/apps/web/src/components/patterns/hero-card.tsx @@ -0,0 +1,96 @@ +import * as React from "react" +import { cn } from "../ui/utils" +import { TrendingUp, TrendingDown, type LucideIcon } from "lucide-react" + +interface HeroCardProps extends React.ComponentProps<"div"> { + icon: LucideIcon + label: string + value: string | number + unit?: string + trend?: { + value: string + direction: "up" | "down" + label?: string + } + backgroundElement?: React.ReactNode + watermarkIcon?: LucideIcon +} + +function HeroCard({ + icon: Icon, + label, + value, + unit, + trend, + backgroundElement, + watermarkIcon: WatermarkIcon, + className, + ...props +}: HeroCardProps) { + return ( +
+ {backgroundElement && ( +
+ {backgroundElement} +
+ )} + + {WatermarkIcon && ( +
+ +
+ )} + +
+
+
+ +
+

+ {label} +

+
+ +

+ {value} + {unit && {unit}} +

+ + {trend && ( +
+
+ + {trend.value} + + {trend.direction === "up" ? ( + + ) : ( + + )} +
+ {trend.label && ( + + {trend.label} + + )} +
+ )} +
+
+ ) +} + +export { HeroCard } +export type { HeroCardProps } diff --git a/apps/web/src/components/patterns/insight-card.tsx b/apps/web/src/components/patterns/insight-card.tsx new file mode 100644 index 0000000..da53fe2 --- /dev/null +++ b/apps/web/src/components/patterns/insight-card.tsx @@ -0,0 +1,69 @@ +import * as React from "react" +import { cn } from "../ui/utils" +import type { LucideIcon } from "lucide-react" + +interface InsightCardProps extends React.ComponentProps<"div"> { + icon?: LucideIcon + title: string + description: string + tags?: { label: string; icon?: LucideIcon }[] + action?: React.ReactNode + variant?: "default" | "highlighted" +} + +function InsightCard({ + icon: Icon, + title, + description, + tags, + action, + variant = "default", + className, + ...props +}: InsightCardProps) { + return ( +
+ {Icon && ( +
+ +
+ )} + +

+ {title} +

+

+ {description} +

+ + {tags && tags.length > 0 && ( +
+ {tags.map((tag, i) => ( + + {tag.icon && } + {tag.label} + + ))} +
+ )} + + {action} +
+ ) +} + +export { InsightCard } +export type { InsightCardProps } diff --git a/apps/web/src/components/patterns/list-item.tsx b/apps/web/src/components/patterns/list-item.tsx new file mode 100644 index 0000000..11d4c67 --- /dev/null +++ b/apps/web/src/components/patterns/list-item.tsx @@ -0,0 +1,64 @@ +import * as React from "react" +import { cn } from "../ui/utils" + +interface ListItemProps extends React.ComponentProps<"div"> { + leading?: React.ReactNode + title: string + subtitle?: React.ReactNode + trailing?: React.ReactNode + status?: { + label: string + color: string + } +} + +function ListItem({ + leading, + title, + subtitle, + trailing, + status, + className, + ...props +}: ListItemProps) { + return ( +
+
+ {leading} +
+

+ {title} +

+ {status && ( +
+ + + {status.label} + +
+ )} + {subtitle && !status && ( +

{subtitle}

+ )} +
+
+ {trailing &&
{trailing}
} +
+ ) +} + +export { ListItem } +export type { ListItemProps } diff --git a/apps/web/src/components/patterns/news-card.tsx b/apps/web/src/components/patterns/news-card.tsx new file mode 100644 index 0000000..f60c191 --- /dev/null +++ b/apps/web/src/components/patterns/news-card.tsx @@ -0,0 +1,67 @@ +import * as React from "react" +import { cn } from "../ui/utils" + +interface NewsCardProps extends React.ComponentProps<"div"> { + title: string + summary?: string + source?: string + timestamp?: string + trend?: "up" | "down" | "neutral" + onClick?: () => void +} + +function NewsCard({ + title, + summary, + source, + timestamp, + trend, + onClick, + className, + ...props +}: NewsCardProps) { + return ( +
+
+
+

+ {title} +

+ {summary && ( +

+ {summary} +

+ )} +
+ {source && {source}} + {source && timestamp && ·} + {timestamp && {timestamp}} +
+
+ + {trend && trend !== "neutral" && ( + + {trend === "up" ? "▲" : "▼"} + + )} +
+
+ ) +} + +export { NewsCard } +export type { NewsCardProps } diff --git a/apps/web/src/components/patterns/page-shell.tsx b/apps/web/src/components/patterns/page-shell.tsx new file mode 100644 index 0000000..f61cccb --- /dev/null +++ b/apps/web/src/components/patterns/page-shell.tsx @@ -0,0 +1,42 @@ +import * as React from "react" +import { cn } from "../ui/utils" + +interface PageShellProps extends React.ComponentProps<"div"> { + maxWidth?: string +} + +function PageShell({ + maxWidth = "430px", + className, + children, + ...props +}: PageShellProps) { + return ( +
+
+ {children} +
+
+ ) +} + +type PageContentProps = React.ComponentProps<"main"> + +function PageContent({ className, children, ...props }: PageContentProps) { + return ( +
+ {children} +
+ ) +} + +export { PageShell, PageContent } +export type { PageShellProps, PageContentProps } diff --git a/apps/web/src/components/patterns/progress-bar.tsx b/apps/web/src/components/patterns/progress-bar.tsx new file mode 100644 index 0000000..c8096e5 --- /dev/null +++ b/apps/web/src/components/patterns/progress-bar.tsx @@ -0,0 +1,106 @@ +import * as React from "react" +import { cn } from "../ui/utils" + +/* === Linear Progress Bar === */ + +interface ProgressBarProps extends React.ComponentProps<"div"> { + value: number + max?: number + height?: string + label?: string +} + +function ProgressBar({ + value, + max = 100, + height = "h-4", + label, + className, + ...props +}: ProgressBarProps) { + const percent = Math.min(100, Math.max(0, (value / max) * 100)) + return ( +
+
+
+
+ {label && ( +

{label}

+ )} +
+ ) +} + +/* === Discrete Bar Segments (게이지) === */ + +interface DiscreteBarProps extends React.ComponentProps<"div"> { + total: number + filled: number + height?: string +} + +function DiscreteBar({ + total, + filled, + height = "h-6", + className, + ...props +}: DiscreteBarProps) { + return ( +
+ {[...Array(total)].map((_, i) => ( +
+ ))} +
+ ) +} + +/* === Progress Bar with Label (오늘 방문 스타일) === */ + +interface ProgressBarWithLabelProps extends React.ComponentProps<"div"> { + value: number + max?: number + label: string +} + +function ProgressBarWithLabel({ + value, + max = 100, + label, + className, + ...props +}: ProgressBarWithLabelProps) { + const percent = Math.min(100, Math.max(0, (value / max) * 100)) + return ( +
+
+
+
+ {label} +
+ ) +} + +export { ProgressBar, DiscreteBar, ProgressBarWithLabel } +export type { ProgressBarProps, DiscreteBarProps, ProgressBarWithLabelProps } diff --git a/apps/web/src/components/patterns/ranked-list.tsx b/apps/web/src/components/patterns/ranked-list.tsx new file mode 100644 index 0000000..064a85a --- /dev/null +++ b/apps/web/src/components/patterns/ranked-list.tsx @@ -0,0 +1,94 @@ +import * as React from "react" +import { cn } from "../ui/utils" + +interface RankedItem { + rank: number + name: string + value: string | number + isHighlighted?: boolean + badge?: string +} + +interface RankedListProps extends React.ComponentProps<"div"> { + title: string + items: RankedItem[] + footer?: React.ReactNode +} + +function RankedList({ + title, + items, + footer, + className, + ...props +}: RankedListProps) { + return ( +
+

+ {title} +

+ +
+ {items.map((item) => ( +
+
+
+ {item.rank} +
+
+

+ {item.name} +

+ {item.badge && ( + + {item.badge} + + )} +
+
+ +

+ {item.value} +

+
+ ))} +
+ + {footer && ( +

+ {footer} +

+ )} +
+ ) +} + +export { RankedList } +export type { RankedListProps, RankedItem } diff --git a/apps/web/src/components/patterns/section-card.tsx b/apps/web/src/components/patterns/section-card.tsx new file mode 100644 index 0000000..066690f --- /dev/null +++ b/apps/web/src/components/patterns/section-card.tsx @@ -0,0 +1,48 @@ +import * as React from "react" +import { cn } from "../ui/utils" + +interface SectionCardProps extends React.ComponentProps<"div"> { + title?: string + headerRight?: React.ReactNode + footer?: React.ReactNode +} + +function SectionCard({ + title, + headerRight, + footer, + className, + children, + ...props +}: SectionCardProps) { + return ( +
+ {(title || headerRight) && ( +
+ {title && ( +

+ {title} +

+ )} + {headerRight} +
+ )} + {children} + {footer && ( +
+ {footer} +
+ )} +
+ ) +} + +export { SectionCard } +export type { SectionCardProps } diff --git a/apps/web/src/components/patterns/stat-card.tsx b/apps/web/src/components/patterns/stat-card.tsx new file mode 100644 index 0000000..2372466 --- /dev/null +++ b/apps/web/src/components/patterns/stat-card.tsx @@ -0,0 +1,74 @@ +import * as React from "react" +import { cn } from "../ui/utils" +import { TrendingUp, TrendingDown, type LucideIcon } from "lucide-react" + +interface StatCardProps extends React.ComponentProps<"div"> { + icon: LucideIcon + label: string + value: string | number + unit?: string + trend?: { + value: string + direction: "up" | "down" + } + children?: React.ReactNode +} + +function StatCard({ + icon: Icon, + label, + value, + unit, + trend, + children, + className, + ...props +}: StatCardProps) { + return ( +
+
+
+ +
+

+ {label} +

+
+ +

+ {value} + {unit && {unit}} +

+ + {trend && ( +
+ + {trend.value} + + {trend.direction === "up" ? ( + + ) : ( + + )} +
+ )} + + {children} +
+ ) +} + +export { StatCard } +export type { StatCardProps } diff --git a/apps/web/src/components/patterns/top-bar.tsx b/apps/web/src/components/patterns/top-bar.tsx new file mode 100644 index 0000000..897510f --- /dev/null +++ b/apps/web/src/components/patterns/top-bar.tsx @@ -0,0 +1,68 @@ +import * as React from "react" +import { cn } from "../ui/utils" + +interface TopBarProps extends React.ComponentProps<"header"> { + logo?: React.ReactNode + subtitle?: string + actions?: React.ReactNode +} + +function TopBar({ + logo, + subtitle, + actions, + className, + ...props +}: TopBarProps) { + return ( +
+
+
{logo}
+ {actions && ( +
{actions}
+ )} +
+ {subtitle && ( +

+ {subtitle} +

+ )} +
+ ) +} + +interface TopBarActionProps extends React.ComponentProps<"button"> { + badge?: boolean +} + +function TopBarAction({ + badge, + className, + children, + ...props +}: TopBarActionProps) { + return ( + + ) +} + +export { TopBar, TopBarAction } +export type { TopBarProps, TopBarActionProps } diff --git a/apps/web/src/components/patterns/value-display.tsx b/apps/web/src/components/patterns/value-display.tsx new file mode 100644 index 0000000..cb1b5db --- /dev/null +++ b/apps/web/src/components/patterns/value-display.tsx @@ -0,0 +1,63 @@ +import * as React from "react" +import { cn } from "../ui/utils" + +interface ValueDisplayProps extends React.ComponentProps<"div"> { + value: number + change?: number + prefix?: string + size?: "sm" | "md" | "lg" + formatType?: "integer" | "decimal" + showArrow?: boolean +} + +function ValueDisplay({ + value, + change, + prefix = "₩", + size = "md", + formatType = "integer", + showArrow = true, + className, + ...props +}: ValueDisplayProps) { + const formatValue = (n: number) => { + if (formatType === "decimal") { + return n.toLocaleString("ko-KR", { minimumFractionDigits: 2, maximumFractionDigits: 2 }) + } + return Math.round(n).toLocaleString("ko-KR") + } + + const sizeStyles = { + sm: { value: "text-[16px] font-semibold leading-tight tracking-[-0.01em]", change: "text-[12px]" }, + md: { value: "text-[20px] font-semibold leading-tight tracking-[-0.02em]", change: "text-[14px]" }, + lg: { value: "text-[24px] font-bold leading-none tracking-[-0.02em]", change: "text-[14px]" }, + } + + return ( +
+

+ {prefix}{formatValue(value)} +

+ + {change !== undefined && change !== 0 && ( +

0 ? "text-destructive" : "text-info", + )} + > + {showArrow && {change > 0 ? "▲" : "▼"}} + {formatValue(Math.abs(change))} +

+ )} +
+ ) +} + +export { ValueDisplay } +export type { ValueDisplayProps } diff --git a/apps/web/src/components/ui/accordion.tsx b/apps/web/src/components/ui/accordion.tsx new file mode 100644 index 0000000..bd6b1e3 --- /dev/null +++ b/apps/web/src/components/ui/accordion.tsx @@ -0,0 +1,66 @@ +"use client"; + +import * as React from "react"; +import * as AccordionPrimitive from "@radix-ui/react-accordion"; +import { ChevronDownIcon } from "lucide-react"; + +import { cn } from "./utils"; + +function Accordion({ + ...props +}: React.ComponentProps) { + return ; +} + +function AccordionItem({ + className, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +function AccordionTrigger({ + className, + children, + ...props +}: React.ComponentProps) { + return ( + + svg]:rotate-180", + className, + )} + {...props} + > + {children} + + + + ); +} + +function AccordionContent({ + className, + children, + ...props +}: React.ComponentProps) { + return ( + +
{children}
+
+ ); +} + +export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }; diff --git a/apps/web/src/components/ui/alert.tsx b/apps/web/src/components/ui/alert.tsx new file mode 100644 index 0000000..9c35976 --- /dev/null +++ b/apps/web/src/components/ui/alert.tsx @@ -0,0 +1,66 @@ +import * as React from "react"; +import { cva, type VariantProps } from "class-variance-authority"; + +import { cn } from "./utils"; + +const alertVariants = cva( + "relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current", + { + variants: { + variant: { + default: "bg-card text-card-foreground", + destructive: + "text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90", + }, + }, + defaultVariants: { + variant: "default", + }, + }, +); + +function Alert({ + className, + variant, + ...props +}: React.ComponentProps<"div"> & VariantProps) { + return ( +
+ ); +} + +function AlertTitle({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ); +} + +function AlertDescription({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
+ ); +} + +export { Alert, AlertTitle, AlertDescription }; diff --git a/apps/web/src/components/ui/avatar.tsx b/apps/web/src/components/ui/avatar.tsx new file mode 100644 index 0000000..c990451 --- /dev/null +++ b/apps/web/src/components/ui/avatar.tsx @@ -0,0 +1,53 @@ +"use client"; + +import * as React from "react"; +import * as AvatarPrimitive from "@radix-ui/react-avatar"; + +import { cn } from "./utils"; + +function Avatar({ + className, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +function AvatarImage({ + className, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +function AvatarFallback({ + className, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +export { Avatar, AvatarImage, AvatarFallback }; diff --git a/apps/web/src/components/ui/badge.tsx b/apps/web/src/components/ui/badge.tsx new file mode 100644 index 0000000..2ccc2c4 --- /dev/null +++ b/apps/web/src/components/ui/badge.tsx @@ -0,0 +1,46 @@ +import * as React from "react"; +import { Slot } from "@radix-ui/react-slot"; +import { cva, type VariantProps } from "class-variance-authority"; + +import { cn } from "./utils"; + +const badgeVariants = cva( + "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden", + { + variants: { + variant: { + default: + "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90", + secondary: + "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90", + destructive: + "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60", + outline: + "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground", + }, + }, + defaultVariants: { + variant: "default", + }, + }, +); + +function Badge({ + className, + variant, + asChild = false, + ...props +}: React.ComponentProps<"span"> & + VariantProps & { asChild?: boolean }) { + const Comp = asChild ? Slot : "span"; + + return ( + + ); +} + +export { Badge, badgeVariants }; diff --git a/apps/web/src/components/ui/button.tsx b/apps/web/src/components/ui/button.tsx new file mode 100644 index 0000000..736c83f --- /dev/null +++ b/apps/web/src/components/ui/button.tsx @@ -0,0 +1,71 @@ +import * as React from "react"; +import { Slot } from "@radix-ui/react-slot"; +import { cva, type VariantProps } from "class-variance-authority"; + +import { cn } from "./utils"; + +const buttonVariants = cva( + "inline-flex items-center justify-center whitespace-nowrap font-bold transition-colors duration-150 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-brand/20", + { + variants: { + variant: { + // 토스 스타일: brandSolid — 키컬러 배경, 흰 텍스트 + default: + "bg-brand text-white active:bg-brand/85 disabled:bg-surface-muted disabled:text-text-disabled", + // neutralSolid — 어두운 배경, 흰 텍스트 + neutral: + "bg-[#2A2A2A] text-white active:bg-[#3C3C3C] disabled:bg-surface-muted disabled:text-text-disabled dark:bg-[#E0E0E0] dark:text-[#121212] dark:active:bg-[#C0C0C0]", + // neutralWeak — 연한 회색 배경, 어두운 텍스트 + secondary: + "bg-[#F3F4F5] text-text-primary active:bg-[#EAEBEC] disabled:bg-surface-muted disabled:text-text-disabled dark:bg-[#2B2E35] dark:text-[#E0E0E0] dark:active:bg-[#393D46]", + // criticalSolid — 위험 액션 + destructive: + "bg-destructive text-white active:bg-destructive/85 focus-visible:ring-destructive/20 disabled:bg-surface-muted disabled:text-text-disabled", + // outline — 테두리만 + outline: + "border border-border bg-transparent text-text-primary active:bg-surface-muted/50 disabled:border-surface-muted disabled:text-text-disabled dark:border-white/8", + // ghost — 배경/테두리 없음 + ghost: + "bg-transparent text-text-primary active:bg-surface-muted/50 disabled:text-text-disabled", + // brandGhost — 키컬러 텍스트, 배경 없음 + brandGhost: + "bg-transparent text-brand active:bg-brand/8 disabled:text-text-disabled", + }, + size: { + // 토스 기준 4단계: xsmall(32) / small(36) / medium(40) / large(52) + xs: "h-8 px-3.5 gap-1 text-[13px] rounded-full [&_svg:not([class*='size-'])]:size-3.5", + sm: "h-9 px-3.5 gap-1 text-[14px] rounded-lg [&_svg:not([class*='size-'])]:size-3.5", + md: "h-10 px-4 gap-1.5 text-[14px] rounded-lg [&_svg:not([class*='size-'])]:size-4", + lg: "h-[52px] px-5 gap-2 text-[18px] rounded-xl [&_svg:not([class*='size-'])]:size-[22px]", + icon: "size-10 rounded-full [&_svg:not([class*='size-'])]:size-[18px]", + }, + }, + defaultVariants: { + variant: "default", + size: "md", + }, + }, +); + +function Button({ + className, + variant, + size, + asChild = false, + ...props +}: React.ComponentProps<"button"> & + VariantProps & { + asChild?: boolean; + }) { + const Comp = asChild ? Slot : "button"; + + return ( + + ); +} + +export { Button, buttonVariants }; diff --git a/apps/web/src/components/ui/card.tsx b/apps/web/src/components/ui/card.tsx new file mode 100644 index 0000000..5f9d58a --- /dev/null +++ b/apps/web/src/components/ui/card.tsx @@ -0,0 +1,92 @@ +import * as React from "react"; + +import { cn } from "./utils"; + +function Card({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ); +} + +function CardHeader({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ); +} + +function CardTitle({ className, ...props }: React.ComponentProps<"div">) { + return ( +

+ ); +} + +function CardDescription({ className, ...props }: React.ComponentProps<"div">) { + return ( +

+ ); +} + +function CardAction({ className, ...props }: React.ComponentProps<"div">) { + return ( +

+ ); +} + +function CardContent({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ); +} + +function CardFooter({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ); +} + +export { + Card, + CardHeader, + CardFooter, + CardTitle, + CardAction, + CardDescription, + CardContent, +}; diff --git a/apps/web/src/components/ui/checkbox.tsx b/apps/web/src/components/ui/checkbox.tsx new file mode 100644 index 0000000..c81696b --- /dev/null +++ b/apps/web/src/components/ui/checkbox.tsx @@ -0,0 +1,32 @@ +"use client"; + +import * as React from "react"; +import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; +import { CheckIcon } from "lucide-react"; + +import { cn } from "./utils"; + +function Checkbox({ + className, + ...props +}: React.ComponentProps) { + return ( + + + + + + ); +} + +export { Checkbox }; diff --git a/apps/web/src/components/ui/confirm-modal.tsx b/apps/web/src/components/ui/confirm-modal.tsx new file mode 100644 index 0000000..551ad3c --- /dev/null +++ b/apps/web/src/components/ui/confirm-modal.tsx @@ -0,0 +1,83 @@ +import * as React from "react" +import { cn } from "./utils" + +interface ConfirmModalProps extends React.ComponentProps<"div"> { + isOpen: boolean + onConfirm: () => void + onCancel: () => void + title: string + message: string | string[] + confirmText?: string + cancelText?: string + variant?: "default" | "destructive" +} + +function ConfirmModal({ + isOpen, + onConfirm, + onCancel, + title, + message, + confirmText = "확인", + cancelText = "닫기", + variant = "default", + className, + ...props +}: ConfirmModalProps) { + const messages = Array.isArray(message) ? message : [message] + + if (!isOpen) return null + + return ( +
+
e.stopPropagation()} + {...props} + > +
+ {/* Content */} +
+

+ {title} +

+
+ {messages.map((line, i) => ( +

{line}

+ ))} +
+
+ + {/* Buttons — 토스 규칙: 좌측=닫기, 우측=확인 */} +
+ + +
+
+
+
+ ) +} + +export { ConfirmModal } +export type { ConfirmModalProps } diff --git a/apps/web/src/components/ui/data-display.tsx b/apps/web/src/components/ui/data-display.tsx new file mode 100644 index 0000000..8bb18bb --- /dev/null +++ b/apps/web/src/components/ui/data-display.tsx @@ -0,0 +1,47 @@ +import * as React from "react" +import { cn } from "./utils" + +interface DataDisplayProps extends React.ComponentProps<"div"> { + label: string + value: string | number + icon?: React.ReactNode + highlighted?: boolean +} + +function DataDisplay({ + label, + value, + icon, + highlighted = false, + className, + ...props +}: DataDisplayProps) { + return ( +
+ {icon && ( +
{icon}
+ )} + + {label} + + + {typeof value === "number" ? value.toLocaleString("ko-KR") : value} + +
+ ) +} + +export { DataDisplay } +export type { DataDisplayProps } diff --git a/apps/web/src/components/ui/dialog.tsx b/apps/web/src/components/ui/dialog.tsx new file mode 100644 index 0000000..e79d88e --- /dev/null +++ b/apps/web/src/components/ui/dialog.tsx @@ -0,0 +1,135 @@ +"use client"; + +import * as React from "react"; +import * as DialogPrimitive from "@radix-ui/react-dialog"; +import { XIcon } from "lucide-react"; + +import { cn } from "./utils"; + +function Dialog({ + ...props +}: React.ComponentProps) { + return ; +} + +function DialogTrigger({ + ...props +}: React.ComponentProps) { + return ; +} + +function DialogPortal({ + ...props +}: React.ComponentProps) { + return ; +} + +function DialogClose({ + ...props +}: React.ComponentProps) { + return ; +} + +function DialogOverlay({ + className, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +function DialogContent({ + className, + children, + ...props +}: React.ComponentProps) { + return ( + + + + {children} + + + Close + + + + ); +} + +function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ); +} + +function DialogFooter({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ); +} + +function DialogTitle({ + className, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +function DialogDescription({ + className, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +export { + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogOverlay, + DialogPortal, + DialogTitle, + DialogTrigger, +}; diff --git a/apps/web/src/components/ui/drawer.tsx b/apps/web/src/components/ui/drawer.tsx new file mode 100644 index 0000000..1ca8917 --- /dev/null +++ b/apps/web/src/components/ui/drawer.tsx @@ -0,0 +1,84 @@ +import * as React from "react" +import { cn } from "./utils" + +interface DrawerProps extends React.ComponentProps<"div"> { + isOpen: boolean + onClose: () => void + title: string + position?: "left" | "right" + width?: string + footer?: React.ReactNode +} + +function Drawer({ + isOpen, + onClose, + title, + position = "right", + width = "w-80", + footer, + className, + children, + ...props +}: DrawerProps) { + return ( + <> + {/* Backdrop */} +
+ + {/* Panel */} +
+
+ {/* Header */} +
+

+ {title} +

+ +
+ + {/* Content */} +
+ {children} +
+ + {/* Footer */} + {footer && ( +
+ {footer} +
+ )} +
+
+ + ) +} + +export { Drawer } +export type { DrawerProps } diff --git a/apps/web/src/components/ui/dropdown-menu.tsx b/apps/web/src/components/ui/dropdown-menu.tsx new file mode 100644 index 0000000..d287f98 --- /dev/null +++ b/apps/web/src/components/ui/dropdown-menu.tsx @@ -0,0 +1,257 @@ +"use client"; + +import * as React from "react"; +import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"; +import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react"; + +import { cn } from "./utils"; + +function DropdownMenu({ + ...props +}: React.ComponentProps) { + return ; +} + +function DropdownMenuPortal({ + ...props +}: React.ComponentProps) { + return ( + + ); +} + +function DropdownMenuTrigger({ + ...props +}: React.ComponentProps) { + return ( + + ); +} + +function DropdownMenuContent({ + className, + sideOffset = 4, + ...props +}: React.ComponentProps) { + return ( + + + + ); +} + +function DropdownMenuGroup({ + ...props +}: React.ComponentProps) { + return ( + + ); +} + +function DropdownMenuItem({ + className, + inset, + variant = "default", + ...props +}: React.ComponentProps & { + inset?: boolean; + variant?: "default" | "destructive"; +}) { + return ( + + ); +} + +function DropdownMenuCheckboxItem({ + className, + children, + checked, + ...props +}: React.ComponentProps) { + return ( + + + + + + + {children} + + ); +} + +function DropdownMenuRadioGroup({ + ...props +}: React.ComponentProps) { + return ( + + ); +} + +function DropdownMenuRadioItem({ + className, + children, + ...props +}: React.ComponentProps) { + return ( + + + + + + + {children} + + ); +} + +function DropdownMenuLabel({ + className, + inset, + ...props +}: React.ComponentProps & { + inset?: boolean; +}) { + return ( + + ); +} + +function DropdownMenuSeparator({ + className, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +function DropdownMenuShortcut({ + className, + ...props +}: React.ComponentProps<"span">) { + return ( + + ); +} + +function DropdownMenuSub({ + ...props +}: React.ComponentProps) { + return ; +} + +function DropdownMenuSubTrigger({ + className, + inset, + children, + ...props +}: React.ComponentProps & { + inset?: boolean; +}) { + return ( + + {children} + + + ); +} + +function DropdownMenuSubContent({ + className, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +export { + DropdownMenu, + DropdownMenuPortal, + DropdownMenuTrigger, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuLabel, + DropdownMenuItem, + DropdownMenuCheckboxItem, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, + DropdownMenuSeparator, + DropdownMenuShortcut, + DropdownMenuSub, + DropdownMenuSubTrigger, + DropdownMenuSubContent, +}; diff --git a/apps/web/src/components/ui/form.tsx b/apps/web/src/components/ui/form.tsx new file mode 100644 index 0000000..504f0cc --- /dev/null +++ b/apps/web/src/components/ui/form.tsx @@ -0,0 +1,168 @@ +"use client"; + +import * as React from "react"; +import * as LabelPrimitive from "@radix-ui/react-label"; +import { Slot } from "@radix-ui/react-slot"; +import { + Controller, + FormProvider, + useFormContext, + useFormState, + type ControllerProps, + type FieldPath, + type FieldValues, +} from "react-hook-form"; + +import { cn } from "./utils"; +import { Label } from "./label"; + +const Form = FormProvider; + +type FormFieldContextValue< + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath, +> = { + name: TName; +}; + +const FormFieldContext = React.createContext( + {} as FormFieldContextValue, +); + +const FormField = < + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath, +>({ + ...props +}: ControllerProps) => { + return ( + + + + ); +}; + +const useFormField = () => { + const fieldContext = React.useContext(FormFieldContext); + const itemContext = React.useContext(FormItemContext); + const { getFieldState } = useFormContext(); + const formState = useFormState({ name: fieldContext.name }); + const fieldState = getFieldState(fieldContext.name, formState); + + if (!fieldContext) { + throw new Error("useFormField should be used within "); + } + + const { id } = itemContext; + + return { + id, + name: fieldContext.name, + formItemId: `${id}-form-item`, + formDescriptionId: `${id}-form-item-description`, + formMessageId: `${id}-form-item-message`, + ...fieldState, + }; +}; + +type FormItemContextValue = { + id: string; +}; + +const FormItemContext = React.createContext( + {} as FormItemContextValue, +); + +function FormItem({ className, ...props }: React.ComponentProps<"div">) { + const id = React.useId(); + + return ( + +
+ + ); +} + +function FormLabel({ + className, + ...props +}: React.ComponentProps) { + const { error, formItemId } = useFormField(); + + return ( +