-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[ButtonGroup] Add optional nowrap property to ButtonGroup #8033
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
size-limit report 📦
|
| segmented, | ||
| fullWidth, | ||
| connectedTop, | ||
| noWrap, |
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.
| noWrap, | |
| noWrap, | |
| }: ButtonGroupProps) { | |
| const className = classNames( | |
| styles.ButtonGroup, | |
| spacing && styles[spacing], | |
| segmented && styles.segmented, | |
| fullWidth && styles.fullWidth, | |
| noWrap && style.noWrap, | |
| ); |
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 see now how this is wrapped around the {contents}. My div was redundant. Updated.
| data-buttongroup-no-wrap={noWrap} | ||
| > | ||
| {contents} | ||
| <div className={classNames(noWrap && styles.noWrap)}>{contents}</div> |
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.
| <div className={classNames(noWrap && styles.noWrap)}>{contents}</div> | |
| {contents} |
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.
Updated.
| } | ||
|
|
||
| .noWrap { | ||
| display: flex; | ||
| flex-wrap: nowrap; | ||
| } |
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 the bug highlighted by the visual regression snapshots can be fixed by moving this class in with the rest of the subclasses 👀
| } | |
| .noWrap { | |
| display: flex; | |
| flex-wrap: nowrap; | |
| } | |
| .noWrap { | |
| display: flex; | |
| flex-wrap: nowrap; | |
| } | |
| } |
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.
So, moving this up into the above brackets would move it inside the .loose class, no?
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 I look at the .scss file, none of these sub classes actually seem to be inside .ButtonGroup
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.
Ah yeah sorry! Made the suggestion on scanning the file here, but no the subclasses aren't nested so there's something else going on 👀 It's odd because the .segmented class also makes the button group not wrap so I'd expect what you have to be enough, but I haven't had time to check out the branch and poke around.
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 played around with this in the Playground and it seems to be working as expected now that I've moved the class into the proper div on the tsx page. I also updated the ButtonGroup NoWrap story to show the difference between default and nowrap. Let me know if that can be improved. Thanks @chloerice!
8f0b9f1 to
2b7a892
Compare
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.
This looks good to go 🎩 👍🏽 Thanks for contributing @allisonjanes-shopify! 🎉
.changeset/happy-dragons-repair.md
Outdated
| '@shopify/polaris': minor | ||
| --- | ||
|
|
||
| Add optional noWrap property to ButtonGroup |
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.
| Add optional noWrap property to ButtonGroup | |
| Added an optional `noWrap` prop to `ButtonGroup` |
2b7a892 to
d8d2bf0
Compare
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @shopify/polaris@10.21.0 ### Minor Changes - [#8033](#8033) [`a2eca1d4d`](a2eca1d) Thanks [@allisonjanes-shopify](https://github.com/allisonjanes-shopify)! - Added an optional `noWrap` prop to `ButtonGroup` - [#8016](#8016) [`ca77f0bc8`](ca77f0b) Thanks [@itwasmattgregg](https://github.com/itwasmattgregg)! - Added the ability for breadcrumbs to be passed as a singular object instead of an array to allow support for upcoming v11 changes ### Patch Changes - [#8059](#8059) [`4b470fc98`](4b470fc) Thanks [@LauraAubin](https://github.com/LauraAubin)! - Fix vertical alignment for sortable headers with custom content on the IndexTable ## @shopify/plugin-polaris@0.0.28 ## polaris.shopify.com@0.28.5 ### Patch Changes - Updated dependencies \[[`4b470fc98`](4b470fc), [`a2eca1d4d`](a2eca1d), [`ca77f0bc8`](ca77f0b)]: - @shopify/polaris@10.21.0 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
<!-- ☝️How to write a good PR title: - Prefix it with [ComponentName] (if applicable), for example: [Button] - Start with a verb, for example: Add, Delete, Improve, Fix… - Give as much context as necessary and as little as possible - Prefix it with [WIP] while it’s a work in progress --> This PR is non-breaking and adds an optional noWrap property to the ButtonGroup component which prevents the buttons in a ButtonGroup from wrapping onto a new line. This change will help with alignment issues we have been having on the new Metaobjects Index page encountered with very long Metaobject Type names. <img width="556" alt="Screenshot 2023-01-11 at 4 13 12 PM" src="https://user-images.githubusercontent.com/109357057/211918907-9632b84b-1f32-4b5b-80d4-75b2130f0022.png"> A `noWrap` option will allow for the title object to wrap sooner instead of forcing the action buttons onto 2 lines. ### WHY are these changes introduced? To address alignment issues on the new Metaobjects page. Since we want our buttons in line with our Metaobjects `Type` label (which might be long), we would prefer to set the `ButtonGroup` to `noWrap` and force the label to wrap. <!-- Context about the problem that’s being addressed. --> ### WHAT is this pull request doing? <!-- Summary of the changes committed. Before / after screenshots are appreciated for UI changes. Make sure to include alt text that describes the screenshot. If you include an animated gif showing your change, wrapping it in a details tag is recommended. Gifs usually autoplay, which can cause accessibility issues for people reviewing your PR: <details> <summary>Summary of your gif(s)</summary> <img src="..." alt="Description of what the gif shows"> </details> --> ### 🎩 checklist - [x] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [x] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [ ] Updated the component's `README.md` with documentation changes - [ ] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @shopify/polaris@10.21.0 ### Minor Changes - [Shopify#8033](Shopify#8033) [`a2eca1d4d`](Shopify@a2eca1d) Thanks [@allisonjanes-shopify](https://github.com/allisonjanes-shopify)! - Added an optional `noWrap` prop to `ButtonGroup` - [Shopify#8016](Shopify#8016) [`ca77f0bc8`](Shopify@ca77f0b) Thanks [@itwasmattgregg](https://github.com/itwasmattgregg)! - Added the ability for breadcrumbs to be passed as a singular object instead of an array to allow support for upcoming v11 changes ### Patch Changes - [Shopify#8059](Shopify#8059) [`4b470fc98`](Shopify@4b470fc) Thanks [@LauraAubin](https://github.com/LauraAubin)! - Fix vertical alignment for sortable headers with custom content on the IndexTable ## @shopify/plugin-polaris@0.0.28 ## polaris.shopify.com@0.28.5 ### Patch Changes - Updated dependencies \[[`4b470fc98`](Shopify@4b470fc), [`a2eca1d4d`](Shopify@a2eca1d), [`ca77f0bc8`](Shopify@ca77f0b)]: - @shopify/polaris@10.21.0 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This PR is non-breaking and adds an optional noWrap property to the ButtonGroup component which prevents the buttons in a ButtonGroup from wrapping onto a new line. This change will help with alignment issues we have been having on the new Metaobjects Index page encountered with very long Metaobject Type names.
A
noWrapoption will allow for the title object to wrap sooner instead of forcing the action buttons onto 2 lines.WHY are these changes introduced?
To address alignment issues on the new Metaobjects page. Since we want our buttons in line with our Metaobjects
Typelabel (which might be long), we would prefer to set theButtonGrouptonoWrapand force the label to wrap.WHAT is this pull request doing?
🎩 checklist
README.mdwith documentation changes