-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Button] Replace booleans with new props #10090
Conversation
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 amazing Aveline, nice cleanup 👏
Can you add a major changelog entry and maybe also a TODO in the v11 to v12 migration guide?
variant && variant === 'primary' && styles.primary, | ||
variant && variant === 'plain' && styles.plain, | ||
variant && variant === 'primaryPlain' && styles.primary, | ||
variant && variant === 'primaryPlain' && styles.primaryPlain, | ||
variant && variant === 'monochromePlain' && styles.monochrome, | ||
variant && variant === 'monochromePlain' && styles.plain, | ||
tone && tone === 'critical' && styles.destructive, | ||
tone && tone === 'success' && styles.success, |
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 don't think we need the variant &&
or tone &&
for these. Or was it rendering something weird like false
as a class?
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 catch, thanks!
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.
Changes look awesome! I'm just still confused by all the variants 😅
/** Sets the color treatment of the Button. */ | ||
tone?: 'critical' | 'success'; | ||
/** Changes the visual appearance of the Button. */ | ||
variant?: 'plain' | 'primary' | 'primaryPlain' | 'monochromePlain'; |
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 like the shift to variant
and tone
here. However, are we firm on the naming?
It seems we are mixing button shape and style with color in the variant
prop. With this model, it seems like we could either move all style variations to variant
(ex primaryDestructive
, plainDestructive
) or we keep them separate allow for combinations (ex: variant="plain" tone="primary"
) with the caveat that all combos have to work together.
Currently, I feel like I have to rely on documentation to understand which button style I'm going to get.
Guess I'm just still confused by all the variants 😓
cc @sarahill
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.
Great points @samrose3. I agree the variants are less than ideal at the moment. The primaryPlain
and monochromePlain
are hacky workarounds for the state of things at the moment.
With tone
I am trying to follow the API guidelines and my understanding is it will show up in other components like Banner
so it would make sense to keep the values consistent between components. critical
and success
make sense applied to Banner
but less sure about tone="primary"
for Banner
? primary
seems more like a Button
style to me.
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.
Agree the naming isn't intuitive to what they'll visually look like. How about something like the attached. I don't like plainMonochrome
as it's describing a couple things but it's legacy and I believe we'll move away from it and plain
as we continue to implement the Uplift.
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 update makes more sense to me 👍 thanks for the additional context @aveline and for the variant updates @sarahill!
I am aligned with the above proposed variants and tone, just want to throw one final consideration and know your advise and feedback!
Would it be too complicated to remove monochrome and either use:
- default the blue link color and use
tone="netrual"
for monochrome (follows API alignment tone proposal) - OR use a
variant="link"
that makes it clear the link color is used (tone has no effect) - OR default to monochrome color for
plain
and usetone="info"
for a link style (not a fan of this one sinceinfo
isn't really related here)
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.
Great suggestions! I will update primaryPlain
to be tertiary
as @sarahill proposed.
I like those ideas @samrose3 if we were planning on keeping plainMonochrome
but I would hesitate to introduce a neutral
tone for a variant that is a hack and really should be removed.
These are the two instances of monochromePlain
within Polaris
There are 36 more in web. It would be worth going through and cleaning that up at some point so we could remove the plainMonochrome
variant altogether.
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 like those ideas @samrose3 if we were planning on keeping plainMonochrome but I would hesitate to introduce a neutral tone for a variant that is a hack and really should be removed.
➕ ☝️
This I would expect to be tertiary
with inverted colors
This I would expect to be tertiary
Some of this is tough because with these updates we also have to account for the space they take up so I don't expect all these changes to happen now. Just some examples to Aveline's point of plainMonochrome
isn't a long term pattern we want to promote.
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 I would expect to be tertiary with inverted colors
So does this become a tertiaryInverted
variant? Or how do we propose handling inverted? It's probably something that could apply to all variants?
This is something we need to put more thought into and until we have it a bit more solidified at the system level, plainMonochrome
is the iterim state.
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 is something we need to put more thought into and until we have it a bit more solidified at the system level, plainMonochrome is the interim state.
Yea I'm tempted to say leave as is for now (use plainMonochrome
) but we'll need to figure out the better solution. I don't know that adding explicit variants for inverse
is great long-term. This feels like another place where component level theming could be beneficial but that feels like a follow up.
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 agree
### WHAT is this pull request doing? Update `ButtonGroup` variant styles to match the changes from #10090 ### How to 🎩 Check that this story is getting the plain button group item variant |Next branch|This PR|Production| |-|-|-| |<img width="321" alt="Screenshot 2023-08-24 at 2 36 27 PM" src="https://github.com/Shopify/polaris/assets/20652326/54bff50b-f4b1-4540-a891-7f3c4a7afaf7">|<img width="306" alt="Screenshot 2023-08-24 at 2 37 27 PM" src="https://github.com/Shopify/polaris/assets/20652326/3dd5578e-51ad-4469-82fe-61db3440b936">|<img width="303" alt="Screenshot 2023-08-24 at 2 37 12 PM" src="https://github.com/Shopify/polaris/assets/20652326/7141b6a8-9589-4746-a7d7-eb9229a6c61d">|
Fixes #10047 - Adds `variant` and `tone` props - Removes `primary`, `outline`, `plain`, `monochrome`, and `primarySuccess` booleans - Updates props on usages of `Button` - Renames `primaryPlain` variant to `tertiary`
### WHAT is this pull request doing? Update `ButtonGroup` variant styles to match the changes from #10090 ### How to 🎩 Check that this story is getting the plain button group item variant |Next branch|This PR|Production| |-|-|-| |<img width="321" alt="Screenshot 2023-08-24 at 2 36 27 PM" src="https://github.com/Shopify/polaris/assets/20652326/54bff50b-f4b1-4540-a891-7f3c4a7afaf7">|<img width="306" alt="Screenshot 2023-08-24 at 2 37 27 PM" src="https://github.com/Shopify/polaris/assets/20652326/3dd5578e-51ad-4469-82fe-61db3440b936">|<img width="303" alt="Screenshot 2023-08-24 at 2 37 12 PM" src="https://github.com/Shopify/polaris/assets/20652326/7141b6a8-9589-4746-a7d7-eb9229a6c61d">|
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 next, this PR will be updated.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ `next` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `next`.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ # Releases ## @shopify/polaris@12.0.0-beta.1 ### Major Changes - [#10122](#10122) [`43b42aefed`](43b42ae) Thanks [@aveline](https://github.com/aveline)! - Removed `shape` prop on `Avatar` component - [#10270](#10270) [`b9bcaef41`](b9bcaef) Thanks [@kyledurand](https://github.com/kyledurand)! - Changed `spacing` prop to `gap` on `List` and `DescriptionList` - [#9997](#9997) [`b59fc9e27`](b59fc9e) Thanks [@yurm04](https://github.com/yurm04)! - [ButtonGroup] Removed `segmented` boolean prop and replaced with `variant`. Replaced `spacing` prop with `gap` - [#10100](#10100) [`4c7b2d4858`](4c7b2d4) Thanks [@kyledurand](https://github.com/kyledurand)! - Updated `borderRadius` props to match web spec - [#10051](#10051) [`69edd97ceb`](69edd97) Thanks [@aveline](https://github.com/aveline)! - Renamed `color` prop to `tone` for `ProgressBar` component - [#10182](#10182) [`e814c0ee1a`](e814c0e) Thanks [@kyledurand](https://github.com/kyledurand)! - Removed connectedDislosure prop on button - [#10283](#10283) [`42ee9f407`](42ee9f4) Thanks [@sam-b-rose](https://github.com/sam-b-rose)! - Renamed `size` prop values for the Avatar component. See the following table for the new prop mappings. | Before | After | | ------------------------- | ----------- | | `size="extraSmall"` | `size="xs"` | | `size="small"` | `size="sm"` | | `size="medium"` | `size="md"` | | `size="large"` | `size="lg"` | | `size="xl-experimental"` | `size="xl"` | | `size="2xl-experimental"` | `size="xl"` | - [#10232](#10232) [`eb2c2035c`](eb2c203) Thanks [@laurkim](https://github.com/laurkim)! - Removed `divider` prop from `Page` component - [#10271](#10271) [`1125087b5`](1125087) Thanks [@kyledurand](https://github.com/kyledurand)! - Removed deprecated additionalNavigation prop on Page Header - [#10164](#10164) [`af9f264b9a`](af9f264) Thanks [@aveline](https://github.com/aveline)! - Renamed `destructive` prop to `tone` for `Button` component - [#10261](#10261) [`abeef7ad0`](abeef7a) Thanks [@kyledurand](https://github.com/kyledurand)! - Replaced `small`, `large`, and `fullScreen` props with `size` prop - [#10206](#10206) [`dad09bde9`](dad09bd) Thanks [@kyledurand](https://github.com/kyledurand)! - Changed `status` prop on `Banner` to `tone` - [#10220](#10220) [`2b0cdb2fbf`](2b0cdb2) Thanks [@kyledurand](https://github.com/kyledurand)! - Changed `color` prop on `Icon` to `tone` - [#10036](#10036) [`359614cf83`](359614c) Thanks [@kyledurand](https://github.com/kyledurand)! - Replaced `borderless` prop with `variant` on TextField Migration: `npx @shopify/polaris-migrator react-rename-component-prop <path> --componentName="TextField" --from="borderless" --to="variant" --newValue="borderless"` - [#10635](#10635) [`340e36e7d`](340e36e) Thanks [@laurkim](https://github.com/laurkim)! - Removed `polarisSummerEditions2023` feature flag from AppProvider context - [#10090](#10090) [`4caed28a77`](4caed28) Thanks [@aveline](https://github.com/aveline)! - Consolidated boolean `Button` props into `variant` prop - [#10041](#10041) [`8f927f7622`](8f927f7) Thanks [@kyledurand](https://github.com/kyledurand)! - Replaced boolean props: `secondary`, `fullWidth`, `oneHalf`, `oneThird` on Layout.Section with `variant` - [#10266](#10266) [`22a51eae2`](22a51ea) Thanks [@kyledurand](https://github.com/kyledurand)! - Renamed `color` prop on Text to `tone` - [#9993](#9993) [`66f5c8df3e`](66f5c8d) Thanks [@gwyneplaine](https://github.com/gwyneplaine)! - Removed Summer Editions experimental styles and code for the following components: `AppProvider`, `Avatar`, `AccountConnection`, `ActionList`, `ActionMenu`, `Autocomplete`, `Badge`, `Banner`, `Breadcrumbs`, `BulkActions`, `Button`, `ButtonGroup`, `CalloutCard`, `Card`, `CheckableButton`, `Checkbox`, `Choice`, `Connected`, `DataTable`, `DatePicker`, `DropZone`, `EmptyState`, `Filters`, `FormLayout`, `Frame`, `FullscreenBar`, `IndexFilters`, `IndexTable`, `InlineError`, `KeyboardKey`, `Labelled`, `Layout`, `LegacyCard`, `LegacyFilters`, `LegacyTabs`, `Link`, `List`, `Listbox`, `MediaCard`, `Modal`, `Navigation`, `OptionList`, `Page`, `PageActions`, `Pagination`, `Popover`, `ProgressBar`, `RadioButton`, `ResourceItem`, `ResourceList`, `Select`, `SettingAction`, `ShadowBevel`, `SkeletonPage`, `SkeletonThumbnail`, `Spinner`, `Tabs`, `Tag`, `Text`, `TextField`, `Thumbnail`, `TooltipOverlay`, `TopBar`, and `VideoThumbnail` - [#10232](#10232) [`eb2c2035c`](eb2c203) Thanks [@laurkim](https://github.com/laurkim)! - Removed `optionRole` prop from `OptionList` component ### Minor Changes - [#10238](#10238) [`b17d23d69`](b17d23d) Thanks [@sam-b-rose](https://github.com/sam-b-rose)! - Add a search field to filter ActionList that have more than 10 items ### Patch Changes - [#10228](#10228) [`e18ca907e`](e18ca90) Thanks [@gwyneplaine](https://github.com/gwyneplaine)! - `Filters` Remove unused disabled states in `FilterPill` - [#10268](#10268) [`dbe3d9ece`](dbe3d9e) Thanks [@laurkim](https://github.com/laurkim)! - Fixed broken focus ring styles on `ResourceItem` component - [#10238](#10238) [`b17d23d69`](b17d23d) Thanks [@sam-b-rose](https://github.com/sam-b-rose)! - Ensure Avatar has no background color if an source prop is passed in to allow for transparent images - [#10230](#10230) [`a573e55d0`](a573e55) Thanks [@gwyneplaine](https://github.com/gwyneplaine)! - `IndexFilter` remove custom `FilterButton` in favor of directly invoking the Polaris `Button` component. - Updated dependencies \[[`86d4040c0`](86d4040)]: - @shopify/polaris-tokens@7.13.0-beta.0 ## @shopify/polaris-tokens@7.13.0-beta.0 ### Minor Changes - [#10382](#10382) [`86d4040c0`](86d4040) Thanks [@laurkim](https://github.com/laurkim)! - Renamed `ThemeVariant` to `Theme` and exposed `Theme` type ## @shopify/stylelint-polaris@14.1.2-beta.0 ### Patch Changes - Updated dependencies \[[`86d4040c0`](86d4040)]: - @shopify/polaris-tokens@7.13.0-beta.0 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
### WHY are these changes introduced? Fixes Shopify#10047 ### WHAT is this pull request doing? - Adds `variant` and `tone` props - Removes `primary`, `outline`, `plain`, `monochrome`, and `primarySuccess` booleans - Updates props on usages of `Button` - Renames `primaryPlain` variant to `tertiary`
WHY are these changes introduced?
Fixes #10047
WHAT is this pull request doing?
variant
andtone
propsprimary
,outline
,plain
,monochrome
, andprimarySuccess
booleansButton
primaryPlain
totertiary
How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
Copy-paste this code in
playground/Playground.tsx
:🎩 checklist
README.md
with documentation changes