[Feat] #90 - MDSActionButton 컴포넌트 구현#92
Conversation
WalkthroughMDSActionButton UIControl과 공개 타입(Variant, Size)을 추가해 텍스트와 선택적 prefix/suffix 아이콘을 지원하는 수평 버튼을 구현하며, SizeToken/ColorToken으로 레이아웃과 색상을 결정합니다. Changes액션 버튼 컴포넌트
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
시
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
MDS/Sources/Components/ActionButton/MDSActionButton.swiftMDS/Sources/Components/ActionButton/MDSActionButtonType.swift
danger variant에서 xsmall size 사용 시 디버그 단에서 assertionFailure로 스펙 위반을 감지하고, 릴리즈에서는 small로 폴백 처리
|
Actionable comments posted: 0 |
setupHierarchy(), setupLayout()으로 분리
🌴 PR 요약
🌱 작업한 브랜치
🌱 PR Point
UIControl + UIStackView 선택 이유
prefix/suffix 아이콘이 각각 독립적으로 optional이기 때문에
UIButton대신UIControl + UIStackView를 사용했습니다.UIButton.Configuration은image프로퍼티가 하나뿐이라 prefix/suffix를 동시에 표현할 수 없음UIControl + UIStackView는prefixImageView,titleLabel,suffixImageView를 각각 arranged subview로 구성하여,isHidden = true처리만으로 UIStackView가 해당 뷰를 자동으로 collapse함.layoutSubviews오버라이드 없이 4가지 조합(없음 / prefix만 / suffix만 / 둘 다)을 모두 처리할 수 있음.UIControl의addTarget(_:action:for:)으로 동일하게 지원.didSet 프로퍼티를 사용한 이유
title,prefixIcon,suffixIcon을init파라미터 대신 프로퍼티로 둔 이유는 초기화 이후에도 외부에서 값을 변경할 수 있도록 하기 위해서입니다.init에 넣으면 값을 바꿀 때마다 버튼을 새로 생성didSet을 통해 값이 바뀌는 시점에 UI가 즉시 반영variant와size는 레이아웃을 결정하므로 변경을 허용하지 않고init에서만 받음danger + xsmall 스펙 불일치 처리
danger variant는 디자인 스펙상 xsmall size를 지원하지 않습니다. 런타임에서 허용 상태를 방지하기 위해
init에서 아래와 같이 처리합니다.assertionFailure로 스펙 위반을 즉시 감지.small로 폴백하여 앱이 중단되지 않도록 처리사이즈 스펙
컬러 토큰
Bg.Neutral.inverseFg.Neutral.inverseBg.Neutral.Inverse.hoverFg.Neutral.inverseBg.Neutral.subtleFg.Neutral.boldBg.Neutral.Subtle.hoverFg.Neutral.boldBg.Danger.defaultFg.Neutral.boldBg.Danger.Default.pressedFg.Neutral.boldBg.Neutral.Default.disabledFg.Neutral.Default.disabled📸 스크린샷
📮 관련 이슈