Skip to content

feat: Component 토큰을 flat ShapeStyle/CGFloat 확장으로 노출#28

Merged
Roy-wonji merged 2 commits into
developfrom
feat/component-flat-shapestyle
May 13, 2026
Merged

feat: Component 토큰을 flat ShapeStyle/CGFloat 확장으로 노출#28
Roy-wonji merged 2 commits into
developfrom
feat/component-flat-shapestyle

Conversation

@Roy-wonji
Copy link
Copy Markdown
Contributor

요약

`ComponentToken.Button.Primary.Background.default` 같은 중첩 enum 접근을 `Color.buttonPrimaryBackgroundDefault` 같은 flat ShapeStyle 확장으로 단순화합니다. brand/semantic 토큰과 동일한 사용 패턴.

```swift
// before
.background(ComponentToken.Button.Primary.Background.default)

// after
.background(.buttonPrimaryBackgroundDefault)
```

변경

Tools/TokenGenerator.swift

  • 기존 `walkComponent` (중첩 enum 생성) → `walkComponentFlat` (pathPrefix 기반 camelCase 단일 이름)
  • 변환 규칙
    • `Component.button.primary.background.default` → `buttonPrimaryBackgroundDefault`
    • `Component.button.radius` → `buttonRadius`
  • `ComponentToken.swift` 더 이상 생성하지 않고, 잔재 파일이 있으면 자동 삭제

Generated 산출물

  • `Sources/Color/ShapeStyle+.swift` — `// MARK: - Component` 섹션에 25종 색상 추가
  • `Sources/Extension/CGFloat/CGFloat+Component+.swift` — 신규 (현재 buttonRadius 1종)
  • `Sources/UI/Token/ComponentToken.swift` — 삭제 (중첩 enum 폐기)

영향 범위

develop 전체에서 `ComponentToken.swift` 외 `ComponentToken` 직접 사용처 0건. 폐기에 따른 컴파일 영향 없음.

사용 예시

```swift
Text("확인")
.padding(.horizontal, .s16)
.padding(.vertical, .s8)
.background(.buttonPrimaryBackgroundDefault)
.foregroundStyle(.buttonPrimaryTextDefault)
.clipShape(RoundedRectangle(cornerRadius: .buttonRadius)) // 또는 .default
```

머지 후 흐름

이 PR 머지 후 design-tokens 의 토큰 변경 PR 이 자동으로 새 형태로 생성됩니다 (TokenGenerator.swift 가 업데이트됐으므로).

Roy-wonji added 2 commits May 13, 2026 12:38
- Tools/TokenGenerator.swift 의 Component 처리 로직을 nested enum → flat path 로 교체
  · walkComponent → walkComponentFlat (pathPrefix 누적해서 camelCase 단일 이름 생성)
  · Component.button.primary.background.default → buttonPrimaryBackgroundDefault
  · Component.button.radius → buttonRadius
- ShapeStyle+.swift 끝 섹션에 Component 색상 25종 추가 (Color.buttonPrimaryBackgroundDefault 등)
- CGFloat+Component+.swift 신규 — Component 숫자 토큰 (buttonRadius)
- 옛 ComponentToken nested enum 폐기 (ComponentToken.swift 삭제)
  · develop 전체에서 ComponentToken 직접 사용처가 ComponentToken.swift 외 0건 확인 후 폐기

사용 예
- .background(.buttonPrimaryBackgroundDefault)
- .foregroundStyle(.buttonPrimaryTextDefault)
- .clipShape(RoundedRectangle(cornerRadius: .buttonRadius))
#28 의 nested 폐기 결정을 번복. flat + nested 둘 다 유지하되, nested 가
flat 정의를 forwarding 하는 형태로 source-of-truth 를 단일화.

- TokenGenerator.swift 에 walkComponentNested 추가
  · 색상: public static var `default`: Color { .buttonPrimaryBackgroundDefault }
  · 숫자: public static var radius: CGFloat { .buttonRadius }
- ComponentToken.swift 재생성 (옛 inline hex/brand alias 대신 flat 확장 참조)
- 토큰 변경 시 flat 정의만 바뀌면 nested 도 자동 동기화

두 가지 사용 패턴 모두 가능
- .background(.buttonPrimaryBackgroundDefault)
- .background(ComponentToken.Button.Primary.Background.default)
@Roy-wonji Roy-wonji merged commit 292c642 into develop May 13, 2026
3 checks passed
@Roy-wonji Roy-wonji deleted the feat/component-flat-shapestyle branch May 13, 2026 03:51
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