Skip to content

Overhaul Color Tokens Setup w/ Extended Button#373

Merged
PauloMFJ merged 6 commits into
datacommonsorg:mainfrom
madebypxlp:paulo/color-tokens-overhaul
Jun 23, 2026
Merged

Overhaul Color Tokens Setup w/ Extended Button#373
PauloMFJ merged 6 commits into
datacommonsorg:mainfrom
madebypxlp:paulo/color-tokens-overhaul

Conversation

@PauloMFJ

@PauloMFJ PauloMFJ commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Overview

Reworks the design-token system into a clear two-layer model and rebuilds the Button's color API on top of it.

Tokens (packages/tokens)

  • Two layers: generic roles (accent, surface, content, shadow, …) hold the real values; component-scoped sets (button-, card-, control-, atlas-, query-, radio-, …) alias them via "$role". Components reference only their own scope's tokens — nothing borrows generics or sibling scopes directly (one deliberate exception: the button control / card-action tones).
  • Value forms: RGB triplet [r,g,b], triplet + alpha [r,g,b,a] (emitted as r g b / a), or "$alias".
  • Generator fixes: COLORS (TS) export now carries alpha in the same r g b / a form as the CSS vars; removed a channel-array mutation bug; alpha 0 no longer rejected.
  • One-off values are inlined in their component token rather than added to the global palette; pruned dead tokens.

Button

  • New API: variant (flat | border) + tone (subtle, subtle-highlight, prominent, accent, accent-subtle, control, card-action).
  • Each tone is a self-contained token set (base / content / border + hovers) — retune one tone without affecting others.
  • Explicit per-tone border / border-hover channels (the 5 standalone tones; control / card-action excluded).
  • Disabled state is derived from the active tone (dropped the separate disabled-style prop).

Docs

  • AGENTS.md updated to document the role/scope layering, value forms (incl. alpha + $alias), and the one-off-inline rule.

Build

  • Generated token output (packages/tokens/dist/) is no longer committed — added
    packages/tokens/.gitignore (dist/) and a root prepare script
    (pnpm run generate:tokens) so it's regenerated on install / build.

New Buttons

Prompt and Status buttons before / after:

image image

Export button before / after:

image image

Everything else matches existing existing styles visually.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the design tokens and the Button component to enforce a strict semantic color system with component-scoped aliases. The Button component now uses predefined variant and tone props instead of inline color schemes. Two critical issues were identified in the review: a self-referential "transparent" alias in colors.json that causes infinite recursion during the build process, and a missing aria-label on an icon-only Button in control.tsx that leads to a TypeScript compilation error.

Comment thread dataweaver/packages/tokens/src/colors.json Outdated

@nick-nlb nick-nlb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks Paolo! The refactoring of the theme looks great (as does the reworking of the button variants).. I like the separation of token layers the overall refactor introduces.

One comment to address but approved.

for (const name of Object.keys(COLOR_MAP)) {
const constName = name.includes('-') ? `'${name}'` : name;
lines.push(` ${constName}: '${values.join(', ')}',`);
lines.push(` ${constName}: '${toCssChannels(resolveChannels(name))}',`);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Differently to the CSS version, this one resolves to the actual color rather than the name. So where the CSS file has:
` ``
--color-atlas-surface: var(--color-surface);

The TS file has 

'atlas-surface': '247 252 255',


This means that if the partner overrides --color-surface, it will affect only CSS/SCSS but not the TS versions. Let's make this resolve to the variable in the same way.
 

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated TS to resolve with shared consts for any inline values - let me know if this wasn't what you were intending?

@PauloMFJ PauloMFJ merged commit 6c8cbd4 into datacommonsorg:main Jun 23, 2026
8 checks passed
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