refactor: simplify Button CSS by using min-heights - #4514
Conversation
|
@claude review |
|
Claude finished @pomfrida's task in 1m 9s —— View job Code ReviewSummaryThis is an excellent refactor that significantly simplifies the Button component. The changes are well-executed and demonstrate strong understanding of both CSS and React patterns. The 41% reduction in CSS complexity (303 → 179 lines) is achieved through a cleaner, more maintainable approach. ✅ Strengths
🔍 Minor Observations
✨ Code Quality
📊 Impact AssessmentBenefits:
Trade-offs:
🎯 RecommendationLGTM - Ready to merge after addressing optional simplifications. The refactor achieves its stated goals perfectly. The only suggestions are optional cleanups around the unused typography-related code. The core changes are solid and well-tested. Optional follow-up improvements:
These are minor and don't block merging this excellent refactor. |
Notes on CSS approachText centering (text shift)Button text has an inherent ~0.5px vertical offset due to font metric asymmetry (ascender > descender). This is a property of the font — not a CSS bug. Before (main): Padding-driven sizing with manual adjustments — asymmetric padding for comfortable density ( After:
Why
|
Replace span height: round(1cap, 4px) with min-height-only approach. In @supports, remove padding-block (instead of min-height) so flexbox centers the span's natural line-height within the min-height box. Improves text centering from -1px to -0.5px max offset.
…block Cap unit is supported in all major browsers for 2+ years — no need for padding-block fallback or @supports feature gate.
7182358 to
dfdac27
Compare
vnys
left a comment
There was a problem hiding this comment.
LGTM 👍🏻 We need to revisit the things that contradict the spacing and typography foundations (height is a function of the content + spacing) after the release, but I think this solves the issues we have for now.
Summary
<TypographyNext>wrapper span from Button — children are now direct flex childrenheightvalues from Figma@layer(line-height overrides, asymmetric padding, icon-only padding calculations)@layer eds-componentsResult: 303 → 179 lines CSS (-41%), 0
calc(), 0 custom properties, 0 line-height overridesContext
See #4513 for detailed analysis of the density token mismatch and trade-offs.
Test plan