Skip to content

Commit

Permalink
feat: add number badge border design tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Oct 6, 2024
1 parent 24b4813 commit 200e34b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .changeset/good-rice-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@utrecht/number-badge-css": minor
"@utrecht/components": minor
"@utrecht/component-library-css": minor
"@utrecht/component-library-react": minor
"@utrecht/component-library-vue": minor
"@utrecht/web-component-library-stencil": minor
---

Add `utrecht.number-badge.border-color` and `utrecht.number-badge.border-width` design tokens.
15 changes: 15 additions & 0 deletions components/number-badge/src/_mixin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
@mixin utrecht-number-badge {
/* Limit size to `max-content`, so the badge will not be stretched out of proportion inside a flexbox */
background-color: var(--utrecht-number-badge-background-color, var(--utrecht-badge-background-color, hsl(0 0% 0%)));
border-color: var(--utrecht-number-badge-border-color, var(--utrecht-badge-border-color));
border-radius: var(--utrecht-number-badge-border-radius, var(--utrecht-badge-border-radius, 0.5ch));
border-style: solid;
border-width: max(
var(--utrecht-number-badge-border-width, var(--utrecht-badge-border-width, 0)),
var(--_utrecht-number-badge-min-border-width, 0)
);
color: var(--utrecht-number-badge-color, var(--utrecht-badge-color, hsl(0 0% 100%)));
display: inline-block;
font-family: var(
Expand All @@ -33,3 +39,12 @@
text-decoration: none; /* no inheritance */
white-space: nowrap;
}

@mixin utrecht-number-badge--media-query-forced-colors {
@media screen and (forced-colors: active) {
/* Warning: there layout difference because of the added 1px border */
--_utrecht-number-badge-min-border-width: 1px;

border-color: currentColor;
}
}
2 changes: 1 addition & 1 deletion components/number-badge/src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

.utrecht-number-badge {
@include utrecht-number-badge;
@include utrecht-badge--media-query-forced-colors;
@include utrecht-number-badge--media-query-forced-colors;
}
24 changes: 22 additions & 2 deletions components/number-badge/src/tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"utrecht": {
"number-badge": {
"background-color": {
"comment": "Default background color for badge components",
"$extensions": {
"nl.nldesignsystem.css.property": {
"syntax": "<color>",
Expand All @@ -13,8 +12,18 @@
},
"type": "color"
},
"border-color": {
"$extensions": {
"nl.nldesignsystem.css.property": {
"syntax": "<color>",
"inherits": true
},
"nl.nldesignsystem.fallback": ["utrecht.badge.border-color"],
"nl.nldesignsystem.figma.supports-token": true
},
"type": "color"
},
"border-radius": {
"comment": "Default corner radius for badge components",
"$extensions": {
"nl.nldesignsystem.css.property": {
"syntax": "<length-percentage>",
Expand All @@ -25,6 +34,17 @@
},
"type": "borderRadius"
},
"border-width": {
"$extensions": {
"nl.nldesignsystem.css.property": {
"syntax": "<length>",
"inherits": true
},
"nl.nldesignsystem.fallback": ["utrecht.badge.border-width"],
"nl.nldesignsystem.figma.supports-token": true
},
"type": "borderWidth"
},
"color": {
"comment": "Default text color for badge components",
"$extensions": {
Expand Down

0 comments on commit 200e34b

Please sign in to comment.