-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 디자인 토큰 자동화 파일 구성 #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| name: Build Design Tokens | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - develop | ||
| paths: | ||
| - 'packages/design-tokens/tokens/**' | ||
|
|
||
| concurrency: | ||
| group: build-design-tokens | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.YML_GITHUB_TOKEN }} | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 9 | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: 'pnpm' | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Build design tokens | ||
| run: pnpm --filter @infra-support/design-tokens build | ||
|
|
||
| - name: Commit generated dist | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add packages/design-tokens/dist/ | ||
| git diff --cached --quiet && echo "No changes to commit" || \ | ||
| (git commit -m "chore(design-tokens): auto-build from Figma tokens" && git push) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ yarn.lock | |
|
|
||
| # Build outputs | ||
| dist/ | ||
| !packages/design-tokens/dist/ | ||
| build/ | ||
| .next/ | ||
| .turbo/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /** | ||
| * Do not edit directly, this file was auto-generated. | ||
| */ | ||
|
|
||
| :root { | ||
| --color-primary: #3B82F6; | ||
| --color-primary-hover: #2563EB; | ||
| --color-secondary: #8B5CF6; | ||
| --color-surface: #F8FAFC; | ||
| --color-surface-elevated: #FFFFFF; | ||
| --color-text-default: #111827; | ||
| --color-text-muted: #6B7280; | ||
| --color-text-inverse: #FFFFFF; | ||
| --color-border: #E5E7EB; | ||
| --color-success: #10B981; | ||
| --color-warning: #F59E0B; | ||
| --color-error: #EF4444; | ||
| --font-size-xl: 2rem; | ||
| --font-size-lg: 1.5rem; | ||
| --font-size-md: 1rem; | ||
| --font-size-sm: 0.875rem; | ||
| --font-size-xs: 0.75rem; | ||
| --font-weight-regular: 400; | ||
| --font-weight-medium: 500; | ||
| --font-weight-bold: 700; | ||
| --font-family-base: Pretendard, sans-serif; | ||
| --line-height-tight: 1.25; | ||
| --line-height-normal: 1.6; | ||
| --line-height-relaxed: 1.75; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /** | ||
| * Do not edit directly, this file was auto-generated. | ||
| */ | ||
|
|
||
| export const colorPrimary: string; | ||
| export const colorPrimaryHover: string; | ||
| export const colorSecondary: string; | ||
| export const colorSurface: string; | ||
| export const colorSurfaceElevated: string; | ||
| export const colorTextDefault: string; | ||
| export const colorTextMuted: string; | ||
| export const colorTextInverse: string; | ||
| export const colorBorder: string; | ||
| export const colorSuccess: string; | ||
| export const colorWarning: string; | ||
| export const colorError: string; | ||
| export const fontSizeXl: string; | ||
| export const fontSizeLg: string; | ||
| export const fontSizeMd: string; | ||
| export const fontSizeSm: string; | ||
| export const fontSizeXs: string; | ||
| export const fontWeightRegular: string; | ||
| export const fontWeightMedium: string; | ||
| export const fontWeightBold: string; | ||
| export const fontFamilyBase: string; | ||
| export const lineHeightTight: string; | ||
| export const lineHeightNormal: string; | ||
| export const lineHeightRelaxed: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /** | ||
| * Do not edit directly, this file was auto-generated. | ||
| */ | ||
|
|
||
| export const colorPrimary = "#3b82f6"; | ||
| export const colorPrimaryHover = "#2563eb"; | ||
| export const colorSecondary = "#8b5cf6"; | ||
| export const colorSurface = "#f8fafc"; | ||
| export const colorSurfaceElevated = "#ffffff"; | ||
| export const colorTextDefault = "#111827"; | ||
| export const colorTextMuted = "#6b7280"; | ||
| export const colorTextInverse = "#ffffff"; | ||
| export const colorBorder = "#e5e7eb"; | ||
| export const colorSuccess = "#10b981"; | ||
| export const colorWarning = "#f59e0b"; | ||
| export const colorError = "#ef4444"; | ||
| export const fontSizeXl = "2rem"; | ||
| export const fontSizeLg = "1.5rem"; | ||
| export const fontSizeMd = "1rem"; | ||
| export const fontSizeSm = "0.875rem"; | ||
| export const fontSizeXs = "0.75rem"; | ||
| export const fontWeightRegular = "400"; | ||
| export const fontWeightMedium = "500"; | ||
| export const fontWeightBold = "700"; | ||
| export const fontFamilyBase = "Pretendard, sans-serif"; | ||
| export const lineHeightTight = "1.25"; | ||
| export const lineHeightNormal = "1.6"; | ||
| export const lineHeightRelaxed = "1.75"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /** Auto-generated by Style Dictionary — do not edit */ | ||
| module.exports = { | ||
| "theme": { | ||
| "extend": { | ||
| "colors": { | ||
| "primary": "#3b82f6", | ||
| "primary-hover": "#2563eb", | ||
| "secondary": "#8b5cf6", | ||
| "surface": "#f8fafc", | ||
| "surface-elevated": "#ffffff", | ||
| "text-default": "#111827", | ||
| "text-muted": "#6b7280", | ||
| "text-inverse": "#ffffff", | ||
| "border": "#e5e7eb", | ||
| "success": "#10b981", | ||
| "warning": "#f59e0b", | ||
| "error": "#ef4444" | ||
| }, | ||
| "fontSize": { | ||
| "xl": "2rem", | ||
| "lg": "1.5rem", | ||
| "md": "1rem", | ||
| "sm": "0.875rem", | ||
| "xs": "0.75rem" | ||
| }, | ||
| "fontWeight": { | ||
| "regular": "400", | ||
| "medium": "500", | ||
| "bold": "700" | ||
| }, | ||
| "fontFamily": { | ||
| "base": "Pretendard, sans-serif" | ||
| }, | ||
| "lineHeight": { | ||
| "tight": "1.25", | ||
| "normal": "1.6", | ||
| "relaxed": "1.75" | ||
| } | ||
| } | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||||||||||||||
| { | ||||||||||||||||||
| "name": "@infra-support/design-tokens", | ||||||||||||||||||
| "version": "1.0.0", | ||||||||||||||||||
| "type": "module", | ||||||||||||||||||
| "exports": { | ||||||||||||||||||
| ".": "./dist/js/tokens.js", | ||||||||||||||||||
| "./tailwind": "./dist/tailwind/preset.cjs", | ||||||||||||||||||
| "./css": "./dist/css/variables.css" | ||||||||||||||||||
| }, | ||||||||||||||||||
| "scripts": { | ||||||||||||||||||
| "build": "node sd.config.mjs", | ||||||||||||||||||
| "clean": "rm -rf dist" | ||||||||||||||||||
| }, | ||||||||||||||||||
| "dependencies": { | ||||||||||||||||||
| "@tokens-studio/sd-transforms": "^1.2.0", | ||||||||||||||||||
| "style-dictionary": "^4.0.0" | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+14
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
References
|
||||||||||||||||||
| } | ||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| import StyleDictionary from 'style-dictionary'; | ||
| import { register } from '@tokens-studio/sd-transforms'; | ||
|
|
||
| register(StyleDictionary); | ||
|
|
||
| // CSS vars는 kebab-case 관례 사용 (tokens-studio 기본은 camelCase) | ||
| StyleDictionary.registerTransformGroup({ | ||
| name: 'tokens-studio/css', | ||
| transforms: [ | ||
| 'ts/descriptionToComment', | ||
| 'ts/size/px', | ||
| 'ts/opacity', | ||
| 'ts/size/lineheight', | ||
| 'ts/typography/fontWeight', | ||
| 'ts/resolveMath', | ||
| 'ts/size/css/letterspacing', | ||
| 'ts/color/css/hexrgba', | ||
| 'ts/color/modifiers', | ||
| 'name/kebab', | ||
| ], | ||
| }); | ||
|
|
||
| function setDeep(obj, path, value) { | ||
| let cur = obj; | ||
| for (let i = 0; i < path.length - 1; i++) { | ||
| if (!cur[path[i]]) cur[path[i]] = {}; | ||
| cur = cur[path[i]]; | ||
| } | ||
| cur[path[path.length - 1]] = value; | ||
| } | ||
|
|
||
| StyleDictionary.registerFormat({ | ||
| name: 'javascript/tailwind-preset', | ||
| format({ dictionary }) { | ||
| const colors = {}; | ||
| const fontSize = {}; | ||
| const fontWeight = {}; | ||
| const fontFamily = {}; | ||
| const lineHeight = {}; | ||
|
|
||
| for (const token of dictionary.allTokens) { | ||
| const [category, ...rest] = token.path; | ||
| const key = rest.join('-'); | ||
|
|
||
| if (category === 'color') setDeep(colors, rest, token.value); | ||
| else if (category === 'font-size') fontSize[key] = token.value; | ||
| else if (category === 'font-weight') fontWeight[key] = token.value; | ||
| else if (category === 'font-family') fontFamily[key] = token.value; | ||
| else if (category === 'line-height') lineHeight[key] = token.value; | ||
| } | ||
|
|
||
| const preset = { | ||
| theme: { | ||
| extend: { colors, fontSize, fontWeight, fontFamily, lineHeight }, | ||
| }, | ||
| }; | ||
|
|
||
| return ( | ||
| '/** Auto-generated by Style Dictionary — do not edit */\n' + | ||
| `module.exports = ${JSON.stringify(preset, null, 2)};\n` | ||
| ); | ||
| }, | ||
| }); | ||
|
|
||
| const sd = new StyleDictionary({ | ||
| source: ['tokens/**/*.json', '!tokens/$metadata.json'], | ||
| preprocessors: ['tokens-studio'], | ||
| platforms: { | ||
| css: { | ||
| transformGroup: 'tokens-studio/css', | ||
| buildPath: 'dist/css/', | ||
| files: [ | ||
| { | ||
| destination: 'variables.css', | ||
| format: 'css/variables', | ||
| options: { selector: ':root', outputReferences: false }, | ||
| }, | ||
| ], | ||
| }, | ||
| tailwind: { | ||
| transformGroup: 'tokens-studio', | ||
| buildPath: 'dist/tailwind/', | ||
| files: [ | ||
| { | ||
| destination: 'preset.cjs', | ||
| format: 'javascript/tailwind-preset', | ||
| }, | ||
| ], | ||
| }, | ||
| js: { | ||
| transformGroup: 'tokens-studio', | ||
| buildPath: 'dist/js/', | ||
| files: [ | ||
| { | ||
| destination: 'tokens.js', | ||
| format: 'javascript/es6', | ||
| }, | ||
| { | ||
| destination: 'tokens.d.ts', | ||
| format: 'typescript/es6-declarations', | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| await sd.buildAllPlatforms(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "tokenSetOrder": ["colors", "typography"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "color": { | ||
| "primary": { "value": "#3B82F6", "type": "color" }, | ||
| "primary-hover": { "value": "#2563EB", "type": "color" }, | ||
| "secondary": { "value": "#8B5CF6", "type": "color" }, | ||
| "surface": { "value": "#F8FAFC", "type": "color" }, | ||
| "surface-elevated": { "value": "#FFFFFF", "type": "color" }, | ||
| "text-default": { "value": "#111827", "type": "color" }, | ||
| "text-muted": { "value": "#6B7280", "type": "color" }, | ||
| "text-inverse": { "value": "#FFFFFF", "type": "color" }, | ||
| "border": { "value": "#E5E7EB", "type": "color" }, | ||
| "success": { "value": "#10B981", "type": "color" }, | ||
| "warning": { "value": "#F59E0B", "type": "color" }, | ||
| "error": { "value": "#EF4444", "type": "color" } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "font-size": { | ||
| "xl": { "value": "2rem", "type": "fontSizes" }, | ||
| "lg": { "value": "1.5rem", "type": "fontSizes" }, | ||
| "md": { "value": "1rem", "type": "fontSizes" }, | ||
| "sm": { "value": "0.875rem", "type": "fontSizes" }, | ||
| "xs": { "value": "0.75rem", "type": "fontSizes" } | ||
| }, | ||
| "font-weight": { | ||
| "regular": { "value": "400", "type": "fontWeights" }, | ||
| "medium": { "value": "500", "type": "fontWeights" }, | ||
| "bold": { "value": "700", "type": "fontWeights" } | ||
| }, | ||
| "font-family": { | ||
| "base": { "value": "Pretendard, sans-serif", "type": "fontFamilies" } | ||
| }, | ||
| "line-height": { | ||
| "tight": { "value": "1.25", "type": "lineHeights" }, | ||
| "normal": { "value": "1.6", "type": "lineHeights" }, | ||
| "relaxed": { "value": "1.75", "type": "lineHeights" } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
빌드 결과물인
dist/디렉토리를 Git 저장소에 직접 포함시키는 것은 권장되지 않습니다. 현재turbo.json설정에서dist/**를 빌드 출력물(outputs)로 관리하고 있으므로, Turbo의 캐시 기능을 통해 환경 간에 빌드 결과물을 공유할 수 있습니다.dist/폴더를 Git 추적에서 제외하여 저장소의 크기를 줄이고 불필요한 머지 충돌을 방지하는 것이 좋습니다.