-
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] Fix buttonFrom
not mapping ComplexAction
boolean properties to variant
and tone
#11028
Conversation
overrides?: Partial<ButtonProps>, | ||
key?: any, | ||
) { | ||
const variant = !overrides?.variant && plain ? 'plain' : overrides?.variant; | ||
const tone = !overrides?.tone && destructive ? 'critical' : overrides?.tone; |
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.
Does this still cause TS errors though?
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.
No, because the Button gets the correct props set. The buttonFrom
API doesn't need to change, the bug where variant and tone weren't set when the action was configured with properties that should map variant and tone is all that needed to be fixed. So any Action
ish typed objects implemented in Polaris and Web can remain as they're typed and the buttons will be correct with this patch.
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.
Makes sense! We'll still need to, at some point, allow these actions to set tone and variant I think but this is a solid fix for now. That global types file is 🤯
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'll creat an issue for deprecating the old booleans on the Action types and adding tone and variant support so we can remove the old boolean properties in v13 💯
23f792d
to
af7de62
Compare
69b0cd9
to
5ea0372
Compare
5ea0372
to
a5dfae0
Compare
3db575a
to
c11413c
Compare
@@ -80,8 +80,7 @@ | |||
// We set the border-color to transparent here | |||
// in order for the background color to bleed all the way to the edge of the element. | |||
border-color: transparent; | |||
// stylelint-disable-next-line polaris/color/function-disallowed-list -- set background color | |||
background-color: rgba(0, 0, 0, 0.08); | |||
background-color: var(--p-color-checkbox-bg-surface-disabled); |
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 token has the equivalent value of rgba(0, 0, 0, 0.08)
)
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-migrator@0.26.1 ### Patch Changes - Updated dependencies \[[`f1d256fce`](f1d256f)]: - @shopify/polaris-tokens@8.0.1 - @shopify/stylelint-polaris@15.0.1 ## @shopify/polaris@12.0.1 ### Patch Changes - [#10792](#10792) [`2980e9d26`](2980e9d) Thanks [@SMAKSS](https://github.com/SMAKSS)! - Fixed typos and `editOnGithubUrl` in docs - [#10960](#10960) [`d7e4aa7f9`](d7e4aa7) Thanks [@oksanashopify](https://github.com/oksanashopify)! - fixed background-color for unselectable tabel first-child cell - [#10975](#10975) [`00952a33a`](00952a3) Thanks [@kyledurand](https://github.com/kyledurand)! - Fixed loading button spinner color - [#10935](#10935) [`8568e5141`](8568e51) Thanks [@gazjones00](https://github.com/gazjones00)! - Fixed an issue with the `primary` variant styles conflicting with the `tertiary` variant in `Button` - [#10934](#10934) [`de419ba2b`](de419ba) Thanks [@gazjones00](https://github.com/gazjones00)! - Fixed disabled state for `monochromePlain` variant in `Button` - [#10993](#10993) [`fb508b91c`](fb508b9) Thanks [@FCalabria](https://github.com/FCalabria)! - Fixed incompatible type between IndexTable and useIndexResourceState - [#10998](#10998) [`bb310cd3a`](bb310cd) Thanks [@alisterdev](https://github.com/alisterdev)! - Update SkeletonThumbnail size values to correspond to Thumbnail - [#10999](#10999) [`e34a4db32`](e34a4db) Thanks [@kyledurand](https://github.com/kyledurand)! - Updated `Checkbox` icon to use tokens vs hard coded value - [#10910](#10910) [`65998488f`](6599848) Thanks [@chloerice](https://github.com/chloerice)! - Fixed negative margin of `segmented` `ButtonGroup.Item` when child `Button` is `primary` - [#11028](#11028) [`9fb367afd`](9fb367a) Thanks [@chloerice](https://github.com/chloerice)! - Fixed `buttonFrom` utility function not mapping boolean variant properties to `variant` and `tone` - Updated dependencies \[[`f1d256fce`](f1d256f)]: - @shopify/polaris-tokens@8.0.1 ## @shopify/polaris-tokens@8.0.1 ### Patch Changes - [#10976](#10976) [`f1d256fce`](f1d256f) Thanks [@sarahill](https://github.com/sarahill)! - Added descriptions to color tokens ## @shopify/stylelint-polaris@15.0.1 ### Patch Changes - Updated dependencies \[[`f1d256fce`](f1d256f)]: - @shopify/polaris-tokens@8.0.1 ## polaris.shopify.com@0.59.0 ### Minor Changes - [#11030](#11030) [`f55a84ce7`](f55a84c) Thanks [@lgriffee](https://github.com/lgriffee)! - Update stylelint-polaris version matchups chart ### Patch Changes - [#10792](#10792) [`2980e9d26`](2980e9d) Thanks [@SMAKSS](https://github.com/SMAKSS)! - Fixed typos and `editOnGithubUrl` in docs - [#10974](#10974) [`2b3b61069`](2b3b610) Thanks [@sam-b-rose](https://github.com/sam-b-rose)! - Removed autoplay from all videos on Motion design guidance pages - [#10925](#10925) [`4590fd828`](4590fd8) Thanks [@MohammedEsafi](https://github.com/MohammedEsafi)! - Improved the visibility of shadows in Dark Mode for token previews - Updated dependencies \[[`2980e9d26`](2980e9d), [`d7e4aa7f9`](d7e4aa7), [`00952a33a`](00952a3), [`8568e5141`](8568e51), [`de419ba2b`](de419ba), [`fb508b91c`](fb508b9), [`bb310cd3a`](bb310cd), [`e34a4db32`](e34a4db), [`f1d256fce`](f1d256f), [`65998488f`](6599848), [`9fb367afd`](9fb367a)]: - @shopify/polaris@12.0.1 - @shopify/polaris-tokens@8.0.1 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
buttonFrom
not mapping ComplexAction
boolean properties to variant
and tone
### WHY are these changes introduced? To prevent type errors from slipping through as Button API undergoes continued alignment, the `buttonFrom` utility needs tests. Right now in v12 the Button boolean props no longer exist as they were replaced with `variant` and `tone`, but `Action` and its extended types still support `destructive`, `plain`, etc. `buttonFrom` takes a `ComplexAction` as its first param and a `Partial<ButtonProps>` object as an optional second param. The utility was not mapping the action boolean properties to `variant` and `tone` as expected (fixed in #11028). This went uncaught because there were no tests and no stories rendering button variants created with the utility (like Modal's `primaryAction`). ### WHAT is this pull request doing? This PR adds tests for `buttonFrom` and `buttonsFrom`.
<!-- ☝️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 --> ### WHY are these changes introduced? Fixes Shopify#10995 Fixes Shopify#11006 <!-- Context about the problem that’s being addressed. --> ### WHAT is this pull request doing? Fixes the `buttonFrom` util not mapping the action parameter's boolean variant properties to `variant` and `tone`. | Before | [After]() | |--------|--------| | <img width="665" alt="Screenshot 2023-10-25 at 4 03 52 PM" src="https://github.com/Shopify/polaris/assets/18447883/a3dfa184-c0ce-465c-97ea-32e5f6cfff86">| <img width="671" alt="Screenshot 2023-10-25 at 4 02 41 PM" src="https://github.com/Shopify/polaris/assets/18447883/1b85d1ed-4804-4776-a168-a551ff298102">| ### 🎩 checklist - [ ] 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) - [ ] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [x] Updated the component's `README.md` with documentation changes - [x] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
### WHY are these changes introduced? To prevent type errors from slipping through as Button API undergoes continued alignment, the `buttonFrom` utility needs tests. Right now in v12 the Button boolean props no longer exist as they were replaced with `variant` and `tone`, but `Action` and its extended types still support `destructive`, `plain`, etc. `buttonFrom` takes a `ComplexAction` as its first param and a `Partial<ButtonProps>` object as an optional second param. The utility was not mapping the action boolean properties to `variant` and `tone` as expected (fixed in Shopify#11028). This went uncaught because there were no tests and no stories rendering button variants created with the utility (like Modal's `primaryAction`). ### WHAT is this pull request doing? This PR adds tests for `buttonFrom` and `buttonsFrom`.
WHY are these changes introduced?
Fixes #10995
Fixes #11006
WHAT is this pull request doing?
Fixes the
buttonFrom
util not mapping the action parameter's boolean variant properties tovariant
andtone
.🎩 checklist
README.md
with documentation changes