Skip to content

[Feat] #90 - MDSActionButton 컴포넌트 구현#92

Merged
yungu0010 merged 3 commits into
defaultfrom
feat/#90-action-button
May 30, 2026
Merged

[Feat] #90 - MDSActionButton 컴포넌트 구현#92
yungu0010 merged 3 commits into
defaultfrom
feat/#90-action-button

Conversation

@yungu0010
Copy link
Copy Markdown
Member

@yungu0010 yungu0010 commented May 25, 2026

🌴 PR 요약

🌱 작업한 브랜치

🌱 PR Point

UIControl + UIStackView 선택 이유

prefix/suffix 아이콘이 각각 독립적으로 optional이기 때문에 UIButton 대신 UIControl + UIStackView를 사용했습니다.

  • UIButton.Configurationimage 프로퍼티가 하나뿐이라 prefix/suffix를 동시에 표현할 수 없음
  • UIControl + UIStackViewprefixImageView, titleLabel, suffixImageView를 각각 arranged subview로 구성하여, isHidden = true 처리만으로 UIStackView가 해당 뷰를 자동으로 collapse함.
  • 별도의 layoutSubviews 오버라이드 없이 4가지 조합(없음 / prefix만 / suffix만 / 둘 다)을 모두 처리할 수 있음.
  • 탭 이벤트는 UIControladdTarget(_:action:for:) 으로 동일하게 지원.

didSet 프로퍼티를 사용한 이유

title, prefixIcon, suffixIconinit 파라미터 대신 프로퍼티로 둔 이유는 초기화 이후에도 외부에서 값을 변경할 수 있도록 하기 위해서입니다.

  • init에 넣으면 값을 바꿀 때마다 버튼을 새로 생성
  • didSet을 통해 값이 바뀌는 시점에 UI가 즉시 반영
  • variantsize는 레이아웃을 결정하므로 변경을 허용하지 않고 init에서만 받음

danger + xsmall 스펙 불일치 처리

danger variant는 디자인 스펙상 xsmall size를 지원하지 않습니다. 런타임에서 허용 상태를 방지하기 위해 init에서 아래와 같이 처리합니다.

  • Debug: assertionFailure로 스펙 위반을 즉시 감지
  • Release: .small로 폴백하여 앱이 중단되지 않도록 처리
사이즈 스펙
Size Height Corner Radius Padding (V/H) Icon Size Typography
xsmall 32px r16 8 / 12 16px label4
small 36px r8 10 / 14 16px label3
medium 46px r10 12 / 20 20px label2
large 56px r12 16 / 24 24px label1

danger variant는 디자인 스펙상 xsmall 미지원

컬러 토큰

Variant State Background Foreground
primary default Bg.Neutral.inverse Fg.Neutral.inverse
primary highlighted Bg.Neutral.Inverse.hover Fg.Neutral.inverse
secondary default Bg.Neutral.subtle Fg.Neutral.bold
secondary highlighted Bg.Neutral.Subtle.hover Fg.Neutral.bold
danger default Bg.Danger.default Fg.Neutral.bold
danger highlighted Bg.Danger.Default.pressed Fg.Neutral.bold
disabled Bg.Neutral.Default.disabled Fg.Neutral.Default.disabled

📸 스크린샷

기능 스크린샷
MDSActionButton image

📮 관련 이슈

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

Review Change Stack

Walkthrough

MDSActionButton UIControl과 공개 타입(Variant, Size)을 추가해 텍스트와 선택적 prefix/suffix 아이콘을 지원하는 수평 버튼을 구현하며, SizeToken/ColorToken으로 레이아웃과 색상을 결정합니다.

Changes

액션 버튼 컴포넌트

Layer / File(s) Summary
버튼 타입 정의
MDS/Sources/Components/ActionButton/MDSActionButtonType.swift
MDSActionButton 확장에서 Variant(primary, secondary, danger)와 Size(xsmall, small, medium, large) 공개 열거형을 정의합니다.
UIControl 구현 및 레이아웃
MDS/Sources/Components/ActionButton/MDSActionButton.swift (줄 1–141)
MDSActionButton UIControl 클래스를 구현하고, title/prefixIcon/suffixIcon 프로퍼티와 isHighlighted/isEnabled 상태 변경을 didSet으로 연결하여 updateAppearance()를 호출합니다. setup() 메서드에서 size 기반 코너 반경과 스택뷰 제약(높이, 인셋, 아이콘 크기)을 구성하며, danger+xsmall 조합을 검사해 size를 보정합니다.
사이즈 토큰 정의
MDS/Sources/Components/ActionButton/MDSActionButton.swift (줄 143–188)
SizeToken 구조체를 통해 각 size별 버튼 높이, 코너 반경, 콘텐츠 인셋, 아이콘 갭/크기, 타이포그래피를 매핑합니다.
컬러 토큰 정의
MDS/Sources/Components/ActionButton/MDSActionButton.swift (줄 190–228)
ColorToken 구조체를 통해 variant와 isHighlighted/isEnabled 조합에 따른 배경/전경 컬러를 선택하며, disabled 상태에서는 disabled 색상으로 고정합니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • kwonseokki
  • juri123123

🐰 버튼이 찰칵, 빛나네
글자와 아이콘 어깨동무
토큰으로 치수 맞추고
색도 맞춰 반짝반짝
배포 준비 완료!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 추가된 MDSActionButton 컴포넌트 구현이라는 주요 변경사항을 명확하게 요약하고 있습니다.
Linked Issues check ✅ Passed PR은 #90의 요구사항인 MDSActionButton 컴포넌트를 다양한 variants(primary/secondary/danger), 크기(xsmall/small/medium/large), 상태(default/highlighted/disabled), prefix/suffix 아이콘, 디자인 스펙 준수 등으로 모두 구현했습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 MDSActionButton 컴포넌트 구현과 관련 열거형 정의에 집중되어 있으며, #90의 요구사항 범위 내에 있습니다.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed PR 설명이 구현된 MDSActionButton 컴포넌트의 기술적 결정사항, 스펙, 색상 토큰 등과 직접적으로 관련되어 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/#90-action-button

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yungu0010 yungu0010 self-assigned this May 25, 2026
@yungu0010 yungu0010 added enhancement New feature or request feat labels May 25, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@MDS/Sources/Components/ActionButton/MDSActionButton.swift`:
- Around line 77-80: The init(variant:size:) currently allows the unsupported
combination Variant.danger + Size.xsmall; update the
MDSActionButton.init(variant:size:) to detect if variant == .danger and size ==
.xsmall, then replace the unsupported size with a safe fallback (e.g., .small)
and emit a debug assertion (assertionFailure or preconditionFailure in debug
builds) so developers are alerted; ensure the assignment to self.size uses the
fallback and keep Variant and Size behavior consistent elsewhere (also apply the
same guard in any other initializers or factory methods that construct
MDSActionButton).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9cbc10c9-0312-408a-9eca-e22d377a5df8

📥 Commits

Reviewing files that changed from the base of the PR and between dc05732 and 94ae45b.

📒 Files selected for processing (2)
  • MDS/Sources/Components/ActionButton/MDSActionButton.swift
  • MDS/Sources/Components/ActionButton/MDSActionButtonType.swift

Comment thread MDS/Sources/Components/ActionButton/MDSActionButton.swift
danger variant에서 xsmall size 사용 시 디버그 단에서 assertionFailure로
스펙 위반을 감지하고, 릴리즈에서는 small로 폴백 처리
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

@yungu0010 yungu0010 requested a review from juri123123 May 28, 2026 11:35
setupHierarchy(), setupLayout()으로 분리
Copy link
Copy Markdown
Contributor

@juri123123 juri123123 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 !

@yungu0010 yungu0010 merged commit 4303a5a into default May 30, 2026
1 check passed
@yungu0010 yungu0010 deleted the feat/#90-action-button branch May 30, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] Action Button 컴포넌트 구현

2 participants