-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Align button content to the center #243
Conversation
@@ -0,0 +1,4 @@ | |||
.button { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question I'm suprised that this is happening. My hunch is that maybe we've missed a Design Token. Have those been investigated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
export interface IButtonProps extends AntButtonProps {} | ||
|
||
export const Button = (props: IButtonProps) => { | ||
return ( | ||
<ConfigProvider> | ||
<AntButton {...props}>{props.children}</AntButton> | ||
<AntButton {...props} className="aquarium-button"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hum, um, yea can we do this in a different way? why not use a utility class, or a Flex
component?
also, why do we need every single button from the aquarium to always be flex? shouldnt it def be a props.children level concern?
if this is fixed in 5.17, might it be better to find an update path instead of patch a hack with display?
@@ -0,0 +1,4 @@ | |||
.aquarium-button--aligned-center { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit hey its me again 〰️
could prefer present tense here, align
over aligned
, its less typing too 😉
but really per the Style Guide, modifier selectors should only be used in conjunction with the unmodified class. this ensures a higher specificity and that the modifier will "always override" the base class
in this case, it would be like .aquarium-button.aquarium-button--aligned-center {}
which would be correct doesnt really make a ton of sense since we dont have any other .aquarium-button
s or rules for a base .aquarium-button
peronally for things like this i'm more a fan of utility classes
we have a place for more in the aquarium
could be something like
<AntButton {...props} className={props.icon ? 'u-display-flex u-align-items-center' : ''}>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was literally changing it for the utility class 🙏 . I'm also big fan of utility classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job on the investigation, evolution of context and alignment seeking in this PR :)
# [1.15.0-icons-integration.3](v1.15.0-icons-integration.2...v1.15.0-icons-integration.3) (2024-05-23) ### Bug Fixes * Align button content to the center ([#243](#243)) ([ca0901d](ca0901d))
🎉 This PR is included in version 1.15.0-icons-integration.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Whenever a button has an icon larger than the label's font size, it becomes misaligned
Currently, we are adding an icon through the icon prop. While version 5.17 (we are currently in 5.13) introduces iconPosition this prop only allows switching the icon between the left and right sides, not centering it.
Since we are adding it though props and not in the children, we can't use a Flex container to make the button aligned, and we can't let the children handle the alignment either. Here is a code snippet from ant's implementation on the icon/children. The rest of the code you can find it here:
As a workaround for this problem, I set up a class that makes the button flex and center aligned only when it has an icon
The button with the fix: