Skip to content

refactor: simplify tokens exposure#1161

Merged
thorbrink merged 40 commits intomain-1.xfrom
refactor/simplify-tokens-create
Mar 31, 2026
Merged

refactor: simplify tokens exposure#1161
thorbrink merged 40 commits intomain-1.xfrom
refactor/simplify-tokens-create

Conversation

@thorbrink
Copy link
Copy Markdown
Contributor

No description provided.

@thorbrink thorbrink requested a review from Copilot March 31, 2026 10:27
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Sass token system by removing “extras”/remapping support from tokens.create() and migrating previously-derived token aliases into explicit component-level CSS custom properties.

Changes:

  • Simplifies tokens.create() to accept only (prefix, tokens) by removing the $extras and $inner parameters.
  • Updates many components/utilities to define derived/alias tokens as --{component}--* custom properties in their selectors and switches usages to var(--{component}--*).
  • Updates documentation and adds an internal automation skill doc for performing this migration.

Reviewed changes

Copilot reviewed 42 out of 42 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
source/utilities/preloader/style.scss Moves shimmer-related “extras” to component-scoped CSS variables.
source/sass/object/_minimal-slider.scss Moves slides-visible extra to a component-scoped CSS variable.
source/sass/mixin/_tokens.scss Removes $extras and $inner support from tokens.create().
source/components/typography/style.scss Replaces extras-derived typography aliases with component-scoped CSS variables and updates consumers to var().
source/components/tooltip/style.scss Moves tooltip alias tokens (color/border-width) into component-scoped CSS variables.
source/components/table/style.scss Moves computed border token into component-scoped CSS variable.
source/components/slider/style.scss Moves multiple computed slider tokens into component-scoped CSS variables.
source/components/sidebar/style.scss Moves width/base extras into component-scoped CSS variables.
source/components/select/style.scss Moves button font-size extras into component-scoped CSS variables.
source/components/segment/style.scss Moves image border-radius/min-height extras into component-scoped CSS variables.
source/components/paper/style.scss Moves border/padding/bg/color extras into component-scoped CSS variables.
source/components/option/style.scss Moves option sizing/disabled color extras into component-scoped CSS variables.
source/components/notice/style.scss Moves shadow/border extras into component-scoped CSS variables.
source/components/newsitem/style.scss Moves border extra into component-scoped CSS variable.
source/components/nav/style.scss Moves nav sizing/colors/shadow extras into component-scoped CSS variables.
source/components/modal/style.scss Moves modal padding/multiplier extras into component-scoped CSS variables.
source/components/megamenu/style.scss Moves title font-size extra into component-scoped CSS variable.
source/components/image/style.scss Moves image typography/border extras into component-scoped CSS variables.
source/components/iconsection/style.scss Moves shadow extra into component-scoped CSS variable.
source/components/icon/style.scss Moves icon sizes into component-scoped CSS variables and updates size resolution.
source/components/hero/style.scss Moves hero overlay/sizing/shadow extras into component-scoped CSS variables.
source/components/header/style.scss Moves header sizing/colors/border color extras into component-scoped CSS variables.
source/components/group/style.scss Moves group gap/fluid width extras into component-scoped CSS variables.
source/components/gallery/style.scss Moves gallery gap/column-min extras into component-scoped CSS variables.
source/components/gallery--modal/style.scss Moves alpha-solid derived token into component-scoped CSS variable.
source/components/footer/style.scss Moves footer layout/color config extras into component-scoped CSS variables.
source/components/fileinput/style.scss Moves border/shadow extras into component-scoped CSS variables.
source/components/field/style.scss Moves field sizing/border/bg/shadow extras into component-scoped CSS variables.
source/components/fab/style.scss Moves fab border extra into component-scoped CSS variable.
source/components/drawer/style.scss Moves drawer shadow/transition-ms extras into component-scoped CSS variables; adds overlay transition var.
source/components/datebadge/style.scss Moves datebadge border extra into component-scoped CSS variable.
source/components/collection/style.scss Moves collection padding extras into component-scoped CSS variables.
source/components/code/style.scss Moves code border extra into component-scoped CSS variable.
source/components/card/style.scss Moves card shadow/border/image-bg extras into component-scoped CSS variables.
source/components/button/style.scss Moves button typography/colors/shadow extras into component-scoped CSS variables and uses them in size map.
source/components/brand/style.scss Moves brand sizing/color extras into component-scoped CSS variables.
source/components/box/style.scss Moves box shadow extras into component-scoped CSS variables.
source/components/block/style.scss Moves block shadow/radius/overlay color extras into component-scoped CSS variables.
source/components/accordion/style.scss Moves accordion border extra into component-scoped CSS variable.
source/components/acceptance/style.scss Moves acceptance shadow/map-image extras into component-scoped CSS variables.
README.md Removes documentation claiming tokens.create() supports extras/remapping.
.claude/skills/remove-tokens-extras/SKILL.md Adds an internal skill doc describing how to perform the migration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +9 to +19
--#{$_}--shadow: tokens.use($_, "shadow", 1);
--#{$_}--shadow-hover: tokens.use($_, "shadow", 2);
--#{$_}--radius: tokens.use($_, "border-radius", 1);
--#{$_}--color-text: tokens.get($_, "color--alpha-contrast");
--#{$_}--color-background: tokens.get($_, "color--alpha");
--#{$_}--color-overlay: rgb(from tokens.get($_, "color--alpha") r g b / 1);
--#{$_}--color-overlay-middle: rgba(from tokens.get($_, "color--alpha") r g b / .5);
--#{$_}--color-overlay-end: rgba(from tokens.get($_, "color--alpha") r g b / 0);
--#{$_}--color-secondary: tokens.get($_, "color--secondary");
--#{$_}--color-hover-background: tokens.get($_, "color--alpha-border");
--#{$_}--color-hover-overlay: tokens.get($_, "color--alpha-border");
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

The values assigned to these new component-scoped custom properties use Sass functions (tokens.use/tokens.get) but aren’t interpolated. In Sass, custom property values are treated as plain CSS, so these tokens.* calls can be emitted literally instead of being evaluated, which would break the generated CSS. Interpolate the function results (and any nested tokens.get calls inside rgb/rgba) when assigning to --c-block--* variables.

Suggested change
--#{$_}--shadow: tokens.use($_, "shadow", 1);
--#{$_}--shadow-hover: tokens.use($_, "shadow", 2);
--#{$_}--radius: tokens.use($_, "border-radius", 1);
--#{$_}--color-text: tokens.get($_, "color--alpha-contrast");
--#{$_}--color-background: tokens.get($_, "color--alpha");
--#{$_}--color-overlay: rgb(from tokens.get($_, "color--alpha") r g b / 1);
--#{$_}--color-overlay-middle: rgba(from tokens.get($_, "color--alpha") r g b / .5);
--#{$_}--color-overlay-end: rgba(from tokens.get($_, "color--alpha") r g b / 0);
--#{$_}--color-secondary: tokens.get($_, "color--secondary");
--#{$_}--color-hover-background: tokens.get($_, "color--alpha-border");
--#{$_}--color-hover-overlay: tokens.get($_, "color--alpha-border");
--#{$_}--shadow: #{tokens.use($_, "shadow", 1)};
--#{$_}--shadow-hover: #{tokens.use($_, "shadow", 2)};
--#{$_}--radius: #{tokens.use($_, "border-radius", 1)};
--#{$_}--color-text: #{tokens.get($_, "color--alpha-contrast")};
--#{$_}--color-background: #{tokens.get($_, "color--alpha")};
--#{$_}--color-overlay: rgb(from #{tokens.get($_, "color--alpha")} r g b / 1);
--#{$_}--color-overlay-middle: rgba(from #{tokens.get($_, "color--alpha")} r g b / .5);
--#{$_}--color-overlay-end: rgba(from #{tokens.get($_, "color--alpha")} r g b / 0);
--#{$_}--color-secondary: #{tokens.get($_, "color--secondary")};
--#{$_}--color-hover-background: #{tokens.get($_, "color--alpha-border")};
--#{$_}--color-hover-overlay: #{tokens.get($_, "color--alpha-border")};

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +9
--#{$_}--shadow: tokens.use($_, "shadow", 1);
--#{$_}--shadow-hover: tokens.use($_, "shadow", 1.5);
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

These new CSS custom properties assign Sass function calls (tokens.use) without interpolation. To ensure Sass evaluates the tokens.* calls rather than outputting them literally, interpolate the values when setting --c-acceptance--shadow and --c-acceptance--shadow-hover.

Suggested change
--#{$_}--shadow: tokens.use($_, "shadow", 1);
--#{$_}--shadow-hover: tokens.use($_, "shadow", 1.5);
--#{$_}--shadow: #{tokens.use($_, "shadow", 1)};
--#{$_}--shadow-hover: #{tokens.use($_, "shadow", 1.5)};

Copilot uses AI. Check for mistakes.

/* Component */
.#{$_} {
--#{$_}--border: tokens.use($_, "border-width", 1) solid tokens.get($_, "color--surface-border");
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

The new --c-accordion--border custom property value contains Sass function calls (tokens.use/tokens.get) but isn’t interpolated. Sass may treat custom property values as plain CSS and emit the tokens.* calls literally; interpolate the value so it compiles to a valid CSS expression.

Suggested change
--#{$_}--border: tokens.use($_, "border-width", 1) solid tokens.get($_, "color--surface-border");
--#{$_}--border: #{tokens.use($_, "border-width", 1)} solid #{tokens.get($_, "color--surface-border")};

Copilot uses AI. Check for mistakes.

/* Component */
.#{$_} {
--#{$_}--logotype-height: tokens.use($_, "base", 6);
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

--c-header--logotype-height is being assigned the result of tokens.use(...) without interpolation. Interpolate this value so Sass evaluates tokens.use(...) and the computed height isn’t emitted as a literal function call in the final CSS.

Suggested change
--#{$_}--logotype-height: tokens.use($_, "base", 6);
--#{$_}--logotype-height: #{tokens.use($_, "base", 6)};

Copilot uses AI. Check for mistakes.
--#{$_}--border: #{tokens.use($_, "border-width", 1)} solid #{tokens.get($_, "color--surface-border")};
--#{$_}--background-color: #{tokens.get($_, "color--surface-alt")};
--#{$_}--contrast-color: #{tokens.get($_, "color--surface-contrast")};
--#{$_}--height: tokens.use($_, "base", 6);
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

--c-field--height is assigned using tokens.use(...) without interpolation. Since this value feeds into var(--c-field--height) and --c-field--height-computed, ensure tokens.use(...) is interpolated so it compiles to a valid CSS calc() rather than being output literally.

Suggested change
--#{$_}--height: tokens.use($_, "base", 6);
--#{$_}--height: #{tokens.use($_, "base", 6)};

Copilot uses AI. Check for mistakes.
@include tokens.create($_, getComponentTokens($_));

.#{$_} {
--#{$_}--border: 1px solid tokens.get($_, "color--surface-border");
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

--c-code--border currently includes a literal tokens.get(...) call without interpolation, which can be emitted as-is into CSS. Interpolate the tokens.get(...) result so the custom property resolves to the intended var(--c-code--color--surface-border) reference.

Suggested change
--#{$_}--border: 1px solid tokens.get($_, "color--surface-border");
--#{$_}--border: 1px solid #{tokens.get($_, "color--surface-border")};

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +19
--#{$_}--line-height-caption: tokens.get($_, "line-height-base");
--#{$_}--font-weight-bold: tokens.get($_, "font-weight-bold");
--#{$_}--font-family-bold: tokens.get($_, "font-family-bold");
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

These new custom properties use tokens.get(...) without interpolation (unlike the other token-based custom properties in this block). Interpolate tokens.get(...) here as well so Sass evaluates the function calls when generating the CSS for --c-image--line-height-caption / --c-image--font-weight-bold / --c-image--font-family-bold.

Suggested change
--#{$_}--line-height-caption: tokens.get($_, "line-height-base");
--#{$_}--font-weight-bold: tokens.get($_, "font-weight-bold");
--#{$_}--font-family-bold: tokens.get($_, "font-family-bold");
--#{$_}--line-height-caption: #{tokens.get($_, "line-height-base")};
--#{$_}--font-weight-bold: #{tokens.get($_, "font-weight-bold")};
--#{$_}--font-family-bold: #{tokens.get($_, "font-family-bold")};

Copilot uses AI. Check for mistakes.
Comment on lines 62 to 67
@each $size in $sizes {
&.#{$_}--size-#{$size} {
$icon-size: var(--c-icon-size, #{tokens.get($_, "size-#{$size}")});
$icon-size: var(--c-icon-size, var(--#{$_}--size-#{$size}));
font-size: $icon-size;

&::after {
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

Indentation inside the size modifier block is inconsistent (e.g., font-size: $icon-size; and the following &::after block are misaligned relative to the surrounding nesting). This makes the nesting structure hard to read and easy to mis-edit; please re-indent this block to match the rest of the file’s formatting.

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +29
.#{$_} {
--#{$_}--font-size-caption: #{calc(tokens.get($_, "base-font-size")*pow(tokens.get($_, "font-size-scale-ratio"), -1))};
--#{$_}--font-size-meta: #{tokens.get($_, "font-size-90")};
--#{$_}--font-size-subtitle: #{tokens.get($_, "font-size-400")};
--#{$_}--font-size-title: #{tokens.get($_, "font-size-500")};
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

These derived --c-typography--* custom properties are declared only on .c-typography, but the file also styles plain h1h6 elements using var(--c-typography--… ) with no fallback. Any heading that doesn’t carry (or inherit from an ancestor with) the .c-typography class will end up with invalid font-size/weight/line-height. Consider emitting these derived vars at :root (or add a :root block in addition to .c-typography) or add explicit fallbacks in the var(--c-typography--…) references; there are existing headings without .c-typography in the repo (e.g. source/components/code/examples/html.blade.php:4).

Copilot uses AI. Check for mistakes.
@thorbrink thorbrink merged commit d4d7b79 into main-1.x Mar 31, 2026
5 of 6 checks passed
@thorbrink thorbrink deleted the refactor/simplify-tokens-create branch March 31, 2026 10:38
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