From 9748b08383c4d11f93a0da72a0ef39a726c96e8b Mon Sep 17 00:00:00 2001 From: Lo Kim Date: Thu, 21 Sep 2023 11:22:12 -0400 Subject: [PATCH] [polaris.shopify.com] Fix preview for color tokens (#10605) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### WHY are these changes introduced? Updates conditional logic to render token preview in TokenList for tokens that don't use `rgba()` as the value. ### WHAT is this pull request doing? Update logic to render token preview for color tokens with `rgba()` or `--p-color` as the value.
Color tokens — before Color tokens — before
Color tokens — after Color tokens — after
### How to 🎩 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) ### 🎩 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) - [ ] 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 --- .changeset/silly-years-search.md | 5 +++++ polaris.shopify.com/src/components/TokenList/TokenList.tsx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/silly-years-search.md diff --git a/.changeset/silly-years-search.md b/.changeset/silly-years-search.md new file mode 100644 index 00000000000..013a6e4abe2 --- /dev/null +++ b/.changeset/silly-years-search.md @@ -0,0 +1,5 @@ +--- +'polaris.shopify.com': patch +--- + +Updated logic for rendering `color` custom property previews in `TokenList` diff --git a/polaris.shopify.com/src/components/TokenList/TokenList.tsx b/polaris.shopify.com/src/components/TokenList/TokenList.tsx index 65878bb082f..fdf435dbf71 100644 --- a/polaris.shopify.com/src/components/TokenList/TokenList.tsx +++ b/polaris.shopify.com/src/components/TokenList/TokenList.tsx @@ -232,7 +232,7 @@ function TokenPreview({name, value}: TokenPreviewProps) { }; // Colors - if (value.startsWith('rgba')) { + if (value.startsWith('rgba') || value.includes('color-')) { return (