Skip to content

fix(storybook): show live computed hex values on Colors page#140

Merged
garrity-miepub merged 3 commits into
mainfrom
update/colors-page
Mar 14, 2026
Merged

fix(storybook): show live computed hex values on Colors page#140
garrity-miepub merged 3 commits into
mainfrom
update/colors-page

Conversation

@garrity-miepub

Copy link
Copy Markdown
Collaborator

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 attributes (class, data-theme, style) and 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
image image image

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
Copilot AI review requested due to automatic review settings March 14, 2026 01:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/components/Colors/Colors.stories.tsx Outdated
Comment thread src/components/Colors/Colors.stories.tsx Outdated
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.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 14, 2026

Copy link
Copy Markdown

Deploying ui with  Cloudflare Pages  Cloudflare Pages

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

View logs

@garrity-miepub garrity-miepub marked this pull request as ready for review March 14, 2026 01:59
Copilot AI review requested due to automatic review settings March 14, 2026 01:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ThemeVersionProvider with shared MutationObservers to trigger recomputation on theme/brand changes.
  • Updates each ColorSwatch to read backgroundColor via getComputedStyle() 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.

Comment thread src/components/Colors/Colors.stories.tsx
Comment thread src/components/Colors/Colors.stories.tsx
Comment thread src/components/Colors/Colors.stories.tsx Outdated
Comment thread src/components/Colors/Colors.stories.tsx Outdated
Comment thread src/components/Colors/Colors.stories.tsx
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
@garrity-miepub garrity-miepub merged commit 6a4a2ee into main Mar 14, 2026
9 of 10 checks passed
@garrity-miepub garrity-miepub deleted the update/colors-page branch March 14, 2026 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants