Skip to content

fix: token 스크립트 수정#10

Closed
dasosann wants to merge 1 commit intomainfrom
feat/background-blur
Closed

fix: token 스크립트 수정#10
dasosann wants to merge 1 commit intomainfrom
feat/background-blur

Conversation

@dasosann
Copy link
Copy Markdown
Contributor

@dasosann dasosann commented Jan 26, 2026

요약

  • 디자인 토큰 자동 생성 스크립트 추가 및 CSS 변수화
  • token.json에서 색상, 타이포그래피, 반경 등을 자동으로 추출하여 tokens.css 생성
  • 테스트 페이지에서 생성된 토큰 및 유틸리티 클래스 시각화

구현 사항

Relevant files
Enhancement
generate-tokens.js
토큰 자동 생성 스크립트 구현                                                                                 

scripts/generate-tokens.js

  • token.json 파일을 읽어 디자인 토큰을 자동으로 파싱하는 Node.js 스크립트 생성
  • Grayscale, Colors(Pink/Flame/Orange), Transparent, System 토큰을 CSS 변수로
    변환
  • 폰트 사이즈와 가중치 조합으로 text-{size}-{weight} 형태의 유틸리티 클래스 자동 생성
  • 배경색, 버튼, 테두리, 텍스트 색상 등 의미론적 유틸리티 클래스 정의
+214/-0 
globals.css
토큰 CSS 파일 임포트 추가                                                                                 

app/globals.css

  • @import 'tailwindcss' 문법을 큰따옴표로 통일
  • 새로운 tokens.css 파일을 import하여 디자인 토큰 적용
+2/-1     
page.tsx
디자인 토큰 테스트 페이지 구현                                                                               

app/page.tsx

  • 기존 Next.js 템플릿 코드 제거 및 토큰 테스트 페이지로 전환
  • 타이포그래피(text-24-700, text-20-600 등), 색상(bg-brand-secondary-pink,
    bg-brand-primary-orange), 배경(bg-surface-base) 토큰 시각화
  • 3개 섹션(Typography, Colors & Backgrounds, Buttons)으로 구성된 테스트 컴포넌트 구현
  • 생성된 유틸리티 클래스의 실제 동작 확인 가능하도록 설계
+55/-57 
Configuration changes
tokens.css
자동 생성된 디자인 토큰 CSS 파일                                                                         

app/tokens.css

  • 자동 생성된 CSS 파일로 260줄의 CSS 변수 및 유틸리티 클래스 포함
  • @layer base에 색상, 반경, 테두리, 불투명도 CSS 변수 정의
  • @layer utilities에 타이포그래피(text-{size}-{weight}), 배경색, 버튼, 테두리, 텍스트 색상
    클래스 정의
  • 토큰 참조를 통한 의미론적 색상 변수 활용 (예: --color-surface-base,
    --color-brand-primary-orange)
+260/-0 
settings.json
CSS 린트 설정 업데이트                                                                                     

.vscode/settings.json

  • CSS 린트 설정에 "css.lint.unknownAtRules": "ignore" 추가
  • @layer, @import 등 CSS 커스텀 규칙에 대한 경고 제거
+2/-1     
Miscellaneous
token.json
레거시 토큰 파일 제거                                                                                         

app/src/token.json

  • 기존 token.json 파일 삭제 (app/token.json으로 위치 변경)
  • 1279줄의 레거시 토큰 정의 제거
+0/-1279

Need Review

  • ~ 부분 이렇게 구현했어요, 피드백 부탁해요!

Reference

📜 리뷰 규칙

Reviewer는 아래 P5 Rule을 참고하여 리뷰를 진행합니다.
P5 Rule을 통해 Reviewer는 Reviewee에게 리뷰의 의도를 보다 정확히 전달할 수 있습니다.

  • P1: 꼭 반영해주세요 (Comment)
  • P2: 적극적으로 고려해주세요 (Comment)
  • P3: 웬만하면 반영해 주세요 (Comment)
  • P4: 반영해도 좋고 넘어가도 좋습니다 (Approve)
  • P5: 그냥 사소한 의견입니다 (Approve)

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @dasosann, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 디자인 토큰 관리 시스템을 개선하여 개발 워크플로우를 효율화하는 데 중점을 둡니다. 기존에 JSON 형태로 관리되던 디자인 토큰을 자동화된 스크립트를 통해 CSS 변수 및 Tailwind CSS와 유사한 유틸리티 클래스로 변환함으로써, 개발자들이 컴포넌트에서 디자인 시스템을 보다 일관되고 편리하게 적용할 수 있도록 합니다. 이는 디자인과 개발 간의 격차를 줄이고, 유지보수성을 향상시키는 데 기여할 것입니다. page.tsx의 업데이트는 이러한 새로운 토큰 시스템의 실제 적용 방식을 명확하게 보여줍니다.

Highlights

  • 디자인 토큰 관리 방식 변경: 기존 token.json 파일을 직접 사용하는 대신, scripts/generate-tokens.js 스크립트를 통해 token.json의 내용을 CSS 변수 및 유틸리티 클래스로 변환한 tokens.css 파일을 생성하도록 변경되었습니다.
  • 자동화된 토큰 생성 스크립트 추가: 디자인 토큰을 CSS로 변환하는 scripts/generate-tokens.js 파일이 새로 추가되어, 토큰 업데이트 시 tokens.css를 자동으로 재생성할 수 있게 되었습니다.
  • 디자인 토큰 적용 예시 업데이트: app/page.tsx 파일이 새로운 디자인 토큰 기반의 타이포그래피, 색상, 배경, 버튼 유틸리티 클래스를 사용하여 UI를 구성하도록 전면 개편되었습니다.
  • CSS 린트 설정 추가: VS Code 설정에 CSS 린트 규칙을 추가하여 @layer와 같은 알 수 없는 At-Rule에 대한 경고를 무시하도록 설정했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이 PR은 디자인 토큰 시스템을 도입하여 UI 일관성을 높이는 중요한 단계입니다. token.json에서 CSS를 자동 생성하는 스크립트 방식은 매우 훌륭합니다. 다만, 몇 가지 개선점을 제안합니다. generate-tokens.js 스크립트는 타입스크립트로 전환하고 리팩토링하여 안정성을 높이는 것이 좋겠습니다. 또한, 생성된 버튼 클래스와 테스트 페이지에서의 사용법이 일치하지 않는 문제가 있으며, 새로운 토큰 시스템과 기존 스타일(shadcn/ui로 추정)이 혼재되어 있어 통합 계획이 필요해 보입니다. 아래에 자세한 리뷰를 남겼으니 확인 부탁드립니다.

Comment on lines +47 to +57
<div className="flex flex-wrap gap-4">
<button className="btn-primary text-16-600 px-8 py-3 transition-opacity hover:opacity-90">
Primary Button
</button>
<button className="btn-slate text-brand-black border-light text-16-600 rounded-2xl border px-8 py-3">
Secondary Button
</button>
<button className="btn-disabled text-16-400 cursor-not-allowed px-8 py-3">
Disabled Button
</button>
</div>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

버튼에 사용된 btn-* 클래스들이 tokens.css에 정의되어 있지 않아 스타일이 적용되지 않습니다. generate-tokens.js 스크립트는 .bg-button-* 형태의 배경색 유틸리티만 생성하고 있습니다.

우선 급한 대로 아래와 같이 직접 클래스를 수정하여 문제를 해결할 수 있습니다. 하지만 장기적으로는 스크립트에서 @apply를 사용하여 모든 스타일이 포함된 단일 클래스(예: .btn-primary)를 생성하는 방향으로 개선하는 것이 좋습니다.

수정 제안:

  1. btn-primary -> bg-button-primary text-white rounded-2xl
  2. btn-slate -> bg-button-slate
  3. btn-disabled -> bg-button-disabled text-disabled rounded-2xl
Suggested change
<div className="flex flex-wrap gap-4">
<button className="btn-primary text-16-600 px-8 py-3 transition-opacity hover:opacity-90">
Primary Button
</button>
<button className="btn-slate text-brand-black border-light text-16-600 rounded-2xl border px-8 py-3">
Secondary Button
</button>
<button className="btn-disabled text-16-400 cursor-not-allowed px-8 py-3">
Disabled Button
</button>
</div>
<div className="flex flex-wrap gap-4">
<button className="bg-button-primary text-white text-16-600 rounded-2xl px-8 py-3 transition-opacity hover:opacity-90">
Primary Button
</button>
<button className="bg-button-slate text-brand-black border-light text-16-600 rounded-2xl border px-8 py-3">
Secondary Button
</button>
<button className="bg-button-disabled text-disabled text-16-400 rounded-2xl cursor-not-allowed px-8 py-3">
Disabled Button
</button>
</div>
References
  1. Tailwind CSS 클래스가 길고 반복적으로 사용되고 있습니다. 스타일 가이드에서는 이런 경우 cva 등을 사용한 논리적 그룹핑을 권장합니다. 스크립트를 개선하여 .btn-primary와 같이 여러 스타일을 하나로 묶은 클래스를 생성하는 것이 좋습니다. (link)

<div className="bg-surface-base flex min-h-screen items-center justify-center font-sans">
<main className="flex min-h-screen w-full max-w-3xl flex-col items-center gap-8 px-8 py-12">
{/* 토큰 테스트 섹션 */}
<div className="w-full space-y-8 rounded-lg border border-gray-200 bg-white p-8 shadow-sm">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

하드코딩된 border-gray-200 클래스 대신 토큰 시스템의 border-light를 사용하는 것이 일관성 측면에서 더 좋습니다. tokens.css.border-light 유틸리티가 이미 정의되어 있습니다.

Suggested change
<div className="w-full space-y-8 rounded-lg border border-gray-200 bg-white p-8 shadow-sm">
<div className="w-full space-y-8 rounded-lg border border-light bg-white p-8 shadow-sm">

{/* 1. Typography */}
<section className="space-y-4">
<h2 className="text-20-600">1. Typography</h2>
<div className="space-y-2 rounded bg-gray-50 p-4">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

하드코딩된 bg-gray-50 클래스 대신 디자인 시스템에 정의된 시맨틱 토큰(예: bg-muted)을 사용하는 것을 권장합니다. 현재 tokens.css에는 bg-gray-50에 해당하는 유틸리티 클래스가 없어 Tailwind의 기본값을 사용하게 되는데, 이는 토큰 시스템의 일관성을 해칠 수 있습니다. 토큰 생성 스크립트에서 관련 유틸리티 클래스를 추가하는 것을 고려해보세요.

Comment on lines +98 to +140
// 토큰 참조 해석
function resolveValue(value, depth = 0) {
if (depth > 10 || typeof value !== "string") return value;

const match = value.match(/^\{(.+)\}$/);
if (!match) return value;

const ref = match[1];

// Grayscale 참조
if (ref.startsWith("Grayscale.")) {
const key = ref.replace("Grayscale.", "");
return `var(--${key})`;
}

// Colors 참조
if (ref.startsWith("Colors.Pink.")) {
const key = ref.replace("Colors.Pink.", "");
return `var(--${key})`;
}
if (ref.startsWith("Colors.Flame.")) {
const key = ref.replace("Colors.Flame.", "");
return `var(--${key})`;
}
if (ref.startsWith("Colors.Orange.")) {
const key = ref.replace("Colors.Orange.", "");
return `var(--${key})`;
}

// Transparent 참조
if (ref.startsWith("Transparent.")) {
const key = ref.replace("Transparent.", "");
return `var(--${key})`;
}

// System/Mode 1의 Colors 참조
if (ref.startsWith("Colors.")) {
const key = ref.replace("Colors.", "");
return `var(--${key})`;
}

return value;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

resolveValue 함수 내에 if (ref.startsWith(...)) 조건문이 반복적으로 사용되고 있습니다. 이 구조는 새로운 토큰 카테고리가 추가될 때마다 코드를 수정해야 하므로 확장성이 떨어집니다. 참조 경로(Grayscale.color-gray-64 등)를 파싱하여 동적으로 토큰 객체를 탐색하는 방식으로 리팩토링하면 더 유연하고 유지보수하기 좋은 코드가 될 것입니다.

@dasosann dasosann closed this Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant