[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
@@ -2,101 +2,242 @@
id: wiki-2026-0508-디자인-시스템-구축
title: 디자인 시스템 구축
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: []
aliases: [Design System, Component Library, UI Kit, Design Tokens]
duplicate_of: none
source_trust_level: A
confidence_score: 0.92
tags: [uncategorized]
confidence_score: 0.9
verification_status: applied
tags: [frontend, design-system, components, tokens, storybook]
raw_sources: []
last_reinforced: 2026-05-08
last_reinforced: 2026-05-10
github_commit: pending
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
tech_stack:
language: unspecified
framework: unspecified
language: typescript
framework: react
---
# [[디자인 시스템 구축|디자인 시스템 구축]]
# 디자인 시스템 구축
## 📌 한 줄 통찰 (The Karpathy Summary)
디자인 시스템은 애플리케이션 구축을 위해 명확한 표준을 바탕으로 조립할 수 있는 재사용 가능한 컴포넌트들의 모음입니다 [1]. 이는 색상, 여백, 타이포그래피 등의 시각적 디자인 원자인 '디자인 토큰([[Design Tokens|Design Tokens]])'을 기초로 하여 브랜드의 시각적 정체성을 프로그래밍 방식으로 구현합니다 [1, 2]. 디자인 시스템을 구축하면 플랫폼 간 일관성을 보장하고, 디자인과 엔지니어링 팀 간의 공통 언어를 형성하며, 유지보수 및 확장을 용이하게 만들 수 있습니다 [1, 3].
## 한 줄
> **"매 product 가 아닌 product 를 만드는 platform"**. Tokens (color/spacing/type) → Primitives (Box, Text) → Components (Button, Modal) → Patterns (Form, Card) → Templates (Page) 의 layer. 2026 표준 stack: Tailwind v4 @theme + shadcn/ui + Radix UI primitives + Storybook 9 + Tokens Studio.
## 📖 구조화된 지식 (Synthesized Content)
- **디자인 토큰(Design Tokens) 기반 설계**
디자인 토큰은 색상, 여백, 타이포그래피, 애니메이션과 같은 디자인 속성을 저장하는 이름이 부여된 식별자입니다 [1, 4]. 이는 특정 기술이나 플랫폼에 구애받지 않으며(Platform-agnostic), 단일 진실 공급원([[Single_Source_of_Truth|Single Source of Truth]])으로서 작용하여 웹의 CSS 변수, iOS의 Swift, Android의 XML 등 다양한 플랫폼의 코드로 변환될 수 있습니다 [3, 5].
## 매 핵심
- **토큰의 3단계 계층 구조 (Token Hierarchy)**
디자인 시스템의 유연성과 일관성을 유지하기 위해 토큰은 일반적으로 3단계 계층 구조로 관리됩니다 [6-8].
1. **Global Tokens (Primitives)**: 문맥 없이 본질적인 값을 나타내는 원시 토큰으로, 디자인 시스템의 기본 팔레트 역할을 합니다 (예: `--blue-500: #3b82f6`) [6-8].
2. **Alias Tokens (Semantic)**: 글로벌 토큰을 참조하며, 특정 의도나 사용 맥락을 설명하는 토큰입니다 (예: `--color-primary: var(--blue-500)`) [6-8].
3. **Component Tokens**: 특정 UI 컴포넌트에 범위가 지정된 토큰으로, 시스템 전체에 영향을 주지 않고 개별 컴포넌트 단위의 세밀한 조정이 가능하게 합니다 (예: `--button-bg: var(--color-primary)`) [6, 8, 9].
### 매 layer 구조
1. **Tokens**: design primitives — color, spacing, type, radii, shadow, motion. CSS variable / JSON.
2. **Primitives** (headless): Radix UI / Ariakit — accessibility 보장, unstyled.
3. **Components**: tokens + primitives → branded — Button, Input, Dialog.
4. **Patterns**: composed components — DataTable, Form, Wizard.
5. **Templates / Pages**: full layouts.
- **유지보수 가능성(Maintainability)과 다중 플랫폼 파이프라인**
대규모 프로젝트에서는 JSON과 같은 중립적 형식으로 디자인 토큰을 저장하고, [[Style Dictionary|Style Dictionary]]나 Theo 등의 자동화 도구를 사용하여 플랫폼 종속적인 코드로 변환하는 파이프라인을 구축합니다 [3, 10, 11]. 이러한 구조적 추상화 계층은 '브랜드 기본 색상 변경'과 같은 요구 사항이 발생했을 때 애플리케이션 내 수천 개의 컴포넌트에 즉시 변경 사항을 전파할 수 있게 하여, 수동 오류를 제거하고 시각적 일관성을 완벽히 확보합니다 [3, 8].
### 매 핵심 결정
- **Headless vs styled**: Radix (headless) + own styles → flex 좋음. Material UI (styled) → 빠른 시작.
- **Distribution**: NPM package (`@acme/ui`) vs copy-paste (shadcn/ui).
- **Theme**: light/dark/brand variants — CSS variable 가 표준.
- **A11y**: 매 Radix/Ariakit 사용으로 무료 — 매 직접 구현 X.
- **반응형 디자인 및 컴포넌트 캡슐화의 통합**
성공적인 디자인 시스템에서는 반응형 동작을 개별 페이지의 문제가 아닌 '컴포넌트의 고유 속성'으로 다루어야 합니다 [12]. 특히 최신 표준인 컨테이너 쿼리([[Container Queries|Container Queries]])를 활용하면, 컴포넌트가 화면 전체의 너비가 아닌 속해 있는 부모 컨테이너의 가용 너비에 따라 스스로 레이아웃을 변경할 수 있습니다 [12, 13]. 이를 통해 어떤 문맥에 배치되더라도 구조가 깨지지 않는 독립적이고 재사용 가능한 진정한 의미의 모듈식 컴포넌트 설계가 가능합니다 [12, 13].
### 매 응용
1. Multi-product company (Atlassian, Shopify Polaris, IBM Carbon).
2. Open source DS (shadcn/ui, Material UI, Mantine).
3. Internal admin tool DS.
4. Marketing + app split (display 강조 + utility).
## 🔗 지식 연결 (Graph)
- **Related Topics:** [[디자인 토큰 (Design Tokens)|디자인 토큰 (Design Tokens]], 컴포넌트 기반 아키텍처 (Component-Based Architecture), 스타일 딕셔너리 (Style Dictionary), [[컨테이너 쿼리 (Container Queries)|컨테이너 쿼리 (Container Queries]]
- **Projects/Contexts:** 대규모 프론트엔드 아키텍처 (Large [[Frontend|Frontend]] [[Architecture|Architecture]]), 크로스 플랫폼 디자인 동기화 (Cross-Platform Design Synchronization)
- **Contradictions/Notes:** 시각적 디자인 앱([[Figma|Figma]] 등)과 개발 환경을 이어주는 토큰 관리를 위한 완벽한 단일 통합 솔루션은 아직 내장되어 있지 않은 경우가 많습니다 [14]. 이를 해결하기 위해 서드파티 플러그인(예: Figma Tokens, Toolabs 등)을 활용해야 하지만, 일부 플러그인은 동기화 버그가 있거나 세밀한 타이포그래피 토큰 관리 등에서 기능적 한계가 존재할 수 있어 실무 적용 시 주의가 필요합니다 [14-16].
## 💻 패턴
---
*Last updated: 2026-04-26*
### Token foundation (Tailwind v4 @theme)
```css
@import "tailwindcss";
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
@theme {
--color-bg: oklch(1 0 0);
--color-fg: oklch(0.2 0 0);
--color-primary: oklch(0.7 0.2 250);
--color-danger: oklch(0.65 0.25 25);
**언제 이 지식을 쓰는가:**
- *(TODO)*
--spacing: 0.25rem; /* base unit */
**언제 쓰면 안 되는가:**
- *(TODO)*
--radius-sm: 0.25rem;
--radius-md: 0.5rem;
--radius-lg: 1rem;
## 🧪 검증 상태 (Validation)
--font-sans: 'Inter Variable', system-ui;
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
--shadow-sm: 0 1px 2px oklch(0 0 0 / 0.05);
--shadow-md: 0 4px 12px oklch(0 0 0 / 0.1);
## 🧬 중복 검사 (Duplicate Check)
--ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌:** 없음
- **정책 변화:** 없음
## 🕓 변경 이력 (Changelog)
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
## 💻 코드 패턴 (Code Patterns)
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
```text
# TODO
/* 매 dark theme */
@media (prefers-color-scheme: dark) {
@theme {
--color-bg: oklch(0.15 0 0);
--color-fg: oklch(0.95 0 0);
}
}
```
## 🤔 의사결정 기준 (Decision Criteria)
### Headless primitive + style (shadcn/ui pattern)
```tsx
// components/ui/dialog.tsx
import * as DialogPrimitive from '@radix-ui/react-dialog';
import { cn } from '@/lib/cn';
**선택 A를 써야 할 때:**
- *(TODO)*
export const Dialog = DialogPrimitive.Root;
export const DialogTrigger = DialogPrimitive.Trigger;
**선택 B를 써야 할 때:**
- *(TODO)*
export const DialogContent = forwardRef<HTMLDivElement, DialogPrimitive.DialogContentProps>(
({ className, children, ...props }, ref) => (
<DialogPrimitive.Portal>
<DialogPrimitive.Overlay className="fixed inset-0 bg-black/50 backdrop-blur" />
<DialogPrimitive.Content
ref={ref}
className={cn(
'fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2',
'rounded-lg bg-bg p-6 shadow-md',
className
)}
{...props}
>
{children}
</DialogPrimitive.Content>
</DialogPrimitive.Portal>
)
);
```
**기본값:**
> *(TODO)*
### Variant API (cva / tailwind-variants)
```ts
import { cva, type VariantProps } from 'class-variance-authority';
## ❌ 안티패턴 (Anti-Patterns)
const button = cva('inline-flex items-center rounded-md font-medium transition', {
variants: {
variant: {
primary: 'bg-primary text-white hover:opacity-90',
ghost: 'hover:bg-fg/5',
danger: 'bg-danger text-white',
},
size: {
sm: 'h-8 px-3 text-sm',
md: 'h-10 px-4 text-base',
lg: 'h-12 px-6 text-lg',
},
},
defaultVariants: { variant: 'primary', size: 'md' },
});
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof button> {}
export const Button = ({ className, variant, size, ...props }: ButtonProps) =>
<button className={button({ variant, size, className })} {...props} />;
```
### Storybook 9 setup
```ts
// Button.stories.tsx
import type { Meta, StoryObj } from '@storybook/react';
import { Button } from './Button';
const meta: Meta<typeof Button> = {
component: Button,
args: { children: 'Click me' },
argTypes: {
variant: { control: 'select', options: ['primary', 'ghost', 'danger'] },
size: { control: 'radio', options: ['sm', 'md', 'lg'] },
},
};
export default meta;
export const Primary: StoryObj<typeof Button> = { args: { variant: 'primary' } };
export const Danger: StoryObj<typeof Button> = { args: { variant: 'danger' } };
```
### Visual regression with Chromatic
```bash
npx chromatic --project-token=$CHROMATIC_TOKEN
# 매 every PR 마다 every story screenshot diff.
```
### A11y testing (axe-core)
```ts
// .storybook/preview.ts
import { withA11y } from '@storybook/addon-a11y';
export const decorators = [withA11y];
```
### Theme provider (multi-brand)
```tsx
function ThemeProvider({ brand, children }: { brand: 'acme' | 'partner', children: ReactNode }) {
return <div data-brand={brand}>{children}</div>;
}
```
```css
[data-brand="acme"] { --color-primary: oklch(0.7 0.2 250); }
[data-brand="partner"] { --color-primary: oklch(0.65 0.18 30); }
```
### Documentation (Storybook MDX)
```mdx
import { Meta, Canvas } from '@storybook/blocks';
import * as ButtonStories from './Button.stories';
<Meta of={ButtonStories} />
# Button
Primary action element.
## Usage
<Canvas of={ButtonStories.Primary} />
### When to use
- 매 form submit
- 매 destructive action — `variant="danger"`
```
### shadcn/ui CLI (copy-paste distribution)
```bash
npx shadcn@latest add button dialog form
# 매 직접 components/ui/ 에 source 가 들어옴 — 매 자유롭게 수정.
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Startup MVP | shadcn/ui copy-paste — quick. |
| Multi-product company | own DS as `@acme/ui` package. |
| Enterprise | Material UI / Carbon / Polaris fork. |
| A11y critical | Radix / Ariakit primitives 필수. |
| Design ↔ code sync | Figma + Tokens Studio + Style Dictionary. |
| Visual QA | Storybook + Chromatic. |
**기본값**: Tailwind v4 @theme + shadcn/ui pattern + Radix primitives + cva + Storybook + Chromatic.
## 🔗 Graph
- 부모: [[Frontend Architecture]] · [[Component Library]]
- 변형: [[Headless UI]] · [[Design Tokens]] · [[Storybook]]
- 응용: [[shadcn/ui]] · [[Radix UI]] · [[Material UI]] · [[Mantine]]
- Adjacent: [[Tailwind v4]] · [[Tokens Studio]] · [[Chromatic]] · [[Figma]]
## 🤖 LLM 활용
**언제**: 5+ devs, 3+ products, brand consistency 필요, A11y compliance.
**언제 X**: 매 single landing page, 매 prototype, single dev (premade DS 로 충분).
## ❌ 안티패턴
- **Inventing primitives**: 매 own dropdown / dialog 만듦 — Radix 사용. A11y 함정 많음.
- **Style first, tokens later**: 매 hardcoded color/size → token 도입 시 mass refactor.
- **Component sprawl**: button 변형 50개 — variant API 로 정리.
- **No Storybook**: design review 시 매 dev branch 띄워야 — 비효율.
- **Forking instead of extending**: shadcn 매 update 누락. wrapper 로 extend.
- **Light-only**: dark mode 나중에 → token 처음부터 분리.
- **No CHANGELOG**: 매 breaking change silent — Changeset.
## 🧪 검증 / 중복
- Weighted by industry adoption (Polaris, Carbon, Material UI, shadcn/ui).
- Verified (Radix UI docs, Tailwind v4 docs, shadcn/ui, Storybook 9 docs, W3C Design Tokens).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — Tailwind v4 + shadcn/ui + Radix + Storybook 9 stack |