Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove severity colors from default 'data-color' type #3223

Merged
merged 4 commits into from
Feb 26, 2025

Conversation

unekinn
Copy link
Contributor

@unekinn unekinn commented Feb 26, 2025

  • Removes SeverityColors from Color type, and adds SeverityColors explicitly to data-color on the components where we deem severity to be relevant. Button component only gets danger from severity.
  • Removes {} fallback from ColorWithFallback when MainAndSupportColors is not extended.
    • This ensures that e.g.
       'data-color'?: Color | SeverityColors
      becomes string | undefined, and not string | {} | "info" | "success" | "warning" | "danger", as the latter would give autocomplete that suggests only the severity colors are valid choices
    • If MainAndSupportColors is extended with e.g. "accent" and "extra" colors, the type will resolve to "neutral" | "accent" | "info" | "success" | "warning" | "danger" and autocomplete will work

Fixes #3183

Copy link

changeset-bot bot commented Feb 26, 2025

🦋 Changeset detected

Latest commit: 16fc286

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

This PR includes changesets to release 4 packages
Name Type
@digdir/designsystemet-react Minor
@digdir/designsystemet Minor
@digdir/designsystemet-css Minor
@digdir/designsystemet-theme 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

Copy link
Contributor

github-actions bot commented Feb 26, 2025

Preview deployments for this pull request:

Storybook - 26. Feb 2025 - 20:52

Copy link
Contributor

github-actions bot commented Feb 26, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 50.33% 3205 / 6367
🔵 Statements 50.33% 3205 / 6367
🔵 Functions 85.31% 215 / 252
🔵 Branches 77.93% 558 / 716
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/react/src/colors.ts 0% 0% 0% 0%
packages/react/src/components/Badge/Badge.tsx 18.75% 100% 0% 18.75% 47-61
packages/react/src/components/Button/Button.tsx 97.14% 85.71% 100% 97.14% 86
packages/react/src/components/Popover/Popover.tsx 93.23% 72.72% 100% 93.23% 185, 222-223, 226-227, 234-235, 240-241
packages/react/src/components/Tag/Tag.tsx 100% 100% 100% 100%
Generated in workflow #2264 for commit 16fc286 by the Vitest Coverage Report Action

@unekinn unekinn force-pushed the split-severity-from-color-type branch from 01f90fd to aa15a92 Compare February 26, 2025 11:34
@unekinn unekinn marked this pull request as ready for review February 26, 2025 12:16
@mimarz mimarz merged commit 763f55f into next Feb 26, 2025
8 of 11 checks passed
@mimarz mimarz deleted the split-severity-from-color-type branch February 26, 2025 20:08
@github-actions github-actions bot mentioned this pull request Mar 3, 2025
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.

Should severity colors be part of global data-color types?
2 participants