-
Notifications
You must be signed in to change notification settings - Fork 616
Button v2: Fix icon positions for block buttons #1733
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
Changes from all commits
cdb29e5
e56eb42
206a9e2
e562c65
601226b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/react': patch | ||
--- | ||
|
||
Button 2: Fix icon positions for block buttons |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,6 +217,7 @@ export const getButtonStyles = (theme?: Theme) => { | |
...getBaseStyles(theme), | ||
display: 'grid', | ||
gridTemplateAreas: '"leadingIcon text trailingIcon"', | ||
gridTemplateColumns: 'min-content 1fr min-content', | ||
'& > :not(:last-child)': { | ||
mr: '2' | ||
}, | ||
|
@@ -228,6 +229,9 @@ export const getButtonStyles = (theme?: Theme) => { | |
}, | ||
'[data-component="trailingIcon"]': { | ||
gridArea: 'trailingIcon' | ||
}, | ||
'[data-component="leadingIcon"] + [data-component="text"]': { | ||
textAlign: 'left' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this leftAlign is required tbh. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fair, how do we make it easier for the user to override this with left align? this would be the override, not sure if requires knowing the internal details? <Button
leadingIcon={EyeIcon}
trailingIcon={TriangleDownIcon}
sx={{ '[data-component="text"]': { textAlign: 'left' } }}
>
Watch
</Button> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True :( This is where composite components would be handy. Maybe such an override usecase means we want to open up the API? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we go with the center-aligned approach I recommended, we can get rid of this style block. |
||
} | ||
} | ||
return styles | ||
|
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.
If we decide to go with the center-aligned approach I recommended, we can remove this style and just add
justify-content: center;