Skip to content

feat: remove color categories#4917

Draft
mimarz wants to merge 41 commits into
mainfrom
feat-remove-color-categories
Draft

feat: remove color categories#4917
mimarz wants to merge 41 commits into
mainfrom
feat-remove-color-categories

Conversation

@mimarz
Copy link
Copy Markdown
Collaborator

@mimarz mimarz commented May 21, 2026

resolves #4934

TODO:

  • Update videos and images in Figma guides with new ones.
  • tokens build still has color-categories as it still works with both. Should we keep for backwards compatability?

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

🦋 Changeset detected

Latest commit: 81a2f0b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@digdir/designsystemet Minor
@digdir/designsystemet-css Minor
@digdir/designsystemet-types Minor
@digdir/designsystemet-react Minor
@digdir/designsystemet-web Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

Preview deployments for this pull request:

storybook - 4. Jun 2026 - 14:24

themebuilder - 4. Jun 2026 - 14:24

www - 4. Jun 2026 - 14:27

Copy link
Copy Markdown
Contributor

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 removes the main/support color category split, flattening custom theme colors into a single record so they sit alongside reserved colors (e.g. neutral). Token files, schema, generators, themebuilder UI, CLI plumbing, and tests are restructured accordingly. A new automigration is introduced to convert legacy colors.main / colors.support configs to the flat shape, and @inquirer/confirm is added to drive the interactive prompt.

Changes:

  • Flatten theme.colors to a single record (no main/support/neutral nesting); regenerate semantic/color/<name>.json per color and drop the semantic/modes/{main,support}-color/* token sets.
  • Add flatten-color-categories automigration plus a checkAutomigrate flow wired into designsystemet tokens create (with --skip-check / --yes); split config validation helpers out of config.ts into a versioned schemas/v1.1/schema.ts and schemas/helpers.ts.
  • Update Themebuilder URL/state model to a single colors query param (with backwards-compat redirect from main/support/neutral) and rework color pane / overrides / previews accordingly.

Reviewed changes

Copilot reviewed 90 out of 95 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/cli/src/migrations/flatten-color-categories.ts New automigration that flattens old main/support/neutral shape.
packages/cli/src/migrations/index.ts Registers the new automigration.
packages/cli/src/automigrate.ts New helper that detects and prompts for eligible migrations.
packages/cli/bin/designsystemet.ts Wires checkAutomigrate, --skip-check/--yes options, switches to colorNames.
packages/cli/bin/config.ts Updates legacy color flags to the flattened structure; uses new schema helpers.
packages/cli/src/schemas/v1.1/schema.ts New v1.1 zod schema with flat colors.
packages/cli/src/schemas/v1/schema.ts Reduced to schema-only (validation helpers extracted).
packages/cli/src/schemas/helpers.ts New validateConfig/parseConfig helpers extracted from config.ts.
packages/cli/src/index.ts Re-export switched to v1.1 schema.
packages/cli/src/scripts/createJsonSchema.ts Imports from v1.1 schema.
packages/cli/src/tokens/types.ts Imports ConfigSchemaTheme from v1.1 schema.
packages/cli/src/tokens/utils.ts Replaces colorNamesByCategory with addSeverityColors / toColorNames.
packages/cli/src/tokens/format.ts Uses toColorNames; passes colorNames into createTokens.
packages/cli/src/tokens/create.ts Accepts colorNames, generates flat semantic/color/<name> sets.
packages/cli/src/tokens/create/files.ts Threads colorNames through file generation.
packages/cli/src/tokens/create/generators/$themes.ts Single Color group instead of Main color/Support color.
packages/cli/src/tokens/create/generators/$metadata.ts Lists flat semantic/color/<name> paths.
packages/cli/src/tokens/create/generators/themes/theme.ts Builds tokens from flat colorNames.
packages/cli/src/tokens/create/generators/semantic/color.ts Emits a per-color TokenSet keyed by color name.
packages/cli/src/tokens/create/generators/semantic/style.ts Inlines former semantic color tokens; restructures style output.
packages/cli/src/tokens/create/generators/semantic/color-modes.ts Removed (no more main/support modes).
packages/cli/src/tokens/create/generators/primitives/color-scheme.ts Generates color scales from flat colors record.
packages/cli/src/tokens/process/platform.ts Adds 'color' to colorGroups.
packages/cli/src/tokens/process/output/declarations.ts Splits severity vs custom colors when emitting .d.ts.
packages/cli/src/tokens/generate-config.ts Replaces categorizeColors with flat extractColors.
packages/cli/src/scripts/update-preview-tokens.ts Updated to new colorNames/flat colors API.
packages/cli/package.json Adds @inquirer/confirm dep and ./schemas/* export.
packages/cli/tests/** Test fixtures regenerated to flat color shape.
packages/css/theme/designsystemet.css Reordered --ds-color-neutral-* and adds new top-level --ds-* vars; drops old data-color="brand1"/"brand2" mapping layers.
packages/react/stories/constants.tsx Reads colors from flat config.
design-tokens/** Token files restructured to flat semantic/color/* and updated $themes.json/$metadata.json.
designsystemet.config.json Migrated to flat colors shape.
apps/themebuilder/** URL state, color pane, overrides, previews, locales updated to the unified colors array (with legacy URL redirect).
pnpm-lock.yaml Adds @inquirer/confirm and bumps node runtime to 24.16.0.
.changeset/*.md Three changesets describing the changes.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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

Comment thread packages/cli/src/migrations/flatten-color-categories.ts
Comment thread packages/cli/src/automigrate.ts Outdated
Comment thread .changeset/twelve-bugs-prove.md Outdated
@mimarz mimarz force-pushed the feat-remove-color-categories branch from a1e90e1 to b98ca06 Compare June 3, 2026 07:31
mimarz and others added 12 commits June 4, 2026 08:25
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@mimarz mimarz force-pushed the feat-remove-color-categories branch from b98ca06 to e4d3d0f Compare June 4, 2026 06:25
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.

Update CLI and Themebuilder to remove color categories

2 participants