-
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
Conversation
🦋 Changeset detectedLatest commit: 601226b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
@@ -227,6 +228,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 comment
The 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 comment
The 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 comment
The 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 comment
The 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.
46ab6f3
to
601226b
Compare
Sorry, my PR was a bit rushed. This is what I'm proposing: (will make changes to the PR if we like the proposal) cc @ashygee |
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 think left-aligning the leadingVisual
and label when we have a trailingVisual
is a bit strange. It will especially look weird if we have two stacked full-width buttons where 1 has left-aligned text, and the other has center-aligned text.
I think the "current" column of the mock you posted is what we want.
Curious to hear what @ashygee thinks
@@ -217,6 +217,7 @@ export const getButtonStyles = (theme?: Theme) => { | |||
...getBaseStyles(theme), | |||
display: 'grid', | |||
gridTemplateAreas: '"leadingIcon text trailingIcon"', | |||
gridTemplateColumns: 'min-content 1fr min-content', |
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;
For context, this is the pattern I'm chasing: This is what the code looks like for positioning it correctly (ignoring the hover state for now): To be able to override it correctly, you have to know some implementation details about it, which feels wrong :( <NewButton
variant="invisible"
trailingIcon={GearIcon}
sx={{
width: "100%",
justifyContent: "space-between",
gridTemplateAreas: '"text trailingIcon"'
}}
> |
@mperrotti - If there is a product use case then I think we should work on supporting the new mocks. |
Since @ashygee is on holidays, I was wondering if @vdepizzol could help us with this? |
Context:
only issues-app for now I think, but feels like a generic use case, we can also decide we want this alignment to be an override in the product instead of supporting it out of the box.
That could work!
That would be nice. This can also wait, it's not a december problem :) |
* add template columns and text align for text * only align left if there's a leading Icon * add changeset * add warning for multiple selection with DropdownMenu * wip: stories * use leadingIcon with #1733 * add form to story example * use menuitemradio + aria-checked * fix types for selectionProperty * it's not a property, it's an attribute * placeholder in story * story with placeholder * oops, don't want forms to submit! * selected milestone can be undefined! * update snapshots * Add story for controlled menu and external anchor * add tests! * export DropdownMenu2 as draft * default to selectionVariant single for DropdownMenu * dont need axe anymore * update octicons for docs * add docs for dropdown menu v2 * remove changes from #1733 * update snapshots for removed button * link to button2 docs * add changeset * lol everybody makes mistakes * oof! * Use active voice in component description Co-authored-by: Rez <rezrah@github.com> * update snapshosts with main * just Props Co-authored-by: Rez <rezrah@github.com> * Use PropsTable * simplify code example a bit * make controlled state more clear * keep lockfile version 1 * remove unrelated change Co-authored-by: Rez <rezrah@github.com>
This came up during a Primer design pattern working session, and I like how @langermank decided to handle it Storybook preview deployment link: https://primer-css-goebhg4xi-primer.vercel.app/css/storybook?path=/story/explorations--example-sheet |
This isn't the direction in which we're going ✌️ |
With a block button, the icon and text alignment is a bit strange
Screenshots
Please provide before/after screenshots for any visual changes
The chromatic tests (see checks below) show that there are no visual regressions :)
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.