fix(storybook): show live computed hex values on Colors page#140
Merged
Conversation
The Colors page previously displayed hardcoded BlueHive hex values (e.g. #27aae1 for primary-500) that never changed when switching brands. This was confusing because the color swatch updated but the hex text stayed the same. Changes: - Replace static hex values with live computed values read from getComputedStyle() on the color swatch element - Add MutationObserver watchers on <html> attributes (class, data-theme, style) and <head> children (<style> injection) so hex values update automatically on brand switch or theme toggle - Remove the Tailwind class column (e.g. bg-primary-50) since it implied the color was only for backgrounds — the same scale works with text-*, border-*, ring-*, etc. - Each row now shows: color swatch | name | CSS variable | live hex
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Storybook “Foundations/Colors” page to display the actual (brand/theme-dependent) computed hex value for each CSS variable swatch, rather than a hardcoded default.
Changes:
- Read each swatch’s computed background color via
getComputedStyle()and render the derived hex value. - Auto-refresh displayed hex values on brand/theme changes by observing mutations on
<html>attributes and<head>style injections. - Remove the Tailwind class display from each row (swatch | name | CSS variable | live hex).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses Copilot review comments on PR #140: - Move the 2 MutationObservers (html attributes + head children) from each ColorSwatch instance into a single ThemeVersionProvider at the ColorsPage level. Swatches now consume a shared version counter via React context and recompute their hex value when it bumps. This reduces ~200+ observers down to exactly 2. - Use window.MutationObserver instead of eslint-disable comments to resolve the no-undef lint rule cleanly.
Deploying ui with
|
| Latest commit: |
6df9451
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6b5d1022.ui-6d0.pages.dev |
| Branch Preview URL: | https://update-colors-page.ui-6d0.pages.dev |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Storybook Colors page to display live, computed hex values that reflect the active brand/theme, avoiding confusing hardcoded values.
Changes:
- Adds a
ThemeVersionProviderwith sharedMutationObservers to trigger recomputation on theme/brand changes. - Updates each
ColorSwatchto readbackgroundColorviagetComputedStyle()and render/copy the computed hex value. - Removes the per-row Tailwind class display column.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses 5 new Copilot comments on PR #140: - Debounce MutationObserver callbacks with requestAnimationFrame to coalesce rapid mutations (e.g. multiple style injections during a brand switch) into a single version bump and rerender - Remove unused lightValue, darkValue, and tailwindClass fields from ColorInfo interface and all color data arrays — these were dead data after switching to live computed hex values - Remove the hardcoded dark mode column (darkValue) since it was still showing static values that didn't update on brand switch - Clear computedHex to empty string when backgroundColor can't be parsed (e.g. transparent) to avoid showing stale values - Fix JSX indentation: properly indent children inside ThemeVersionProvider wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Colors page previously displayed hardcoded BlueHive hex values (e.g. #27aae1 for primary-500) that never changed when switching brands. This was confusing because the color swatch updated but the hex text stayed the same.
Changes: