diff --git a/apps/landing/src/app/(detail)/docs/devup/breakpoints/page.ko.mdx b/apps/landing/src/app/(detail)/docs/devup/breakpoints/page.ko.mdx new file mode 100644 index 000000000..47213c60c --- /dev/null +++ b/apps/landing/src/app/(detail)/docs/devup/breakpoints/page.ko.mdx @@ -0,0 +1,280 @@ +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeaderCell, + TableRow, +} from '@/components/mdx/components/Table' + +export const metadata = { + title: '브레이크포인트', + alternates: { + canonical: '/ko/docs/devup/breakpoints', + languages: { + en: '/docs/devup/breakpoints', + ko: '/ko/docs/devup/breakpoints', + 'x-default': '/docs/devup/breakpoints', + }, + }, +} + +# 브레이크포인트 + +Devup UI는 6개의 브레이크포인트로 구성된 모바일 우선 반응형 디자인 시스템을 사용합니다. 배열을 사용하면 뷰포트 너비에 따라 서로 다른 스타일을 적용할 수 있습니다. + +## 브레이크포인트 범위 + + + + + 인덱스 + 브레이크포인트 + 범위 + 기기 + + + + + 0 + + xs + + 0px - 479px + 모바일(세로) + + + 1 + + sm + + 480px - 767px + 모바일(가로) + + + 2 + + md + + 768px - 991px + 태블릿 + + + 3 + + lg + + 992px - 1279px + 소형 데스크톱 + + + 4 + + xl + + 1280px - 1599px + 데스크톱 + + + 5 + + 2xl + + 1600px+ + 대형 데스크톱 + + +
+ +## 기본 사용법 + +모든 스타일 prop에 배열을 전달할 수 있습니다. 각 인덱스는 하나의 브레이크포인트에 대응합니다. + +```tsx + +``` + +결과는 다음과 같습니다. + +- **0-479px**: 빨간색 배경 +- **480-767px**: 파란색 배경 +- **768-991px**: 초록색 배경 +- **992-1279px**: 노란색 배경 +- **1280-1599px**: 보라색 배경 +- **1600px+**: 주황색 배경 + +## `null`로 브레이크포인트 건너뛰기 + +`null`을 사용하면 해당 브레이크포인트를 건너뛰고 이전 값을 유지합니다. + +{/* conformance */} + +```tsx + +``` + +결과는 다음과 같습니다. + +- **0-767px**: 빨간색(인덱스 0, 이후 null은 이전 값을 상속) +- **768-1279px**: 초록색(인덱스 2, 이후 null은 이전 값을 상속) +- **1280px+**: 보라색 + +값이 정의된 브레이크포인트마다 별도의 클래스가 생성되고, 건너뛴 브레이크포인트에는 아무것도 출력되지 않습니다. + +```css +.a { + background: red; +} +@media (min-width: 768px) { + .b { + background: green; + } +} +@media (min-width: 1280px) { + .c { + background: purple; + } +} +``` + +## 더 짧은 배열 + +요소가 6개보다 적은 배열은 길이만큼의 브레이크포인트에만 스타일을 적용합니다. + +```tsx +// 모바일과 데스크톱만 정의 +const example = + +// 축약형: 모바일과 태블릿만 정의 +const example2 = +``` + +## 반응형 레이아웃 예제 + +```tsx + + + Left content + + + Right content + + +``` + +- **모바일(0-767px)**: 세로로 쌓이고, 전체 너비를 차지하며, 패딩과 간격이 작습니다. +- **태블릿 이상(768px+)**: 나란히 배치되고, 각각 50% 너비를 차지하며, 패딩과 간격이 커집니다. + +## 반응형 타이포그래피 + +타이포그래피와 함께 사용하여 반응형 텍스트를 만들 수 있습니다. + +```tsx + + Responsive Heading + +``` + +또는 `devup.json`에 정의한 반응형 타이포그래피를 사용할 수 있습니다. + +```json +{ + "theme": { + "typography": { + "h1": [ + { "fontSize": "32px", "fontWeight": 800 }, + null, + null, + null, + { "fontSize": "48px", "fontWeight": 800 } + ] + } + } +} +``` + +```tsx +Responsive Heading +``` + +## 의사 선택자와 함께 사용하기 + +반응형 배열을 의사 선택자와 함께 사용할 수 있습니다. + +{/* conformance */} + +```tsx +// Different hover colors per breakpoint +const example = + +// Alternative syntax +const example2 = +``` + +두 형식 모두 같은 클래스를 생성합니다. + +```css +.a:hover { + background: blue; +} +@media (min-width: 768px) { + .b:hover { + background: purple; + } +} +``` + +## 자주 쓰는 패턴 + +### 요소 표시/숨기기 + +```tsx +// 모바일에서는 숨기고 데스크톱에서는 표시 +const example = ( + Desktop only content +) + +// 모바일에서는 표시하고 데스크톱에서는 숨김 +const example2 = ( + Mobile only content +) +``` + +### 반응형 그리드 + +```tsx + + Item 1 + Item 2 + Item 3 + Item 4 + +``` + +- **모바일**: 1열 +- **태블릿**: 2열 +- **데스크톱**: 4열 + +### 반응형 간격 + +```tsx + + Content with responsive padding and margin + +``` + +참고로 숫자 값에는 4를 곱합니다. 따라서 `p={[2, null, 4]}`는 모바일에서 `padding: 8px`, 태블릿 이상에서 `padding: 16px`가 됩니다. + +## 권장 사항 + +1. **모바일 우선**: 인덱스 0의 모바일 스타일부터 작성합니다. +2. **null을 적절히 활용**: 변경이 필요 없는 브레이크포인트는 건너뜁니다. +3. **단순하게 유지**: 모든 prop에 6개의 값이 필요하지는 않습니다. +4. **충분히 테스트**: 개발 중에 모든 브레이크포인트를 확인합니다. +5. **성능 고려**: 반응형 값은 더 많은 CSS를 생성하므로 신중하게 사용합니다. diff --git a/apps/landing/src/app/(detail)/docs/devup/breakpoints/page.mdx b/apps/landing/src/app/(detail)/docs/devup/breakpoints/page.mdx index c2d1ce12d..08584571b 100644 --- a/apps/landing/src/app/(detail)/docs/devup/breakpoints/page.mdx +++ b/apps/landing/src/app/(detail)/docs/devup/breakpoints/page.mdx @@ -11,6 +11,11 @@ export const metadata = { title: 'Breakpoints', alternates: { canonical: '/docs/devup/breakpoints', + languages: { + en: '/docs/devup/breakpoints', + ko: '/ko/docs/devup/breakpoints', + 'x-default': '/docs/devup/breakpoints', + }, }, } diff --git a/apps/landing/src/app/(detail)/docs/devup/colors/page.ko.mdx b/apps/landing/src/app/(detail)/docs/devup/colors/page.ko.mdx new file mode 100644 index 000000000..d51eec2fe --- /dev/null +++ b/apps/landing/src/app/(detail)/docs/devup/colors/page.ko.mdx @@ -0,0 +1,224 @@ +export const metadata = { + title: '색상', + alternates: { + canonical: '/ko/docs/devup/colors', + languages: { + en: '/docs/devup/colors', + ko: '/ko/docs/devup/colors', + 'x-default': '/docs/devup/colors', + }, + }, +} + +# 색상 + +Devup UI는 직접 지정한 값과 테마 토큰을 통해 유연하게 색상을 관리할 수 있도록 지원합니다. + +## 색상 값 직접 지정 + +모든 컴포넌트에 색상 값을 직접 전달할 수 있습니다. + +{/* conformance */} + +```tsx +// Hex colors +const example1 = +const example2 = + +// RGB/RGBA +const example3 = +const example4 = + +// HSL +const example5 = + +// Named colors +const example6 = +const example7 = +``` + +> Devup UI는 빌드 시점에 색상 값을 자동으로 최적화합니다. `#FF0000`, `#F00`, `rgb(255, 0, 0)`은 모두 `#F00`이 되어 하나의 클래스를 공유하고, `rgba(255, 0, 0, 0.5)`는 `#FF000080`이 됩니다. + +```css +.a { + background: #f00; +} +.b { + background: #ff000080; +} +.c { + background: hsl(0, 100%, 50%); +} +.d { + background: red; +} +.e { + background: tomato; +} +``` + +## 테마 색상 + +규모가 큰 프로젝트에서는 일관성과 테마 지원을 위해 `devup.json`에 색상을 정의하세요. + +```json +{ + "theme": { + "colors": { + "default": { + "primary": "#0070f3", + "secondary": "#7928ca", + "success": "#0070f3", + "warning": "#f5a623", + "error": "#e00", + "text": "#000", + "textSecondary": "#666", + "background": "#fff", + "border": "#eaeaea" + }, + "dark": { + "primary": "#3291ff", + "secondary": "#8a63d2", + "success": "#3291ff", + "warning": "#f7b955", + "error": "#f33", + "text": "#fff", + "textSecondary": "#888", + "background": "#000", + "border": "#333" + } + } + } +} +``` + +테마 색상은 `$` 접두사를 붙여 사용합니다. + +{/* conformance: theme */} + +```tsx +const boxExample1 = +const textExample = +const boxExample2 = +``` + +각 토큰은 CSS 변수를 읽으므로 테마를 전환해도 새 클래스가 필요하지 않습니다. + +```css +.a { + background: var(--primary); +} +.b { + color: var(--text); +} +.c { + border-color: var(--border); +} +``` + +## 여러 테마 변형 + +`default`와 `dark` 외에도 여러 테마 변형을 정의할 수 있습니다. + +```json +{ + "theme": { + "colors": { + "default": { + "primary": "#0070f3" + }, + "dark": { + "primary": "#3291ff" + }, + "blue": { + "primary": "#0052cc" + }, + "green": { + "primary": "#00875a" + } + } + } +} +``` + +기본 테마는 `default`입니다(없으면 `light`, 그것도 없으면 첫 번째 변형). 다른 테마는 테마 API로 활성화할 수 있습니다. 변형에는 바꾸려는 색상만 나열하면 됩니다. 나머지 색상은 기본 테마의 값을 그대로 유지하며, 한 변형에만 정의된 색상은 해당 변형에서만 정의됩니다. + +각 변형은 페이지의 네이티브 색 구성표(폼 컨트롤, 스크롤바, 기본 텍스트 색상)도 설정합니다. `dark`는 어둡게, 그 밖의 모든 변형은 밝게 렌더링되며, 다른 변형의 색 구성표는 `colorScheme`에 지정합니다. + +```json +{ + "theme": { + "colors": { + "default": { "primary": "#0070f3" }, + "midnight": { "primary": "#3291ff" } + }, + "colorScheme": { "midnight": "dark" } + } +} +``` + +토큰 이름은 문자, 숫자 또는 `_`로 시작하고, 이어서 문자, 숫자, `-`, `_`, `.`를 사용할 수 있습니다(`primary`, `text-primary`, `gray.100`). 점은 CSS 변수에서 대시로 바뀌므로 `gray.100`은 `var(--gray-100)`이 됩니다. 허용되지 않는 문자가 포함된 이름이나, 한 변형 안에서 같은 변수가 되는 두 토큰(`a-b`와 `a.b`)이 있으면 브라우저가 무시할 CSS를 출력하는 대신 빌드에서 이를 보고합니다. 색상, `length`, `shadow` 토큰은 CSS 변수의 네임스페이스 하나를 공유하므로, 색상 `card`와 그림자 `card`(둘 다 `--card`)도 빌드 오류가 됩니다. 둘 중 하나의 이름을 바꾸세요. + +## 의미 기반 색상 이름 + +색상을 겉모습이 아니라 용도에 따라 구성하세요. + +```json +{ + "theme": { + "colors": { + "default": { + "primary": "#0070f3", + "primaryHover": "#0060df", + "primaryActive": "#0050c0", + + "text": "#000", + "textMuted": "#666", + "textInverse": "#fff", + + "background": "#fff", + "backgroundSubtle": "#fafafa", + "backgroundMuted": "#f5f5f5", + + "border": "#eaeaea", + "borderFocus": "#0070f3", + + "success": "#0070f3", + "warning": "#f5a623", + "error": "#e00", + "info": "#0070f3" + } + } + } +} +``` + +## 투명도가 있는 색상 사용 + +투명한 변형이 필요하면 RGBA를 사용하거나 별도의 토큰을 정의하세요. + +```json +{ + "theme": { + "colors": { + "default": { + "primary": "#0070f3", + "primaryAlpha10": "rgba(0, 112, 243, 0.1)", + "primaryAlpha20": "rgba(0, 112, 243, 0.2)", + "overlay": "rgba(0, 0, 0, 0.5)" + } + } + } +} +``` + +## 타입 안전성 + +테마 색상은 완전히 타입 안전합니다. TypeScript가 사용 가능한 색상 토큰을 자동 완성합니다. + +```tsx +// 자동 완성 목록: $primary, $secondary, $text 등 + +``` + +잘못된 색상 토큰은 TypeScript 오류로 표시되므로 코드베이스 전체에서 일관성을 유지할 수 있습니다. diff --git a/apps/landing/src/app/(detail)/docs/devup/colors/page.mdx b/apps/landing/src/app/(detail)/docs/devup/colors/page.mdx index 25eed6a2a..470ffd5d7 100644 --- a/apps/landing/src/app/(detail)/docs/devup/colors/page.mdx +++ b/apps/landing/src/app/(detail)/docs/devup/colors/page.mdx @@ -2,6 +2,11 @@ export const metadata = { title: 'Colors', alternates: { canonical: '/docs/devup/colors', + languages: { + en: '/docs/devup/colors', + ko: '/ko/docs/devup/colors', + 'x-default': '/docs/devup/colors', + }, }, } diff --git a/apps/landing/src/app/(detail)/docs/devup/devup-json/page.ko.mdx b/apps/landing/src/app/(detail)/docs/devup/devup-json/page.ko.mdx new file mode 100644 index 000000000..aecd167cd --- /dev/null +++ b/apps/landing/src/app/(detail)/docs/devup/devup-json/page.ko.mdx @@ -0,0 +1,356 @@ +export const metadata = { + title: 'devup.json', + alternates: { + canonical: '/ko/docs/devup/devup-json', + languages: { + en: '/docs/devup/devup-json', + ko: '/ko/docs/devup/devup-json', + 'x-default': '/docs/devup/devup-json', + }, + }, +} + +# devup.json + +`devup.json` 파일은 Devup UI 테마의 설정 파일입니다. 프로젝트 루트에 이 파일을 만들어 색상, 타이포그래피, 길이, 그림자 및 기타 디자인 토큰을 정의합니다. + +사용자 정의 prop 축약형은 디자인 토큰이 아니라 추출 동작에 해당하므로 +이 파일에 넣지 않습니다. 대신 빌드 플러그인에서 설정하세요. +[사용자 정의 축약형](/docs/api/custom-shorthands)을 참고하세요. + +## 기본 구조 + +```json +{ + "theme": { + "colors": { + "default": {}, + "dark": {} + }, + "typography": {}, + "length": { + "default": {} + }, + "shadow": { + "default": {} + } + } +} +``` + +## 전체 예제 + +```json +{ + "theme": { + "colors": { + "default": { + "primary": "#0070f3", + "primaryHover": "#0060df", + "secondary": "#7928ca", + "success": "#0070f3", + "warning": "#f5a623", + "error": "#e00", + "text": "#000", + "textMuted": "#666", + "background": "#fff", + "backgroundMuted": "#fafafa", + "border": "#eaeaea" + }, + "dark": { + "primary": "#3291ff", + "primaryHover": "#2080ef", + "secondary": "#8a63d2", + "success": "#3291ff", + "warning": "#f7b955", + "error": "#f33", + "text": "#fff", + "textMuted": "#888", + "background": "#000", + "backgroundMuted": "#111", + "border": "#333" + } + }, + "typography": { + "h1": [ + { + "fontFamily": "Pretendard", + "fontSize": "32px", + "fontWeight": 800, + "lineHeight": 1.2 + }, + null, + null, + null, + { + "fontFamily": "Pretendard", + "fontSize": "48px", + "fontWeight": 800, + "lineHeight": 1.2 + } + ], + "body": { + "fontFamily": "Pretendard", + "fontSize": "16px", + "fontWeight": 400, + "lineHeight": 1.5 + }, + "caption": { + "fontFamily": "Pretendard", + "fontSize": "14px", + "fontWeight": 400, + "lineHeight": 1.4 + } + } + } +} +``` + +## 색상 설정 + +테마 변형별로 색상 토큰을 정의합니다. + +```json +{ + "theme": { + "colors": { + "default": { + "primary": "#0070f3", + "text": "#000" + }, + "dark": { + "primary": "#3291ff", + "text": "#fff" + } + } + } +} +``` + +- 첫 번째 키(`default`)는 처음 로드할 때 적용되는 기본 테마입니다. +- 각 변형에는 같은 색상 토큰 이름이 있어야 합니다. +- 색상은 `$` 접두사를 붙여 사용합니다: `$primary`, `$text` + +자세한 내용은 [색상](/docs/devup/colors)을 참고하세요. + +## 타이포그래피 설정 + +타이포그래피 스타일을 객체 또는 반응형 배열로 정의합니다. + +```json +{ + "theme": { + "typography": { + "heading": { + "fontFamily": "Pretendard", + "fontSize": "24px", + "fontWeight": 700, + "lineHeight": 1.3 + }, + "responsiveHeading": [ + { "fontSize": "20px", "fontWeight": 700 }, + null, + null, + null, + { "fontSize": "32px", "fontWeight": 700 } + ] + } + } +} +``` + +타이포그래피 속성: + +- `fontFamily` - 글꼴 패밀리 이름 +- `fontSize` - 글꼴 크기(예: `"16px"`) +- `fontWeight` - 굵기(`700` 같은 숫자 또는 `"bold"` 같은 문자열) +- `fontStyle` - 스타일(예: `"italic"`) +- `lineHeight` - 줄 높이(`1.5` 같은 숫자 또는 `"150%"` 같은 문자열) +- `letterSpacing` - 자간(예: `"-0.02em"`) + +자세한 내용은 [타이포그래피](/docs/devup/typography)를 참고하세요. + +## 길이 설정 + +간격, 크기 및 기타 CSS 길이 속성에 사용할 반응형 길이 토큰을 정의합니다. + +```json +{ + "theme": { + "length": { + "default": { + "containerX": ["16px", null, "32px", null, "64px"], + "gutter": ["8px", null, "16px"] + } + } + } +} +``` + +길이 토큰은 타이포그래피와 마찬가지로 반응형 배열을 사용합니다. `null`을 사용하면 브레이크포인트를 건너뛰고 이전 값을 상속합니다. + +자세한 내용은 [길이](/docs/devup/length)를 참고하세요. + +## 그림자 설정 + +box-shadow 값에 사용할 반응형 그림자 토큰을 정의합니다. + +```json +{ + "theme": { + "shadow": { + "default": { + "card": [ + "0 1px 2px rgba(0,0,0,0.1)", + null, + null, + "0 4px 8px rgba(0,0,0,0.1)" + ], + "sm": "0 1px 2px rgba(0,0,0,0.05)" + } + } + } +} +``` + +그림자 토큰도 반응형 배열을 지원합니다. 배열이 아닌 값은 모든 브레이크포인트에 적용되는 하나의 그림자를 정의합니다. + +자세한 내용은 [그림자](/docs/devup/shadow)를 참고하세요. + +## 컴포넌트에서 사용하기 + +### 색상 + +```tsx + +``` + +### 타이포그래피 + +```tsx +const headingExample = Heading +const bodyExample = Body text +``` + +### 길이 + +```tsx + +``` + +### 그림자 + +```tsx + +``` + +## 파일 위치 + +`devup.json` 파일은 프로젝트 루트에 두어야 합니다. + +``` +your-project/ +├── devup.json <-- here +├── package.json +├── src/ +│ └── ... +└── ... +``` + +## 다른 파일 확장하기 + +`extends`에는 기반으로 삼을 다른 `devup.json` 파일을 나열합니다. 예를 들어 +모노레포의 여러 패키지가 공유하는 테마를 확장할 수 있습니다. + +```json +{ + "extends": ["../../shared/devup.json"], + "theme": { + "colors": { + "default": { + "primary": "#0070f3" + } + } + } +} +``` + +- 경로는 패키지 이름이 아니라, 해당 경로를 나열한 파일을 기준으로 한 상대 + 파일 경로입니다. 확장된 파일이 다시 다른 파일을 확장할 수도 있습니다. +- 파일은 순서대로 병합됩니다. 첫 번째 항목이 기반이 되고, 이후 항목이 차례로 + 이를 덮어쓰며, 파일 자신이 마지막에 적용됩니다. +- 객체는 키 단위로 병합되므로, 예제는 공유 파일에 정의된 모든 색상을 유지하고 + `primary`만 교체합니다. 반응형 값이나 `breakpoints` 같은 배열은 통째로 + 교체됩니다. +- 존재하지 않는 파일 경로는 아무것도 추가하지 않습니다. 빌드는 이를 확장한 + 파일과 누락된 경로를 명시하여 경고하며, 해당 파일이 생성되면 이를 + 반영합니다. +- 파일들이 서로를 순환적으로 확장하면 그 연결 고리를 명시한 오류가 발생합니다. + +Vite, webpack, Rsbuild, Next.js 플러그인의 개발 서버는 연결된 파일 중 하나라도 +변경되면 테마를 다시 로드합니다. + +## 플러그인 설정 + +기본적으로 플러그인은 프로젝트 루트에서 `devup.json`을 찾습니다. 프로젝트 루트는 Vite의 `root`, +webpack의 `context`, Rsbuild의 루트, Next.js 프로젝트 디렉터리(webpack +빌드 기준이며, Turbopack 빌드는 작업 디렉터리를 사용합니다) 또는 +`Bun.build`의 `root`입니다. 상대 경로로 지정한 `devupFile`, `distDir`, +`cssDir`은 모노레포 도구(turbo, nx 등)가 빌드를 시작한 디렉터리가 아니라 +이 루트를 기준으로 해석됩니다. `devupFile`을 설정하지 않았고 작업 디렉터리에만 +`devup.json`이 있으면 해당 파일을 그대로 사용하되, 파일을 프로젝트 루트로 +옮기거나 `devupFile`을 설정하라는 경고를 한 번 표시합니다. + +경로를 직접 지정할 수도 있습니다. + +### Vite + +```ts +import { DevupUI } from '@devup-ui/vite-plugin' + +export default defineConfig({ + plugins: [ + DevupUI({ + devupFile: 'config/devup.json', // 사용자 지정 경로 + }), + ], +}) +``` + +### Next.js + +```js +const { DevupUI } = require('@devup-ui/next-plugin') + +module.exports = DevupUI( + { + // Next.js 설정 + }, + { + devupFile: 'config/devup.json', // 사용자 지정 경로 + }, +) +``` + +## 타입 생성 + +프로젝트를 빌드하면 Devup UI가 `devup.json`으로부터 TypeScript 타입을 자동으로 생성합니다. 이를 통해 다음이 가능해집니다. + +- 색상, 타이포그래피, 길이, 그림자 토큰 자동 완성 +- 잘못된 토큰에 대한 타입 오류 +- 코드베이스 전체에서 일관된 사용 + +타입은 `/theme.d.ts`에 생성됩니다. `distDir`은 `devup.json` 필드가 아닌 +빌드 플러그인 옵션이며 기본값은 `df`이므로, 기본 경로는 `df/theme.d.ts`입니다 +(Bun 플러그인은 항상 `df`를 사용합니다). `tsconfig.json`에서 `include`를 제한하고 있다면 `df/*.d.ts` +(또는 사용자 지정 `distDir`에 맞는 경로)를 추가하세요. + +## 핫 리로드 + +개발 중에 `devup.json`을 변경하면 핫 리로드가 실행됩니다. 다음과 같은 작업을 할 수 있습니다. + +1. 새 색상 토큰 추가 +2. 기존 값 수정 +3. 타이포그래피, 길이, 그림자 스타일 추가 + +개발 서버를 다시 시작하지 않아도 변경 사항이 즉시 반영됩니다. diff --git a/apps/landing/src/app/(detail)/docs/devup/devup-json/page.mdx b/apps/landing/src/app/(detail)/docs/devup/devup-json/page.mdx index 41a4d40ea..2fdaa1c90 100644 --- a/apps/landing/src/app/(detail)/docs/devup/devup-json/page.mdx +++ b/apps/landing/src/app/(detail)/docs/devup/devup-json/page.mdx @@ -2,6 +2,11 @@ export const metadata = { title: 'devup.json', alternates: { canonical: '/docs/devup/devup-json', + languages: { + en: '/docs/devup/devup-json', + ko: '/ko/docs/devup/devup-json', + 'x-default': '/docs/devup/devup-json', + }, }, } diff --git a/apps/landing/src/app/(detail)/docs/devup/length/page.ko.mdx b/apps/landing/src/app/(detail)/docs/devup/length/page.ko.mdx new file mode 100644 index 000000000..dbf82b874 --- /dev/null +++ b/apps/landing/src/app/(detail)/docs/devup/length/page.ko.mdx @@ -0,0 +1,137 @@ +export const metadata = { + title: 'Length', + alternates: { + canonical: '/ko/docs/devup/length', + languages: { + en: '/docs/devup/length', + ko: '/ko/docs/devup/length', + 'x-default': '/docs/devup/length', + }, + }, +} + +# Length + +Devup UI는 간격, 크기, 모서리 반경(border-radius) 등 CSS 길이 속성에 사용할 수 있는 반응형 length 토큰을 지원합니다. 타이포그래피와 마찬가지로 length 토큰도 `devup.json`에서 반응형 배열로 정의할 수 있습니다. + +## Length 토큰 정의 + +`devup.json`에 length 토큰을 정의합니다. + +```json +{ + "theme": { + "length": { + "default": { + "containerX": ["16px", null, "32px", null, "64px"], + "gutter": ["8px", null, "16px"], + "borderRadiusMd": ["8px", null, "16px"] + } + } + } +} +``` + +배열의 각 인덱스는 하나의 브레이크포인트에 대응합니다. `null`을 사용하면 해당 브레이크포인트를 건너뛰고 이전 값을 그대로 이어받습니다. + +## 사용법 + +길이 값을 받는 모든 prop에서 `$` 접두사를 붙여 length 토큰을 사용합니다. + +```tsx +<> + + + + + +``` + +`"$token"`과 `{"$token"}` 모두 반응형 토큰을 브레이크포인트별 여러 클래스로 확장합니다. + +{/* conformance: theme */} + +```tsx + +``` + +`gutter`는 인덱스 0과 2에 정의되어 있으므로 prop은 각 인덱스마다 클래스를 하나씩 얻고, 두 클래스 모두 토큰의 CSS 변수를 읽습니다(테마는 브레이크포인트마다 `--gutter`를 정의합니다). + +```css +.a { + gap: var(--gutter); +} +@media (min-width: 768px) { + .b { + gap: var(--gutter); + } +} +``` + +## 반응형 배열에서의 동작 + +`$token`이 반응형 배열 안에 있으면 확장되지 **않습니다**. 배열 자체가 브레이크포인트를 정의하기 때문입니다. + +```tsx +{ + /* "$containerX" stays as a single class at breakpoint index 2 */ +} +; +``` + +인덱스 2의 클래스는 여전히 `var(--containerX)`를 읽습니다. 테마가 브레이크포인트와 테마 변형마다 `--containerX`를 다시 정의하므로, 해당 미디어 쿼리가 적용되는 곳에서는 언제나 토큰의 현재 값이 표시됩니다. + +핵심적인 차이는 다음과 같습니다. + +| 문법 | 동작 | 클래스 수 | +| ----------------------------------- | ----------------------------------------- | --------- | +| `px="$containerX"` | 정의된 모든 브레이크포인트로 확장 | 여러 개 | +| `px={"$containerX"}` | 정의된 모든 브레이크포인트로 확장 | 여러 개 | +| `px={["$containerX"]}` | 인덱스 0에 `var(--containerX)` | 1 | +| `px={["8px", null, "$containerX"]}` | 인덱스 0에 `8px`, 2에 `var(--containerX)` | 2 | + +## 테마 변형 + +length 토큰은 색상과 마찬가지로 테마 변형을 지원합니다. + +```json +{ + "theme": { + "length": { + "default": { + "containerX": ["16px", null, "32px"] + }, + "compact": { + "containerX": ["8px", null, "16px"] + } + } + } +} +``` + +## 반응형이 아닌 토큰 + +모든 브레이크포인트에서 하나의 값을 사용하려면 단순 문자열을 사용합니다. + +```json +{ + "theme": { + "length": { + "default": { + "borderRadiusSm": "4px", + "borderRadiusMd": "8px", + "borderRadiusLg": "16px" + } + } + } +} +``` + +## 타입 안전성 + +length 토큰은 완전한 타입 안전성을 갖습니다. `$`를 입력하면 TypeScript가 사용 가능한 토큰을 자동 완성합니다. + +```tsx +// 자동 완성 목록: $containerX, $gutter, $borderRadiusMd 등 + +``` diff --git a/apps/landing/src/app/(detail)/docs/devup/length/page.mdx b/apps/landing/src/app/(detail)/docs/devup/length/page.mdx index c65ce1364..8828c9668 100644 --- a/apps/landing/src/app/(detail)/docs/devup/length/page.mdx +++ b/apps/landing/src/app/(detail)/docs/devup/length/page.mdx @@ -2,6 +2,11 @@ export const metadata = { title: 'Length', alternates: { canonical: '/docs/devup/length', + languages: { + en: '/docs/devup/length', + ko: '/ko/docs/devup/length', + 'x-default': '/docs/devup/length', + }, }, } diff --git a/apps/landing/src/app/(detail)/docs/devup/shadow/page.ko.mdx b/apps/landing/src/app/(detail)/docs/devup/shadow/page.ko.mdx new file mode 100644 index 000000000..297ae2bff --- /dev/null +++ b/apps/landing/src/app/(detail)/docs/devup/shadow/page.ko.mdx @@ -0,0 +1,144 @@ +export const metadata = { + title: 'Shadow', + alternates: { + canonical: '/ko/docs/devup/shadow', + languages: { + en: '/docs/devup/shadow', + ko: '/ko/docs/devup/shadow', + 'x-default': '/docs/devup/shadow', + }, + }, +} + +# Shadow + +Devup UI는 `box-shadow` 값에 사용할 수 있는 반응형 shadow 토큰을 지원합니다. 타이포그래피, length와 마찬가지로 shadow 토큰도 `devup.json`에서 반응형 배열로 정의할 수 있습니다. + +## Shadow 토큰 정의 + +`devup.json`에 shadow 토큰을 정의합니다. + +```json +{ + "theme": { + "shadow": { + "default": { + "sm": "0 1px 2px rgba(0,0,0,0.05)", + "card": [ + "0 1px 2px rgba(0,0,0,0.1)", + null, + null, + "0 4px 8px rgba(0,0,0,0.1)" + ], + "modal": [ + "0 4px 12px rgba(0,0,0,0.15)", + null, + null, + "0 8px 24px rgba(0,0,0,0.15)" + ] + } + } + } +} +``` + +배열의 각 인덱스는 하나의 브레이크포인트에 대응합니다. `null`을 사용하면 해당 브레이크포인트를 건너뛰고 이전 값을 그대로 이어받습니다. + +## 사용법 + +`boxShadow`에 `$` 접두사를 붙여 shadow 토큰을 사용합니다. + +{/* conformance: theme */} + +```tsx +<> + + + + +``` + +`"$token"`과 `{"$token"}` 모두 반응형 토큰을 브레이크포인트별 여러 클래스로 확장합니다. 테마는 각 토큰을 브레이크포인트별 CSS 변수로 정의하고(색상은 hex로 변환됩니다), 모든 클래스는 이 변수를 읽습니다. + +```css +@layer t { + :root { + --card: 0 1px 2px #0000001a; + --modal: 0 4px 12px #00000026; + --sm: 0 1px 2px #0000000d; + } + @media (min-width: 992px) { + :root { + --card: 0 4px 8px #0000001a; + --modal: 0 8px 24px #00000026; + } + } +} +.a { + box-shadow: var(--card); +} +.c { + box-shadow: var(--sm); +} +.d { + box-shadow: var(--modal); +} +@media (min-width: 992px) { + .b { + box-shadow: var(--card); + } + .e { + box-shadow: var(--modal); + } +} +``` + +## 반응형 배열에서의 동작 + +`$token`이 반응형 배열 안에 있으면 확장되지 **않습니다**. 배열 자체가 브레이크포인트를 정의하기 때문입니다. + +```tsx +{ + /* "$card" stays as a single class at breakpoint index 3 */ +} +; +``` + +인덱스 3의 클래스는 여전히 `var(--card)`를 읽습니다. 테마가 브레이크포인트와 테마 변형마다 `--card`를 다시 정의하므로, 해당 미디어 쿼리가 적용되는 곳에서는 언제나 토큰의 현재 값이 표시됩니다. + +핵심적인 차이는 다음과 같습니다. + +| 문법 | 동작 | 클래스 수 | +| ------------------------------------------- | ------------------------------------ | --------- | +| `boxShadow="$card"` | 정의된 모든 브레이크포인트로 확장 | 여러 개 | +| `boxShadow={"$card"}` | 정의된 모든 브레이크포인트로 확장 | 여러 개 | +| `boxShadow={["$card"]}` | 인덱스 0에 `var(--card)` | 1 | +| `boxShadow={["none", null, null, "$card"]}` | 인덱스 0에 `none`, 3에 `var(--card)` | 2 | + +## 테마 변형 + +shadow 토큰은 색상과 마찬가지로 테마 변형을 지원합니다. + +```json +{ + "theme": { + "shadow": { + "default": { + "card": "0 2px 4px rgba(0,0,0,0.1)" + }, + "dark": { + "card": "0 2px 4px rgba(0,0,0,0.4)" + } + } + } +} +``` + +## 타입 안전성 + +shadow 토큰은 완전한 타입 안전성을 갖습니다. `$`를 입력하면 TypeScript가 사용 가능한 토큰을 자동 완성합니다. + +```tsx +// 자동 완성 목록: $sm, $card, $modal 등 + +``` diff --git a/apps/landing/src/app/(detail)/docs/devup/shadow/page.mdx b/apps/landing/src/app/(detail)/docs/devup/shadow/page.mdx index 156c19564..3bc2c0980 100644 --- a/apps/landing/src/app/(detail)/docs/devup/shadow/page.mdx +++ b/apps/landing/src/app/(detail)/docs/devup/shadow/page.mdx @@ -2,6 +2,11 @@ export const metadata = { title: 'Shadow', alternates: { canonical: '/docs/devup/shadow', + languages: { + en: '/docs/devup/shadow', + ko: '/ko/docs/devup/shadow', + 'x-default': '/docs/devup/shadow', + }, }, } diff --git a/apps/landing/src/app/(detail)/docs/devup/typography/page.ko.mdx b/apps/landing/src/app/(detail)/docs/devup/typography/page.ko.mdx new file mode 100644 index 000000000..7d48f9616 --- /dev/null +++ b/apps/landing/src/app/(detail)/docs/devup/typography/page.ko.mdx @@ -0,0 +1,343 @@ +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeaderCell, + TableRow, +} from '@/components/mdx/components/Table' + +export const metadata = { + title: '타이포그래피', + alternates: { + canonical: '/ko/docs/devup/typography', + languages: { + en: '/docs/devup/typography', + ko: '/ko/docs/devup/typography', + 'x-default': '/docs/devup/typography', + }, + }, +} + +# 타이포그래피 + +Devup UI는 정적 스타일, 반응형 타이포그래피, 테마 통합을 지원하는 강력한 타이포그래피 시스템을 제공합니다. + +## 기본 타이포그래피 + +`devup.json`에 타이포그래피 스타일을 정의합니다. + +```json +{ + "theme": { + "typography": { + "h1": { + "fontFamily": "Pretendard", + "fontSize": "48px", + "fontWeight": 800, + "lineHeight": 1.2, + "letterSpacing": "-0.02em" + }, + "h2": { + "fontFamily": "Pretendard", + "fontSize": "36px", + "fontWeight": 700, + "lineHeight": 1.3, + "letterSpacing": "-0.02em" + }, + "body": { + "fontFamily": "Pretendard", + "fontSize": "16px", + "fontWeight": 400, + "lineHeight": 1.5 + }, + "caption": { + "fontFamily": "Pretendard", + "fontSize": "14px", + "fontWeight": 400, + "lineHeight": 1.4 + } + } + } +} +``` + +`typography` prop으로 타이포그래피를 적용합니다. + +```tsx +const h1Example = Heading 1 +const h2Example = Heading 2 +const bodyExample = Body text +const captionExample = Caption text +``` + +## 타이포그래피 속성 + +각 타이포그래피 스타일에는 다음 속성을 포함할 수 있습니다. + + + + + 속성 + 설명 + 예시 + + + + + + fontFamily + + 글꼴 패밀리 이름 + + "Pretendard" + + + + + fontSize + + 글꼴 크기 + + "16px" + + + + + fontWeight + + 글꼴 굵기(숫자 또는 문자열) + + 700 또는 "bold" + + + + + fontStyle + + 글꼴 스타일 + + "normal" 또는 "italic" + + + + + lineHeight + + 줄 높이(숫자 또는 문자열) + + 1.5 또는 "150%" + + + + + letterSpacing + + 자간 + + "-0.02em" + + + + + textTransform + + 텍스트 변환 + + "uppercase" + + + +
+ +## 반응형 타이포그래피 + +배열을 사용해 반응형 타이포그래피를 정의합니다. 각 인덱스는 하나의 브레이크포인트에 대응합니다. + +```json +{ + "theme": { + "typography": { + "h1": [ + { + "fontFamily": "Pretendard", + "fontSize": "32px", + "fontWeight": 800, + "lineHeight": 1.2 + }, + null, + null, + null, + { + "fontFamily": "Pretendard", + "fontSize": "48px", + "fontWeight": 800, + "lineHeight": 1.2 + } + ] + } + } +} +``` + +브레이크포인트는 다음과 같습니다. + +- 인덱스 0: `0px`(모바일) +- 인덱스 1: `480px` +- 인덱스 2: `768px` +- 인덱스 3: `992px` +- 인덱스 4: `1280px`(데스크톱) +- 인덱스 5: `1600px` + +`null`을 사용하면 해당 브레이크포인트를 건너뛰고 이전 값을 그대로 이어받습니다. + +## 전체 타이포그래피 스케일 + +권장하는 타이포그래피 스케일은 다음과 같습니다. + +```json +{ + "theme": { + "typography": { + "h1": [ + { + "fontFamily": "Pretendard", + "fontSize": "32px", + "fontWeight": 800, + "lineHeight": 1.2, + "letterSpacing": "-0.03em" + }, + null, + null, + null, + { + "fontFamily": "Pretendard", + "fontSize": "48px", + "fontWeight": 800, + "lineHeight": 1.2, + "letterSpacing": "-0.03em" + } + ], + "h2": [ + { + "fontFamily": "Pretendard", + "fontSize": "28px", + "fontWeight": 700, + "lineHeight": 1.3 + }, + null, + null, + null, + { + "fontFamily": "Pretendard", + "fontSize": "36px", + "fontWeight": 700, + "lineHeight": 1.3 + } + ], + "h3": [ + { + "fontFamily": "Pretendard", + "fontSize": "24px", + "fontWeight": 600, + "lineHeight": 1.3 + }, + null, + null, + null, + { + "fontFamily": "Pretendard", + "fontSize": "28px", + "fontWeight": 600, + "lineHeight": 1.3 + } + ], + "body": { + "fontFamily": "Pretendard", + "fontSize": "16px", + "fontWeight": 400, + "lineHeight": 1.5 + }, + "bodyBold": { + "fontFamily": "Pretendard", + "fontSize": "16px", + "fontWeight": 700, + "lineHeight": 1.5 + }, + "caption": { + "fontFamily": "Pretendard", + "fontSize": "14px", + "fontWeight": 400, + "lineHeight": 1.4 + }, + "small": { + "fontFamily": "Pretendard", + "fontSize": "12px", + "fontWeight": 400, + "lineHeight": 1.4 + }, + "buttonL": { + "fontFamily": "Pretendard", + "fontSize": "18px", + "fontWeight": 600, + "lineHeight": 1.3 + }, + "buttonM": { + "fontFamily": "Pretendard", + "fontSize": "16px", + "fontWeight": 600, + "lineHeight": 1.3 + }, + "buttonS": { + "fontFamily": "Pretendard", + "fontSize": "14px", + "fontWeight": 600, + "lineHeight": 1.3 + } + } + } +} +``` + +## 컴포넌트에서 타이포그래피 사용 + +```tsx +// Text 컴포넌트에서 사용 +const titleExample = Main Title +const bodyExample = Paragraph text goes here. + +// Box 컴포넌트에서 사용 +const boxExample = Caption in a box +``` + +```tsx +// styled로 만든 컴포넌트에서 사용 +const Title = styled('h1', { + typography: 'h1', + color: '$text', +}) +``` + +## 다른 스타일과 함께 사용 + +타이포그래피는 다른 스타일 props와 함께 사용할 수 있습니다. `typography` 옆에 작성한 속성은 지정한 브레이크포인트부터 그 이후의 모든 브레이크포인트에서 프리셋보다 우선합니다. 따라서 ``는 `h1`의 크기가 커지는 구간에서도 `14px`를 유지합니다. 조건부로만 지정한 속성(`fontSize={small ? '12px' : undefined}`)도 마찬가지입니다. 프리셋 선언은 직접 작성한 선언보다 아래 캐스케이드 레이어에 놓이므로, 직접 작성한 값이 적용될 때는 언제나 그 값이 우선합니다. + +```tsx +const example = ( + + Centered Title + +) +``` + +## 타입 안전성 + +타이포그래피 토큰은 완전한 타입 안전성을 갖습니다. + +```tsx +// TypeScript 자동 완성 목록: h1, h2, body 등 +const example = + +// 잘못된 토큰은 TypeScript 오류를 표시합니다 +const invalidExample = // 오류! +``` diff --git a/apps/landing/src/app/(detail)/docs/devup/typography/page.mdx b/apps/landing/src/app/(detail)/docs/devup/typography/page.mdx index 965106674..b1cb72655 100644 --- a/apps/landing/src/app/(detail)/docs/devup/typography/page.mdx +++ b/apps/landing/src/app/(detail)/docs/devup/typography/page.mdx @@ -11,6 +11,11 @@ export const metadata = { title: 'Typography', alternates: { canonical: '/docs/devup/typography', + languages: { + en: '/docs/devup/typography', + ko: '/ko/docs/devup/typography', + 'x-default': '/docs/devup/typography', + }, }, } diff --git a/apps/landing/src/app/(detail)/docs/figma-and-theme-integration/devup-figma-plugin/page.ko.mdx b/apps/landing/src/app/(detail)/docs/figma-and-theme-integration/devup-figma-plugin/page.ko.mdx new file mode 100644 index 000000000..f3b9369f1 --- /dev/null +++ b/apps/landing/src/app/(detail)/docs/figma-and-theme-integration/devup-figma-plugin/page.ko.mdx @@ -0,0 +1,39 @@ +export const metadata = { + title: 'Devup Figma 플러그인', + alternates: { + canonical: '/ko/docs/figma-and-theme-integration/devup-figma-plugin', + languages: { + en: '/docs/figma-and-theme-integration/devup-figma-plugin', + ko: '/ko/docs/figma-and-theme-integration/devup-figma-plugin', + 'x-default': '/docs/figma-and-theme-integration/devup-figma-plugin', + }, + }, +} + +# Devup Figma 플러그인 + +Devup UI는 디자인과 개발 워크플로를 매끄럽게 연결해 주는 강력한 Figma 플러그인을 제공합니다. 이 플러그인은 Figma 레이어를 Devup UI 코드 스니펫으로 변환하고 디자인 토큰을 내보냅니다. + +### **Figma Community에서 설치** + +1. Figma를 엽니다. +2. **Plugins** → **Browse all plugins**로 이동합니다. +3. "Devup UI"를 검색합니다. +4. Devup UI 플러그인에서 **Open in Figma**를 클릭하거나 [Figma Community 페이지](https://www.figma.com/community/plugin/1412341601954480694)로 직접 이동합니다. + +## 주요 기능 + +### **레이어를 컴포넌트로 변환** + +Figma 레이어를 Devup UI 컴포넌트로 변환합니다. + +```tsx +// Figma 레이어에서 생성된 코드 + + Button Text + +``` + +### **디자인 토큰 내보내기** + +Figma의 디자인 토큰을 `devup.json`으로 내보냅니다. diff --git a/apps/landing/src/app/(detail)/docs/figma-and-theme-integration/devup-figma-plugin/page.mdx b/apps/landing/src/app/(detail)/docs/figma-and-theme-integration/devup-figma-plugin/page.mdx index 3a33d5039..fa91231ac 100644 --- a/apps/landing/src/app/(detail)/docs/figma-and-theme-integration/devup-figma-plugin/page.mdx +++ b/apps/landing/src/app/(detail)/docs/figma-and-theme-integration/devup-figma-plugin/page.mdx @@ -2,6 +2,11 @@ export const metadata = { title: 'Devup Figma Plugin', alternates: { canonical: '/docs/figma-and-theme-integration/devup-figma-plugin', + languages: { + en: '/docs/figma-and-theme-integration/devup-figma-plugin', + ko: '/ko/docs/figma-and-theme-integration/devup-figma-plugin', + 'x-default': '/docs/figma-and-theme-integration/devup-figma-plugin', + }, }, } diff --git a/apps/landing/src/app/(detail)/docs/figma-and-theme-integration/devup-json/page.ko.mdx b/apps/landing/src/app/(detail)/docs/figma-and-theme-integration/devup-json/page.ko.mdx new file mode 100644 index 000000000..115b586af --- /dev/null +++ b/apps/landing/src/app/(detail)/docs/figma-and-theme-integration/devup-json/page.ko.mdx @@ -0,0 +1,227 @@ +export const metadata = { + title: 'devup.json 설정', + alternates: { + canonical: '/ko/docs/figma-and-theme-integration/devup-json', + languages: { + en: '/docs/figma-and-theme-integration/devup-json', + ko: '/ko/docs/figma-and-theme-integration/devup-json', + 'x-default': '/docs/figma-and-theme-integration/devup-json', + }, + }, +} + +# devup.json 설정 + +`devup.json` 파일은 Devup UI의 핵심 설정 파일로, 사용자 정의 테마, 색상, 타이포그래피 등 다양한 디자인 토큰을 정의할 수 있습니다. + +## 기본 구조 + +```json +{ + "theme": { + "colors": { + "default": { + "primary": "#5A44FF" + } + }, + "typography": { + "h1": { + "fontSize": "32px" + } + } + } +} +``` + +## 색상 설정 + +`theme.colors`는 변형 이름(`default`, `light`, `dark` 또는 직접 정한 이름)을 +토큰 맵에 대응시킵니다. 평면적인 `colors.primary` 값은 테마 스키마에 맞지 않으므로, +`colors.default.primary`처럼 변형 아래에 배치해야 합니다. + +### **기본 색상 설정** + +테마별로 색상을 정의합니다. + +```json +{ + "theme": { + "colors": { + "light": { + "primary": "#5A44FF", + "secondary": "#85A5F2", + "text": "#2F2F2F", + "background": "#FFF" + }, + "dark": { + "primary": "#9086FF", + "secondary": "#2A4586", + "text": "#EDEDED", + "background": "#131313" + } + } + } +} +``` + +### **의미 기반 색상 이름** + +용도를 설명하는 의미 기반 이름을 사용합니다. + +```json +{ + "theme": { + "colors": { + "light": { + "primary": "#5A44FF", + "primaryHover": "#4D38AE", + "text": "#2F2F2F", + "textSecondary": "#787878", + "background": "#FFF", + "surface": "#F8F8F8", + "success": "#4CAF50", + "warning": "#FF9800", + "error": "#F44336" + } + } + } +} +``` + +### **색상 변형** + +불투명도를 적용한 색상 변형을 만듭니다. + +```json +{ + "theme": { + "colors": { + "light": { + "primary": "#5A44FF", + "primary50": "#5A44FF80", + "primary20": "#5A44FF33", + "black50": "#00000080" + } + } + } +} +``` + +## 타이포그래피 설정 + +### **타이포그래피 속성** + +각 타이포그래피 정의에는 다음 속성을 포함할 수 있습니다. + +- **fontFamily**: 글꼴 패밀리 이름 +- **fontWeight**: 숫자 굵기(100-900) 또는 문자열 +- **fontSize**: 단위를 포함한 크기(`16px`, `1rem`) +- **lineHeight**: 숫자 비율 또는 단위를 포함한 문자열 +- **letterSpacing**: 단위를 포함한 자간(`-0.03em`) + +### **타이포그래피 구성** + +정적인 값은 객체로, 반응형 브레이크포인트는 배열로 타이포그래피 스타일을 정의합니다. + +#### **정적 타이포그래피** + +```json +{ + "theme": { + "typography": { + "caption": { + "fontFamily": "Pretendard", + "fontWeight": 500, + "fontSize": "14px", + "lineHeight": 1.4 + } + } + } +} +``` + +#### **반응형 타이포그래피** + +배열을 사용해 브레이크포인트마다 스타일을 정의합니다. + +```json +{ + "theme": { + "typography": { + "heading": [ + { + "fontFamily": "Pretendard", + "fontWeight": 700, + "fontSize": "20px", + "lineHeight": 1.3 + }, + { + "fontFamily": "Pretendard", + "fontWeight": 700, + "fontSize": "28px", + "lineHeight": 1.3 + }, + { + "fontFamily": "Pretendard", + "fontWeight": 700, + "fontSize": "32px", + "lineHeight": 1.2 + } + ] + } + } +} +``` + +## 컴포넌트에서 사용 + +### **색상 사용** + +`$` 접두사로 색상에 접근합니다. + +```tsx + + Content + +``` + +선택한 변형에 정의된 토큰만 사용하세요. 기본 구조 예시는 +`$primary`만 정의하므로, `$text`를 사용하려면 먼저 해당 변형에 `text`를 추가해야 합니다. + +### 생성된 테마 타입 + +빌드 플러그인은 `distDir` 안에 `theme.d.ts`를 생성합니다. 기본 +`distDir`은 `df`이므로 기본 선언 파일 경로는 `df/theme.d.ts`입니다. 타입 +자동 완성을 활성화하려면 생성된 선언 파일을 `tsconfig.json`에 포함합니다. + +```json +{ + "include": ["src", "df/*.d.ts"] +} +``` + +`distDir`은 빌드 플러그인 옵션이며 `devup.json`의 필드가 아닙니다. 예를 들어 +Vite 설정에서 생성 디렉터리를 변경할 수 있습니다. + +```ts +import DevupUI from '@devup-ui/vite-plugin' +import { defineConfig } from 'vite' + +export default defineConfig({ + plugins: [DevupUI({ distDir: 'generated/devup' })], +}) +``` + +이 설정은 `generated/devup/theme.d.ts`를 생성하므로, `df/*.d.ts` 대신 +`generated/devup/*.d.ts`를 포함해야 합니다. 테마를 변경한 후에는 빌드 플러그인을 +실행해 선언 파일을 다시 생성하세요. + +### **타이포그래피 사용** + +`typography` prop으로 타이포그래피 스타일을 적용합니다. + +```tsx +<> + Heading 1 + +``` diff --git a/apps/landing/src/app/(detail)/docs/figma-and-theme-integration/devup-json/page.mdx b/apps/landing/src/app/(detail)/docs/figma-and-theme-integration/devup-json/page.mdx index 5bf10cbc0..1fb10313f 100644 --- a/apps/landing/src/app/(detail)/docs/figma-and-theme-integration/devup-json/page.mdx +++ b/apps/landing/src/app/(detail)/docs/figma-and-theme-integration/devup-json/page.mdx @@ -2,6 +2,11 @@ export const metadata = { title: 'devup.json Configuration', alternates: { canonical: '/docs/figma-and-theme-integration/devup-json', + languages: { + en: '/docs/figma-and-theme-integration/devup-json', + ko: '/ko/docs/figma-and-theme-integration/devup-json', + 'x-default': '/docs/figma-and-theme-integration/devup-json', + }, }, } diff --git a/apps/landing/src/app/(detail)/docs/migration/overview/page.ko.mdx b/apps/landing/src/app/(detail)/docs/migration/overview/page.ko.mdx new file mode 100644 index 000000000..48567a4a7 --- /dev/null +++ b/apps/landing/src/app/(detail)/docs/migration/overview/page.ko.mdx @@ -0,0 +1,105 @@ +export const metadata = { + title: '마이그레이션', + alternates: { + canonical: '/ko/docs/migration/overview', + languages: { + en: '/docs/migration/overview', + ko: '/ko/docs/migration/overview', + 'x-default': '/docs/migration/overview', + }, + }, +} + +# 다른 CSS-in-JS 라이브러리에서 마이그레이션하기 + +Devup UI는 styled-components, Emotion, vanilla-extract, StyleX 소스를 그대로 읽습니다. 호출 위치를 다시 작성할 필요도, 원래 라이브러리를 설치해 둘 필요도 없습니다. 빌드가 import를 다시 작성하고 모든 호출을 정적 CSS로 컴파일합니다. + +## 코드에 일어나는 일 + +```tsx +// 작성한 코드 +import styled from 'styled-components' + +const Card = styled.div` + color: red; +` +``` + +```tsx +// 배포되는 코드(단순화) — styled-components도, 런타임도 없음 +// (실제 출력은 `ref`도 전달하고, `as`를 받으며, `$` props를 제거합니다) +const Card = ({ style, className, ...rest }) => ( +
+) +``` + +```css +.a { + color: red; +} +``` + +import는 단순히 `@devup-ui/react`를 가리키도록 바뀌는 것이 아닙니다. 추출기가 호출을 소비하고 specifier를 제거하므로, import 문은 출력에서 완전히 사라집니다. + +## 두 단계 + +1. **import 재작성** — `import { style } from '@vanilla-extract/css'`는 `import { css as style } from '@devup-ui/react'`가 됩니다. 실제로 대응하는 Devup UI API가 있는 이름만 옮겨지며, 나머지는 자체 타입이 계속 동작하도록 그대로 남습니다. +2. **추출** — `style({ ... })`는 클래스 이름으로 컴파일되고, specifier가 제거되며, 비게 된 import는 삭제됩니다. + +두 번째 단계 덕분에 중간 단계의 `css as style` alias는 번들에 포함되지 않습니다. + +## 활성화하기 + +모든 플러그인은 기본 alias를 자동으로 켭니다: + +```ts +// vite.config.ts +import { DevupUI } from '@devup-ui/vite-plugin' + +export default DevupUI({}) +``` + +기본값은 `styled-components`, `@emotion/styled`, `@emotion/react`, `@emotion/css`, `@vanilla-extract/css`를 포함합니다. StyleX는 alias가 필요 없습니다. `@stylexjs/stylex`는 직접 인식됩니다. + +원래 라이브러리를 계속 사용하려면 해당 패키지를 제외하세요: + +```ts +DevupUI({ + importAliases: { + 'styled-components': false, + }, +}) +``` + +## 원래 패키지 제거하기 + +import가 다시 작성되고 나면, 빌드가 오류를 보고하지 않는 한 의존성을 제거할 수 있습니다. Devup UI에 대응하는 API가 없는 export(`@emotion/react`의 `ThemeContext`나 `withEmotionCache`, `@emotion/css/create-instance`, vanilla-extract의 `recipes`와 `sprinkles`)는 패키지를 남겨 두는 대신 그 이름을 알려 주는 빌드 오류가 됩니다. `@emotion/css`의 `cache`, `flush`, `hydrate`, `sheet`는 런타임에 삽입된 스타일을 다루므로 `@emotion/css`에 남으며, 이를 사용하는 파일은 해당 패키지를 유지합니다. TypeScript는 여전히 작성한 specifier를 해석해야 하므로, 플러그인은 활성화한 alias에 대한 ambient 선언을 담은 `/compat.d.ts`를 생성합니다: + +```ts +/// +/// +/// +/// +``` + +이 파일은 프로젝트 안의 `theme.d.ts` 옆에 생성되므로, 별도 설정 없이 `tsconfig.json`이 인식합니다. 비활성화한 alias는 의도적으로 제외됩니다. ambient 선언은 설치된 패키지보다 우선하며, 제외한 라이브러리는 자체 타입을 유지해야 하기 때문입니다. + +## 어떤 스타일이 적용되는가 + +빌드가 볼 수 있는 합성은 같은 속성에 대해 나중 스타일이 적용된다는 원래 라이브러리의 규칙을 유지합니다: `css(a, b)`와 Emotion의 `cx(a, b)`, 파일에서 정의한 컴포넌트의 `styled(Base)` 확장, `.attrs()`, vanilla-extract의 `style([a, b])`, StyleX의 `props(a, b)`가 여기에 해당합니다. 빌드는 이들을 하나의 클래스 집합으로 병합하므로, `color`를 덮어쓰는 `styled(Base)`는 새 색상만 배포합니다. + +런타임에만 일어나는 합성은 병합할 수 없으며, 이 경우 작성한 순서가 아니라 CSS 캐스케이드가 결과를 결정합니다. props로 전달된 `className`, CSS Modules나 다른 라이브러리의 클래스, 런타임에 만든 클래스 문자열을 Devup UI 클래스와 합치는 경우가 그렇습니다. 런타임 라이브러리가 나중 스타일을 마지막에 삽입하는 동작에 의존하던 코드는 여기서 결과가 달라질 수 있습니다. 변형은 prop, 조건(`cond ? a : b`), 또는 같은 파일 안의 `styled()` 확장으로 전달해서 빌드가 양쪽을 모두 볼 수 있게 하세요. + +전체 목록은 [스타일 덮어쓰기 규칙](/docs/limitations)을 참고하세요. + +## 흡수한 API의 위치 + +다른 라이브러리를 흡수하기 위해서만 존재하는 API(`ThemeProvider`, `createGlobalStyle`, `ServerStyleSheet` 등)는 `@devup-ui/react`가 아니라 `@devup-ui/react/compat`에서 export됩니다. Devup UI를 직접 사용하면 이들을 볼 일이 없으며, compat 엔트리는 원래 이름을 그대로 유지할 수 있습니다. 그 `useTheme`가 Devup UI 자체의 `useTheme`와 충돌하지 않기 때문입니다. + +```tsx +// rewritten for you +``` diff --git a/apps/landing/src/app/(detail)/docs/migration/overview/page.mdx b/apps/landing/src/app/(detail)/docs/migration/overview/page.mdx index 8eda17bf6..ab1387fc1 100644 --- a/apps/landing/src/app/(detail)/docs/migration/overview/page.mdx +++ b/apps/landing/src/app/(detail)/docs/migration/overview/page.mdx @@ -2,6 +2,11 @@ export const metadata = { title: 'Migration', alternates: { canonical: '/docs/migration/overview', + languages: { + en: '/docs/migration/overview', + ko: '/ko/docs/migration/overview', + 'x-default': '/docs/migration/overview', + }, }, } diff --git a/apps/landing/src/app/(detail)/docs/migration/stylex/page.ko.mdx b/apps/landing/src/app/(detail)/docs/migration/stylex/page.ko.mdx new file mode 100644 index 000000000..8d4cc5a0b --- /dev/null +++ b/apps/landing/src/app/(detail)/docs/migration/stylex/page.ko.mdx @@ -0,0 +1,274 @@ +export const metadata = { + title: '마이그레이션', + alternates: { + canonical: '/ko/docs/migration/stylex', + languages: { + en: '/docs/migration/stylex', + ko: '/ko/docs/migration/stylex', + 'x-default': '/docs/migration/stylex', + }, + }, +} + +# StyleX + +`@stylexjs/stylex`는 alias 설정이 필요 없습니다. 추출기가 default import, 네임스페이스 import, named import 중 어떤 방식이든 패키지를 직접 인식합니다. + +## 스타일과 props + +`create()`는 네임스페이스에서 클래스 이름으로 매핑되는 객체가 되고, `props()`는 spread할 속성이 됩니다: + +```tsx +import stylex from '@stylexjs/stylex' + +const styles = stylex.create({ + base: { display: 'inline-block' }, +}) +const colors = stylex.create({ red: { color: 'red' }, blue: { color: 'blue' } }) + +const el =
+``` + +```tsx +const styles = { base: 'a' } +const colors = { red: 'b', blue: 'c' } + +const el =
+``` + +`colors[color]` 같은 computed 접근은 `create()` 호출이 변환된 객체를 기준으로 해석되므로, 생성된 모든 atom에 계속 접근할 수 있습니다. `stylex.attrs()`도 동일하게 동작하지만 `className` 대신 `class`를 출력합니다. + +숫자에는 StyleX가 붙이는 단위가 붙습니다. `fontSize: 16`은 `16px`, `transitionDuration: 300`은 `300ms`가 되며, `lineHeight` 같은 단위 없는 속성은 작성한 그대로 유지됩니다. 동적 스타일에 전달한 숫자도 런타임에 같은 단위가 붙습니다. + +허용되는 인자 형태: + +```tsx +stylex.props(styles.base) // 멤버 접근 +stylex.props(styles['base']) // 리터럴 키 +stylex.props(colors[color]) // 런타임 키 +stylex.props([styles.a, styles.b]) // StyleXArray, 중첩 가능 +stylex.props(on && styles.active) // 조건부 +stylex.props(styles?.base) // optional chaining +``` + +## 축약 속성과 `styleResolution` + +StyleX의 babel 플러그인은 `styleResolution` 옵션으로 축약 속성과 그것이 포함하는 개별 속성(longhand) 중 무엇을 적용할지 결정합니다. Devup UI 플러그인에도 같은 옵션을 전달하세요: + +```ts +// vite.config.ts (모든 플러그인이 같은 옵션을 받습니다) +DevupUI({ stylex: { styleResolution: 'application-order' } }) +``` + +| `styleResolution` | 적용되는 쪽 | +| --------------------------------- | -------------------------------------------------------------------- | +| `'property-specificity'` (기본값) | 적용 순서와 관계없이 개별 속성이 축약 속성보다 우선함 | +| `'application-order'` | 축약 속성 여부와 관계없이 마지막에 적용된 속성 | +| `'legacy-expand-shorthands'` | 축약 속성이 남지 않음: 빌드 시점에 각 축약 속성을 개별 속성으로 나눔 | + +어떤 정책이든 하나의 `props()`나 `attrs()` 호출 안에서는 같은 속성과 조건에 대해 나중 스타일이 앞선 스타일을 대체합니다. `stylex.props(colors.red, colors.blue)`는 blue 클래스만 유지합니다. + +```tsx +const styles = stylex.create({ + top: { paddingTop: '1px' }, + pad: { padding: '2px' }, +}) + +const el =
+``` + +- `'property-specificity'`는 두 클래스를 모두 유지하고 스타일시트에서 `padding-top`을 `padding` 뒤에 작성하므로 `padding-top: 1px`가 적용됩니다. +- `'application-order'`는 StyleX처럼 `padding`이 포함하는 개별 속성에 대해 `null` 초기화를 추가하므로, 나중에 오는 `padding`이 `padding-top`을 제거합니다. 순서가 반대이면 둘 다 유지되고 `padding-top`이 적용됩니다. +- `'legacy-expand-shorthands'`는 `padding: '1px 2px'`를 `padding-top`, `padding-inline-end`, `padding-bottom`, `padding-inline-start`로 바꾸며, 이들은 다른 개별 속성과 마찬가지로 키별로 병합됩니다. + +기본값이 아닌 두 정책은 별칭(`marginStart`는 `margin-inline-start`, `blockSize`는 `height`)을 포함한 StyleX 자체의 축약 속성 테이블을 읽으며, 정적 `create()` 네임스페이스에만 적용됩니다. 여기서 축약 속성은 `firstThatWorks()` 폴백을 받을 수 없고, `application-order`는 StyleX처럼 `all`을 거부합니다. 둘 다 해당 키를 알려 주는 빌드 오류입니다. 동적(화살표 함수) 네임스페이스는 축약 속성을 작성한 그대로 유지하며, `float`/`clear`도 `inline-start` 같은 논리 값을 작성한 그대로 유지합니다. 이들에 대한 StyleX의 polyfill은 자체 런타임 변수에 의존하기 때문입니다. 알 수 없는 `styleResolution`은 플러그인을 생성할 때 설정 오류가 됩니다. Devup UI 자체 API(`css()`, `styled`, `Box` props)는 이 옵션을 무시합니다. 여기서는 개별 속성 뒤에 작성한 축약 속성이 적용됩니다. + +## 변수와 테마 + +```tsx +const colors = stylex.defineVars({ primary: 'blue', secondary: 'grey' }) +const dark = stylex.createTheme(colors, { primary: 'navy' }) +const styles = stylex.create({ box: { color: colors.primary } }) + +const el =
+``` + +```css +:root { + --a: blue; + --b: grey; +} +.c { + --a: navy; +} +.d { + color: var(--a); +} +``` + +```tsx +const colors = { primary: 'var(--a)', secondary: 'var(--b)' } +const dark = 'c' +const styles = { box: 'd' } +const el =
+``` + +`createThemeContract()`는 `:root` 블록을 출력하지 않고 같은 참조를 만들며, `defineConsts()`는 그 값을 읽는 `create()` 호출에 값을 인라인합니다. + +변수나 테마 값은 선택적인 `types.*()` 래퍼와 함께 at-rule에 따라 달라질 수 있습니다. 각 조건 집합은 무조건 값 뒤에 하나의 블록이 되며, 중첩 조건은 그것이 세분화하는 조건 뒤에 오므로 더 구체적인 값이 적용됩니다: + +```tsx +const DARK = '@media (prefers-color-scheme: dark)' + +const colors = stylex.defineVars({ + text: { default: 'black', [DARK]: 'white' }, + accent: stylex.types.color({ default: 'blue', [DARK]: 'lightblue' }), +}) +const dracula = stylex.createTheme(colors, { + text: { default: 'purple', [DARK]: 'pink' }, +}) +``` + +```css +@property --b { + syntax: ''; + inherits: true; + initial-value: blue; +} +:root { + --a: black; + --b: blue; +} +@media (prefers-color-scheme: dark) { + :root { + --a: white; + --b: lightblue; + } +} +.c { + --a: purple; +} +@media (prefers-color-scheme: dark) { + .c { + --a: pink; + } +} +``` + +조건은 `default`, `@media`, `@supports`, `@container` 키이며, `null`은 해당 조건에서 변수를 설정하지 않은 상태로 둡니다. 정적이지 않은 값은 그 값을 알려 주는 빌드 오류입니다. 변수는 스타일이 적용되는 요소가 아니라 `:root`나 테마 클래스에 설정되므로, 의사 클래스 키는 정적이지 않은 것으로 간주됩니다. + +`types.*()` 래퍼는 `default`를 초기값으로 하여 변수를 `@property`로 등록하므로, 해당 타입으로 애니메이션되고 보간됩니다. `default`가 없는 타입 지정 변수, 소수를 받은 `types.integer()`, 알 수 없는 `types.*` 헬퍼는 빌드 오류입니다. `'--global'`처럼 이미 커스텀 속성 이름인 키는 그 이름을 유지하며, `colors['--global']`로 읽을 수 있습니다. + +StyleX가 요구하는 대로, 변수는 보통 `.stylex.ts` 파일에 두고 사용하는 곳에서 import합니다. import는 번들러가 해석하는 방식대로 해석되며, import하는 파일은 정의하는 파일이 생성하는 것과 같은 커스텀 속성, 테마 클래스, 상수를 읽습니다: + +```tsx +// tokens.stylex.ts +export const colors = stylex.defineVars({ primary: 'blue' }) +export const spacing = stylex.defineConsts({ gap: '8px' }) +``` + +```tsx +// Button.tsx +import { colors, spacing } from './tokens.stylex' + +const dark = stylex.createTheme(colors, { primary: 'navy' }) +const styles = stylex.create({ + box: { color: colors.primary, marginTop: spacing.gap }, +}) +``` + +`create()` 안의 값 중 이 파일 자체의 함수가 상수와 결과가 정확한 내장 기능으로 계산하는 값(`double(SIZE)` 등)은 빌드 시점에 계산됩니다. 다른 모듈의 코드는 실행되지 않으며, 결과가 확실하지 않은 코드(`Date`, `Math.random`, `Math.sin`, 로케일 메서드, `new`, `this`...)도 실행되지 않습니다. prop이나 state처럼 런타임에만 알 수 있는 값은 그 값을 알려 주는 빌드 오류이며, `create()`, `defineVars()`, `defineConsts()`, `createTheme()`, `keyframes()`, `positionTry()`, `viewTransitionClass()`가 읽을 수 없는 것(spread, 상수가 아닌 computed key, 객체가 아닌 인자)도 마찬가지입니다. computed 조건 키는 `defineConsts()` 쿼리를 가리키는 `[constants.wide]`처럼 상수를 읽을 수 있습니다. 런타임 값은 동적 스타일(`(color) => ({ color })`)로 전달하세요. 동적 스타일은 대신 CSS 변수가 됩니다. 동적 스타일은 `(size) => ({ width: { default: 100, ':hover': size } })`처럼 조건별로 매개변수를 설정할 수도 있으며, 각 조건은 자체 변수를 사용합니다. + +`stylex.props()`는 부모가 전달하는 `style` prop, spread, 다른 모듈의 네임스페이스처럼 다른 곳에서 컴파일된 스타일을 받아 런타임에 클래스 이름을 합칩니다. 이 파일의 네임스페이스는 빌드 시점에 해석됩니다. + +## at-rule + +```tsx +const fallback = stylex.positionTry({ top: '0', insetBlockEnd: 'auto' }) +const transition = stylex.viewTransitionClass({ + old: { animationDuration: '300ms' }, + new: { animationDuration: '150ms' }, +}) +const styles = stylex.create({ + popover: { positionTryFallbacks: fallback, anchorName: '--trigger' }, + card: { viewTransitionClass: transition }, +}) +``` + +```css +@position-try --a { + top: 0; + inset-block-end: auto; +} +::view-transition-old(*.b) { + animation-duration: 300ms; +} +::view-transition-new(*.b) { + animation-duration: 150ms; +} +``` + +이 바인딩은 `create()` 안에서 자신의 이름으로 읽히며, anchor, timeline, `@position-try` 규칙의 이름을 지정하는 속성의 dashed ident(`anchorName: '--trigger'`)는 `var(--trigger)`가 되지 않고 이름으로 유지됩니다. `viewTransitionClass()`는 `group`, `imagePair`, `old`, `new` 그룹을 받으며, 그 밖의 키는 빌드 오류입니다. + +## 값 헬퍼 + +`firstThatWorks()`는 폴백을 CSS 순서대로 출력하고, `types.*()`는 `create()` 안에서 내부 값으로 풀립니다(`defineVars()`에서는 `@property`도 등록합니다). 값은 일반 리터럴, 조건 객체(`{ default, ':hover', '@media ...' }`), 또는 호출 위치에서 바인딩되는 CSS 변수가 되는 화살표 함수일 수 있습니다. + +`include()`는 현재 StyleX API에 포함되지 않습니다. StyleX는 이를 deprecated 처리했고 현재 `@stylexjs/stylex` 릴리스는 더 이상 이를 export하지 않으며, 대신 여러 네임스페이스를 `props()`에 전달해 합성합니다. `@devup-ui/react/compat/stylex` 선언만 여전히 이 타입을 제공합니다. Devup UI는 `create()` 안의 레거시 `...stylex.include(base.root)` spread를 Devup UI 확장 기능으로 계속 컴파일하므로, 이전 StyleX용으로 작성한 코드도 계속 빌드됩니다. 인자는 같은 파일에서 앞서 `create()` 호출이 정의한 네임스페이스여야 하며, 그 밖의 값은 빌드 오류입니다. spread는 작성된 위치에서 포함된 네임스페이스의 키를 병합합니다. `include()` 뒤에 작성한 키는 포함된 키를 덮어쓰므로 `{ ...stylex.include(base.root), color: 'blue' }`는 `color`에 대해 blue 클래스만 유지하며, 나중 `include()`도 마찬가지로 앞선 키를 덮어씁니다. 이는 네임스페이스를 `props()`에 전달하는 경우를 포함해 빌드 시점에 해석됩니다. 동적(화살표 함수) 네임스페이스는 병합할 키가 없으므로, 그 클래스는 네임스페이스 자체의 클래스 앞에 추가되기만 합니다. 두 네임스페이스를 모두 `props()`에 전달하면(`stylex.props(base.root, styles.fancy)`) StyleX와 Devup UI에서 같은 방식으로 합성됩니다. + +## 관계 조건과 marker + +`when.ancestor()`, `when.descendant()`, `when.anySibling()`, `when.siblingBefore()`, `when.siblingAfter()`는 주변의 marker가 지정된 요소의 상태에 따라 요소의 스타일을 지정합니다. 이들은 빌드 시점에 StyleX가 작성하는 것과 같은 `:where(...)` 조건 키로 컴파일되므로, StyleX 코드는 실행되지 않습니다: + +```tsx +// markers.stylex.ts +export const cardMarker = stylex.defineMarker() +``` + +```tsx +import { cardMarker } from './markers.stylex' + +const styles = stylex.create({ + title: { + color: { + default: 'black', + [stylex.when.ancestor(':hover')]: 'blue', + [stylex.when.siblingBefore(':focus', cardMarker)]: 'red', + }, + }, +}) + +const el = ( +
+

+

+) +``` + +```css +.a { + color: black; +} +.b.b:where(.x-default-marker:hover *) { + color: blue; +} +.c.c:where(.d:focus ~ *) { + color: red; +} +``` + +| 조건 | 선택자 | +| -------------------------- | -------------------------------- | +| `when.ancestor(p, m)` | `:where(.m p *)` | +| `when.descendant(p, m)` | `:where(:has(.m p))` | +| `when.anySibling(p, m)` | `:where(.m p ~ *, :has(~ .m p))` | +| `when.siblingBefore(p, m)` | `:where(.m p ~ *)` | +| `when.siblingAfter(p, m)` | `:where(:has(~ .m p))` | + +`p`는 문자열로 작성한 의사 클래스나 속성 선택자(`':hover'`, `'[data-open]'`)입니다. 의사 요소나 `:` 또는 `[`로 시작하지 않는 값은 StyleX의 메시지를 담은 빌드 오류입니다. marker `m`의 기본값은 `x-default-marker` 클래스인 `stylex.defaultMarker()`입니다. `stylex.defineMarker()`는 파일과 export 이름을 따라 자체 marker 이름을 지으므로, 이를 import하는 모듈도 같은 클래스를 읽습니다. StyleX와 마찬가지로 named export에 바인딩해야 하며, 그 밖의 경우는 빌드 오류입니다. 또한 StyleX는 `.stylex` 파일에서만 marker 이름을 짓지만, Devup UI는 어떤 파일에서든 이름을 짓습니다. 요소에 marker를 지정하려면 marker를 `props()`나 `attrs()`에 전달하세요. + +클래스는 StyleX처럼 두 번 작성되므로 조건은 의사 클래스의 명시도를 유지하며, 조건은 StyleX의 순서(`ancestor`, `descendant`, `anySibling`, `siblingBefore`, `siblingAfter`)대로 의사 클래스보다 앞에 정렬됩니다. at-rule 안에서 Devup UI는 StyleX처럼 at-rule마다 클래스를 한 번 더 반복하지 않습니다. 대신 모든 StyleX 조건에서와 마찬가지로 at-rule을 그것이 세분화하는 규칙 뒤에 작성합니다. + +## 지원하지 않는 API + +Devup UI는 `create`, `props`, `attrs`, `keyframes`, `defineVars`, `createTheme`, `createThemeContract`, `defineConsts`, `positionTry`, `viewTransitionClass`, `firstThatWorks`, `types`, `when`, `defineMarker`, `defaultMarker`와 위에서 설명한 레거시 `include`를 컴파일합니다. `@stylexjs/stylex`의 그 밖의 export(`env`, ...)는 런타임에 예외를 던지는 StyleX 호출로 남게 되므로, 이를 import하거나 패키지에서 읽으면 그 이름을 알려 주는 빌드 오류가 됩니다. diff --git a/apps/landing/src/app/(detail)/docs/migration/stylex/page.mdx b/apps/landing/src/app/(detail)/docs/migration/stylex/page.mdx index 699a158e5..8c74ac736 100644 --- a/apps/landing/src/app/(detail)/docs/migration/stylex/page.mdx +++ b/apps/landing/src/app/(detail)/docs/migration/stylex/page.mdx @@ -2,6 +2,11 @@ export const metadata = { title: 'Migration', alternates: { canonical: '/docs/migration/stylex', + languages: { + en: '/docs/migration/stylex', + ko: '/ko/docs/migration/stylex', + 'x-default': '/docs/migration/stylex', + }, }, } diff --git a/apps/landing/src/app/(detail)/docs/migration/tailwind/page.ko.mdx b/apps/landing/src/app/(detail)/docs/migration/tailwind/page.ko.mdx new file mode 100644 index 000000000..595b4cece --- /dev/null +++ b/apps/landing/src/app/(detail)/docs/migration/tailwind/page.ko.mdx @@ -0,0 +1,115 @@ +export const metadata = { + title: '마이그레이션', + alternates: { + canonical: '/ko/docs/migration/tailwind', + languages: { + en: '/docs/migration/tailwind', + ko: '/ko/docs/migration/tailwind', + 'x-default': '/docs/migration/tailwind', + }, + }, +} + +# Tailwind CSS + +Devup UI 컴포넌트(`Box`, `Flex`, `Text` ...)의 `className`에 작성한 Tailwind CSS 클래스는 스타일 props와 같은 방식으로 빌드 시점에 Devup UI 클래스로 컴파일됩니다. 브라우저에서는 아무것도 실행되지 않으며, 이 클래스들을 위한 Tailwind 빌드도 필요 없습니다. 클래스는 Tailwind CSS **v4**를 따릅니다. + +```tsx + +``` + +## 클래스가 컴파일되는 경우 + +클래스는 빌드가 그 **전체**를 이해할 때만 컴파일됩니다. 모든 variant(`md:`, `hover:`, `data-[state=open]:`, `[&>*]:` ...), 유틸리티, 그 값과 modifier(`/50`, `!`)를 모두 이해해야 합니다. 그러면 클래스는 Tailwind CSS v4가 작성하는 선언이 됩니다. + +그 밖의 모든 클래스는 **작성한 그대로 `className`에 남으므로**, 그 클래스를 정의하는 다른 무언가가 계속 동작합니다. 여기에는 다음이 포함됩니다: + +- 직접 만든 클래스(`card`)와 플러그인 클래스(`prose`), +- Tailwind CSS v4가 정의하지 않는 클래스(v3에 있던 `bg-gradient-to-r`), +- 빌드가 정확히 재현할 수 없는 클래스([작성한 그대로 남는 것](#작성한-그대로-남는-것) 참고), +- 프로젝트의 Tailwind CSS가 빌드가 읽을 수 없는 방식으로 테마 값을 정의한 클래스. + +클래스는 Tailwind CSS가 생성하는 것과 다른 무언가로 다시 작성되지 않습니다. v4의 선언으로 컴파일되거나, 그대로 남습니다. Tailwind 이름을 가진 클래스는 Tailwind의 의미로 컴파일되므로, 직접 만든 클래스에 Tailwind 유틸리티의 이름을 붙이지 마세요. + +## 클래스를 읽는 위치 + +클래스는 Devup UI 컴포넌트의 `className`에서 컴파일되며, 빌드는 알 수 있는 것만 읽습니다: + +- 문자열 리터럴, 템플릿 리터럴, `cond ? 'a' : 'b'`, `a && 'b'`, `a || 'b'`, 괄호, +- 같은 파일에서 문자열에 바인딩된 `const`(`const base = 'p-4 card'`는 `className`이 읽는 곳 어디서든 담고 있는 클래스로 읽힙니다. `let`, 매개변수, `${}`가 있는 템플릿은 읽히지 않습니다), +- `clsx(...)`, `classnames(...)`, `classNames(...)`의 인자(문자열, 배열, 객체의 키)와 `['a', cond && 'b'].join(' ')`. 각 클래스는 작성된 위치에서 컴파일됩니다, +- **모든** 인자가 문자열, `${}`가 없는 템플릿, 또는 이들의 배열인 `cn(...)`과 `twMerge(...)`: 빌드는 tailwind-merge처럼 이를 병합하므로, 나중 클래스가 다시 설정하는 Tailwind 클래스는 제거되고(`cn('p-4 m-2', 'p-2')`는 `m-2`와 `p-2`를 유지합니다. variant(`hover:p-2`), 브레이크포인트, `!`는 각각 별개로 취급되며, `px-4`와 `p-2`는 둘 다 남습니다) 남은 것을 컴파일합니다. `cn`은 `twMerge(clsx(...))`로 읽히므로, 직접 만든 `cn`이 다른 일을 한다면 다른 이름을 붙이세요. 조건이나 그 밖의 인자가 있는 `cn()`은 결과를 런타임에만 알 수 있고 그 안의 문자열이 작성한 그대로 `twMerge`에 전달되어야 하므로 그대로 둡니다, +- Devup UI를 import하는 파일 안의 `cva(base, { variants, compoundVariants })` 문자열: base, 모든 variant 옵션, 모든 compound variant의 `class`/`className`은 작성된 위치에서 컴파일됩니다(`cva`는 이들을 합치기만 하므로 각 클래스는 클래스로 유지됩니다). Devup UI import가 없는 파일은 전혀 컴파일되지 않으므로, `cva` 호출은 Devup UI import가 있는 파일에 두세요. + +런타임에만 알 수 있는 클래스(prop, 계산된 문자열, import한 상수, 조건이 있는 `cn()`)는 컴파일할 수 없습니다. 어떤 경우든 `className`은 일반 텍스트로서 이전처럼 계속 동작합니다. + +일반 DOM 요소(`
`)나 Devup UI 컴포넌트가 아닌 컴포넌트는 **건드리지 않습니다**. 그 `className`은 작성한 그대로 전달되므로 Tailwind(자체 빌드)가 스타일을 적용할 수 있습니다. 클래스를 컴파일하려면 ``를 사용하세요. + +## 테마 값 + +Tailwind CSS v4 기본 팔레트의 색상(`oklch`로 정의된 `bg-red-500`)과 `devup.json`의 값을 함께 사용할 수 있습니다: + +- `devup.json` 색상은 토큰 이름을 가진 Tailwind 색상입니다. `bg-primary`, `text-text`, `border-primary/50`은 `var(--primary)`, `var(--text)` 등이 됩니다. 어떤 이름이 `devup.json` 색상이면서 팔레트 색상이기도 하면 `devup.json` 색상이 사용됩니다. +- `devup.json` 그림자 토큰은 `shadow-`(`shadow-card`)으로 동작합니다. +- 브레이크포인트는 Tailwind가 아니라 Devup UI의 것(`devup.json`의 `theme.breakpoints`)입니다. `sm:`, `md:`, `lg:`, `xl:`, `2xl:`는 base 다음의 첫 다섯 브레이크포인트입니다. 변경은 `devup.json`에서 하세요. +- `dark:`는 Devup UI 테마를 따릅니다(`data-theme`로 테마를 설정하기 전까지는 `prefers-color-scheme`). + +## Tailwind CSS 정의 + +`tailwindcss`를 import하는 프로젝트의 CSS 파일은 Tailwind 자체에서처럼 추가 정의를 할 수 있습니다: + +```css +@import 'tailwindcss'; + +@theme { + --color-brand: oklch(60% 0.2 250); + --spacing-gutter: 3rem; + --breakpoint-3xl: 120rem; + --animate-wiggle: wiggle 1s ease-in-out infinite; + @keyframes wiggle { + 50% { + transform: rotate(3deg); + } + } +} + +@utility content-auto { + content-visibility: auto; +} + +@custom-variant theme-midnight (&:where([data-theme='midnight'] *)); +``` + +모든 플러그인은 빌드가 시작될 때 이 파일을 읽고, 이 파일이나 이 파일이 상대 경로로 import하는 CSS 파일이 바뀌면 다시 읽습니다. Vite, webpack, Next.js, Rsbuild는 모든 모듈을 다시 컴파일하고, Bun 플러그인(자체 리빌드가 없는 런타임 플러그인)은 정의를 다시 읽으므로 모듈은 Bun이 다음에 로드할 때 새 정의로 컴파일됩니다. 따라서 `bg-brand`, `p-gutter`, `3xl:flex`, `animate-wiggle`, `content-auto`, `theme-midnight:bg-black`이 컴파일됩니다. + +파일은 다음 순서로 찾습니다: `devup.json`의 `tailwind.css` 옵션, 그렇지 않으면 `src/app/globals.css`, `app/globals.css`, `src/globals.css`, `src/index.css`, `src/styles/globals.css`, `src/styles.css`, `src/style.css`, `src/app.css`, `styles/globals.css`, `app/app.css` 중 `tailwindcss`를 import하는 첫 번째 파일입니다. + +```json +{ + "tailwind": { "css": "src/styles/tailwind.css" } +} +``` + +아무 파일도 읽지 않으려면 `"css": false`를 사용하세요. + +읽는 것: + +- color, spacing(`--spacing`, `--spacing-*`), shadow, inset-shadow, text-shadow, drop-shadow, blur, radius, ease, animate, perspective, container(`@sm:`), `default-transition-*`, breakpoint 네임스페이스의 `@theme` 변수(그리고 `@theme` 안의 `@keyframes`), 그리고 `--color-*: initial`과 `--*: initial` 같은 초기화. +- 선언과 `@apply` 줄이 있는 `@utility name { ... }`. `@apply`는 지정한 유틸리티(`@apply px-4 py-2!`)를 풀어서 작성하며, 유틸리티를 적용하는 다른 `@utility`를 거쳐서도 마찬가지입니다. variant가 있는 유틸리티(`hover:p-4`), 자식에 스타일을 적용하는 유틸리티(`space-x-4`), 알 수 없는 유틸리티, 또는 순환이 있으면 `@utility` 전체를 작성한 그대로 둡니다. +- 선언이 `--value(...)`와 `--modifier(...)`를 읽는 함수형 `@utility name-* { ... }`. 인자는 `integer`, `number`, `percentage`, 리터럴(`'inherit'`), 테마 네임스페이스(`--tab-size-*`, `--color-*`, `--spacing-*`), 또는 임의 값 타입(`[length]`, `[color]`, `[number]`, `[url]`)이며, 값이 맞는 첫 번째 인자가 사용됩니다. 주어지지 않은 `--modifier()`를 읽는 선언은 제거되고, 어떤 인자에도 맞지 않는 `--value()`는 클래스를 작성한 그대로 남깁니다. `--spacing()`, `--alpha()` 등 유틸리티의 다른 함수는 실행되지 않으므로, 이를 사용하는 유틸리티는 작성한 그대로 남습니다. +- 선택자 목록, 또는 선택자, `@media`, `@supports` 안에 `@slot;`을 담은 블록으로 작성한 `@custom-variant`. 내장 variant의 이름(`dark`)을 가진 `@custom-variant`는 그 variant를 대체합니다. +- 임의 값 안의 `theme(--name)`(`p-[theme(--spacing-gutter)]`, `bg-[theme(--color-brand)]`, `w-[calc(theme(--spacing)*2)]`): 프로젝트의 테마 변수, 색상, 또는 spacing 단계. 빌드가 읽을 수 없는 변수에 대한 호출(v3 형태인 `theme(colors.red.500)` 포함)은 클래스를 작성한 그대로 남깁니다. + +읽지 않는 것은 그 클래스를 작성한 그대로 남깁니다: `@plugin`과 `@config`(이들은 JavaScript를 실행하며 빌드는 그 출력을 알 수 없습니다. `@tailwindcss/typography` 같은 플러그인이 만드는 `prose` 같은 클래스는 Tailwind 자체 빌드를 위해 `className`에 남습니다), `@utility` 안의 중첩 규칙, CSS 안의 `theme()`(임의 값 바깥), `--theme()`, 중괄호의 짝이 맞지 않는 파일. 프로젝트가 빌드가 읽지 않는 네임스페이스(`--text-*`, `--font-*`, `--leading-*`, `--tracking-*`, `--container-*`, `--perspective-*`, `--aspect-*`)의 값을 바꾸면, 그 값을 읽는 클래스(`text-lg`, `font-bold`, `max-w-sm` ...)도 프로젝트가 대체한 기본값으로 컴파일되는 대신 작성한 그대로 남습니다. + +## 한 요소의 클래스와 스타일 props + +Tailwind 클래스와 Devup UI props는 모두 같은 스타일시트에서 속성마다 하나의 원자적 클래스가 되므로, 두 props와 같은 규칙을 따릅니다: + +- 요소의 Tailwind 클래스가 먼저 컴파일되고, Devup props는 그 뒤에 컴파일됩니다. **같은 속성**(`p-4`와 `p={12}`)에 대해서는 JSX에서 어느 쪽이 먼저 오든 prop이 스타일시트에서 뒤에 오므로 prop이 적용됩니다. +- 속성은 축약 속성이 개별 속성보다 앞에 오도록 정렬됩니다. `bg="green"`은 `background`이고 `bg-red-500`은 그 뒤에 오는 `background-color`이므로, 이 경우에는 Tailwind 클래스가 적용됩니다. 두 쪽이 모두 같은 속성을 설정하게 될 때는 한쪽만 사용하세요. +- 반응형 스타일과 `hover:` 스타일은 props에서처럼 같은 속성의 기본 스타일 뒤에 옵니다. + +## 작성한 그대로 남는 것 + +이 빌드가 컴파일하지 않는 유틸리티는 `className`에 남습니다: `container`(브레이크포인트마다 너비를 설정하므로 하나의 클래스로는 담을 수 없습니다), 그라디언트 마스크(`mask-linear-*`, `mask-radial-*`, `mask-conic-*`, `mask-t|r|b|l|x|y-from|to-*`), 그리고 Tailwind CSS v4에 정의되지 않은 variant와 값. 컨테이너 쿼리(`@sm:`, `@max-md:`, `@min-[400px]:`, `@sm/main:`)와 `@container` 유틸리티, 그 밖의 마스크(`mask-none`, `mask-[...]`, 크기, 위치, 반복, clip, origin, composite, mode), `text-shadow-*`, `inset-shadow-*`, `font-variant-numeric`(`tabular-nums` 등, 조합 가능), 3D 변환(`rotate-x|y|z-*`, `translate-z-*`, `scale-z-*`, `translate-3d`, `scale-3d`, `transform-3d`, `backface-*`, `perspective-*`), `contain-*`, `outline-hidden`은 Tailwind CSS v4가 작성하는 그대로 컴파일됩니다. diff --git a/apps/landing/src/app/(detail)/docs/migration/tailwind/page.mdx b/apps/landing/src/app/(detail)/docs/migration/tailwind/page.mdx index aca2ed1bf..066e0d9e1 100644 --- a/apps/landing/src/app/(detail)/docs/migration/tailwind/page.mdx +++ b/apps/landing/src/app/(detail)/docs/migration/tailwind/page.mdx @@ -2,6 +2,11 @@ export const metadata = { title: 'Migration', alternates: { canonical: '/docs/migration/tailwind', + languages: { + en: '/docs/migration/tailwind', + ko: '/ko/docs/migration/tailwind', + 'x-default': '/docs/migration/tailwind', + }, }, } diff --git a/apps/landing/src/i18n/pages.ts b/apps/landing/src/i18n/pages.ts index 1cf850c83..ab88e5508 100644 --- a/apps/landing/src/i18n/pages.ts +++ b/apps/landing/src/i18n/pages.ts @@ -11,19 +11,65 @@ interface TranslatedPage { // Keep translated content beside its English source; share the original layout. export const translatedPages: Record = { + '/docs/devup/breakpoints': { + load: () => import('@/app/(detail)/docs/devup/breakpoints/page.ko.mdx'), + Layout: DocsLayout, + }, + '/docs/devup/colors': { + load: () => import('@/app/(detail)/docs/devup/colors/page.ko.mdx'), + Layout: DocsLayout, + }, + '/docs/devup/devup-json': { + load: () => import('@/app/(detail)/docs/devup/devup-json/page.ko.mdx'), + Layout: DocsLayout, + }, '/docs/devup/figma-plugin': { load: () => import('@/app/(detail)/docs/devup/figma-plugin/page.ko.mdx'), Layout: DocsLayout, }, + '/docs/devup/length': { + load: () => import('@/app/(detail)/docs/devup/length/page.ko.mdx'), + Layout: DocsLayout, + }, + '/docs/devup/shadow': { + load: () => import('@/app/(detail)/docs/devup/shadow/page.ko.mdx'), + Layout: DocsLayout, + }, + '/docs/devup/typography': { + load: () => import('@/app/(detail)/docs/devup/typography/page.ko.mdx'), + Layout: DocsLayout, + }, + '/docs/figma-and-theme-integration/devup-figma-plugin': { + load: () => + import('@/app/(detail)/docs/figma-and-theme-integration/devup-figma-plugin/page.ko.mdx'), + Layout: DocsLayout, + }, + '/docs/figma-and-theme-integration/devup-json': { + load: () => + import('@/app/(detail)/docs/figma-and-theme-integration/devup-json/page.ko.mdx'), + Layout: DocsLayout, + }, '/docs/installation': { load: () => import('@/app/(detail)/docs/installation/page.ko.mdx'), Layout: DocsLayout, }, + '/docs/migration/overview': { + load: () => import('@/app/(detail)/docs/migration/overview/page.ko.mdx'), + Layout: DocsLayout, + }, '/docs/migration/styled-components': { load: () => import('@/app/(detail)/docs/migration/styled-components/page.ko.mdx'), Layout: DocsLayout, }, + '/docs/migration/stylex': { + load: () => import('@/app/(detail)/docs/migration/stylex/page.ko.mdx'), + Layout: DocsLayout, + }, + '/docs/migration/tailwind': { + load: () => import('@/app/(detail)/docs/migration/tailwind/page.ko.mdx'), + Layout: DocsLayout, + }, '/docs/migration/vanilla-extract': { load: () => import('@/app/(detail)/docs/migration/vanilla-extract/page.ko.mdx'), diff --git a/packages/__tests__/docs-conformance.test.ts b/packages/__tests__/docs-conformance.test.ts index fd09ce2aa..67edcc99b 100644 --- a/packages/__tests__/docs-conformance.test.ts +++ b/packages/__tests__/docs-conformance.test.ts @@ -37,9 +37,13 @@ const CHECKED_PAGES = [ 'api/input/page.mdx', 'api/text/page.mdx', 'api/v-stack/page.mdx', + 'devup/breakpoints/page.ko.mdx', 'devup/breakpoints/page.mdx', + 'devup/colors/page.ko.mdx', 'devup/colors/page.mdx', + 'devup/length/page.ko.mdx', 'devup/length/page.mdx', + 'devup/shadow/page.ko.mdx', 'devup/shadow/page.mdx', ]