Skip to content

feat(ui-scripts,ui-themes): generate theme tokens as css custom properties - #2690

Open
HerrTopi wants to merge 1 commit into
masterfrom
css-themes
Open

feat(ui-scripts,ui-themes): generate theme tokens as css custom properties#2690
HerrTopi wants to merge 1 commit into
masterfrom
css-themes

Conversation

@HerrTopi

Copy link
Copy Markdown
Contributor

Summary

  • Add a buildCSSVariables step to build-themes that flattens each theme's shared tokens and emits one stylesheet per theme under src/themes/newThemeTokens/themesAsCSSVariables/.
  • Emit cssThemesWithMediaQueries.css, mapping the light and dark themes to prefers-color-scheme.
  • Register the malva CSS plugin in dprint.json so the generated stylesheets go through the existing dprint pass.
  • Mark *.css as side-effectful in ui-themes so bundlers don't tree-shake stylesheet imports.

Test Plan

  • Run pnpm run build:themes and check the 5 files under packages/ui-themes/src/themes/newThemeTokens/themesAsCSSVariables/ — the directory is gitignored, so none of the generated CSS appears in this diff.
  • With cssThemesWithMediaQueries.css loaded, toggle the OS colour scheme and confirm the :root values and color-scheme switch.

Open questions for the reviewer

  • The 188 custom properties are unprefixed (--background-*, --spacing-md). The existing style-dictionary emitter uses instui-<theme>. Adding a prefix later is breaking, so this should be settled before release.
  • :root in the media-query file and .light/.dark in the per-theme files are both specificity 0-1-0, so combining them makes source order decide which wins.
  • Composite boxShadow tokens are emitted as per-field vars with no composed value; boxShadowObjectsToCSSString already handles this for JS consumers.

Fixes INSTUI-5153

🤖 Generated with Claude Code

…rties

Add a buildCSSVariables step to build-themes that flattens each theme's shared tokens and
emits one stylesheet per theme under src/themes/newThemeTokens/themesAsCSSVariables/, plus a
cssThemesWithMediaQueries.css that maps the light and dark themes to prefers-color-scheme.

Register the malva plugin in dprint.json so the generated stylesheets are formatted by the
existing dprint pass, and mark *.css as side-effectful in ui-themes so bundlers do not drop
the stylesheet imports.

Also emit SharedTokens as a type-only import in the generated component templates.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@HerrTopi HerrTopi self-assigned this Aug 17, 2026
@HerrTopi
HerrTopi requested a review from matyasf August 17, 2026 14:14
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://instructure.design/pr-preview/pr-2690/

Built to branch gh-pages at 2026-08-17 14:17 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

Copy link
Copy Markdown
Contributor

Visual regression report

⚠️ Changes detected.

Status Count
Unchanged 0
Changed 1
New 96
Removed 32

📊 View full report

Diff images (33)

alert.png — baseline no longer produced

avatar.png — baseline no longer produced

badge.png — baseline no longer produced

billboard.png — baseline no longer produced

breadcrumb.png — baseline no longer produced

button-and-derivatives.png — baseline no longer produced

byline.png — baseline no longer produced

calendar.png — baseline no longer produced

checkbox.png — baseline no longer produced

checkboxgroup.png — baseline no longer produced

colorpicker.png — baseline no longer produced

contextview.png — baseline no longer produced

custom-and-lucide-icons.png — baseline no longer produced

dateinput-dateinput2.png — baseline no longer produced

datetimeinput.png — baseline no longer produced

diff-demo.png — 6324 pixels differ

drilldown.png — baseline no longer produced

filedrop.png — baseline no longer produced

form-errors.png — baseline no longer produced

heading.png — baseline no longer produced

img.png — baseline no longer produced

link.png — baseline no longer produced

menu.png — baseline no longer produced

metric-pill-tag-timeselect-text.png — baseline no longer produced

options.png — baseline no longer produced

pagination.png — baseline no longer produced

progressbar.png — baseline no longer produced

select-simpleselect.png — baseline no longer produced

table.png — baseline no longer produced

tabs.png — baseline no longer produced

tooltip.png — baseline no longer produced

treebrowser.png — baseline no longer produced

view.png — baseline no longer produced

Baselines come from the visual-baselines branch. They refresh on every merge to master.

github-actions Bot pushed a commit that referenced this pull request Aug 17, 2026
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.

1 participant