Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Commit 9748b08

Browse files
authored
[polaris.shopify.com] Fix preview for color tokens (#10605)
### 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. <details> <summary>Color tokens — before</summary> <img src="https://github.com/Shopify/polaris/assets/26749317/a2442fa0-87e9-44a5-afe7-b6962089d879" alt="Color tokens — before"> </details> <details> <summary>Color tokens — after</summary> <img src="https://github.com/Shopify/polaris/assets/26749317/98827dc6-1340-4c35-938e-16a671a0bad2" alt="Color tokens — after"> </details> <!-- ℹ️ Delete the following for small / trivial changes --> ### 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
1 parent 7db26ac commit 9748b08

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/silly-years-search.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'polaris.shopify.com': patch
3+
---
4+
5+
Updated logic for rendering `color` custom property previews in `TokenList`

polaris.shopify.com/src/components/TokenList/TokenList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ function TokenPreview({name, value}: TokenPreviewProps) {
232232
};
233233

234234
// Colors
235-
if (value.startsWith('rgba')) {
235+
if (value.startsWith('rgba') || value.includes('color-')) {
236236
return (
237237
<div
238238
{...previewDivAttributes}

0 commit comments

Comments
 (0)