99
1010@use " sass:map" ;
1111
12- $hds-badge-types : (" flat" , " inverted" , " outlined" );
13- $hds-badge-colors-accents : (" highlight" , " success" , " warning" , " critical" );
1412$hds-badge-sizes : (" small" , " medium" , " large" );
15- $hds-badge-border-width : 1px ;
16- $hds-badge-colors-props : (
17- " highlight" : (
18- " inverted-background-color" : var (--token-color-palette-purple-200 ),
19- " outlined-border-color" : var (--token-color-palette-purple-200 ),
20- ),
21- " success" : (
22- " inverted-background-color" : var (--token-color-palette-green-200 ),
23- " outlined-border-color" : var (--token-color-palette-green-200 ),
24- ),
25- " warning" : (
26- " inverted-background-color" : var (--token-color-palette-amber-200 ),
27- " outlined-border-color" : var (--token-color-palette-amber-200 ),
28- ),
29- " critical" : (
30- " inverted-background-color" : var (--token-color-palette-red-200 ),
31- " outlined-border-color" : var (--token-color-palette-red-200 ),
32- ),
33- );
13+ $hds-badge-colors : (" neutral" , " neutral-dark-mode" , " highlight" , " success" , " warning" , " critical" );
14+ $hds-badge-types : (" filled" , " inverted" , " outlined" );
3415
3516.hds-badge {
36- // Redefine color values to increase contrast
37- --token-color-surface-success : var (--token-color-palette-green-100 );
38- --token-color-foreground-success-on-surface : var (--token-color-palette-green-400 );
39- --token-color-surface-warning : var (--token-color-palette-amber-100 );
40- --token-color-foreground-warning-on-surface : var (--token-color-palette-amber-400 );
41- --token-color-surface-critical : var (--token-color-palette-red-100 );
42- --token-color-foreground-critical-on-surface : var (--token-color-palette-red-400 );
43- --token-color-surface-highlight : var (--token-color-palette-purple-100 );
44- --token-color-foreground-highlight-on-surface : var (--token-color-palette-purple-400 );
45-
4617 display : inline-flex ;
4718 align-items : center ;
4819 max-width : 100% ;
4920 vertical-align : middle ;
50- border : $hds-badge-border-width solid transparent ;
51- border-radius : var (--token-border-radius-small );
21+ border : var (--token-badge-border-width ) solid transparent ;
5222}
5323
5424.hds-badge__icon {
@@ -64,116 +34,39 @@ $hds-badge-colors-props: (
6434
6535// SIZE
6636
67- // these values later may come from the design tokens
68- $hds-badge-size-props : (
69- " small" : (
70- // 13px = 0.8125rem
71- " font-size" : 0.8125rem ,
72- " gap" : 0.25rem ,
73- " height" : 1.25rem ,
74- " icon-size" : 0.75rem ,
75- // 16px = 1.2308
76- " line-height" : 1.2308 ,
77- " padding-vertical" : 0.125rem ,
78- " padding-horizontal" : 0.375rem ,
79- ),
80- " medium" : (
81- // 13px = 0.8125rem
82- " font-size" : 0.8125rem ,
83- " gap" : 0.25rem ,
84- " height" : 1.5rem ,
85- " icon-size" : 1rem ,
86- // 16px = 1.2308
87- " line-height" : 1.2308 ,
88- " padding-vertical" : 0.25rem ,
89- " padding-horizontal" : 0.5rem ,
90- ),
91- " large" : (
92- // 16px = 1rem
93- " font-size" : 1rem ,
94- " gap" : 0.375rem ,
95- " height" : 2rem ,
96- " icon-size" : 1rem ,
97- // 24px = 1.5
98- " line-height" : 1.5 ,
99- " padding-vertical" : 0.25rem ,
100- " padding-horizontal" : 0.5rem ,
101- ),
102- );
103-
10437@each $size in $hds-badge-sizes {
10538 .hds-badge--size-#{$size } {
106- gap : map .get ($hds-badge-size-props , $size , " gap" );
107- min-height : map .get ($hds-badge-size-props , $size , " height" );
108- padding : calc (#{map .get ($hds-badge-size-props , $size , " padding-vertical" )} - #{$hds-badge-border-width } )
109- calc (#{map .get ($hds-badge-size-props , $size , " padding-horizontal" )} - #{$hds-badge-border-width } );
39+ gap : var (--token-badge-gap - #{$size } );
40+ min-height : var (--token-badge-height - #{$size } );
41+ padding : calc (var (--token-badge-padding-vertical - #{$size } ) - var (--token-badge-border-width ))
42+ calc (var (--token-badge-padding-horizontal - #{$size } ) - var (--token-badge-border-width ));
43+ border-radius : var (--token-badge-border-radius - #{$size } );
11044
11145 .hds-badge__icon {
112- width : map . get ( $hds- badge-size-props , $size , " icon-size " );
113- height : map . get ( $hds- badge-size-props , $size , " icon-size " );
46+ width : var ( --token- badge-icon- size- #{ $size } );
47+ height : var ( --token- badge-icon- size- #{ $size } );
11448 }
11549
11650 .hds-badge__text {
117- font-size : map . get ( $hds- badge-size-props , $size , " font-size " );
118- line-height : map . get ( $hds-badge-size-props , $size , " line-height" );
51+ font-size : var ( --token- badge-font- size- #{ $size } );
52+ line-height : var ( --token-badge- line-height- #{ $size } );
11953 }
12054 }
12155}
12256
12357// COLOR + TYPE COMBINATIONS
12458
125- .hds-badge--color-neutral {
126- & .hds-badge--type-filled {
127- color : var (--token-color-foreground-primary );
128- background-color : var (--token-color-palette-neutral-200 );
129- }
130-
131- & .hds-badge--type-inverted {
132- color : var (--token-color-foreground-high-contrast );
133- background-color : var (--token-color-palette-neutral-500 );
134- }
135-
136- & .hds-badge--type-outlined {
137- color : var (--token-color-foreground-primary );
138- background-color : transparent ;
139- border-color : var (--token-color-palette-neutral-500 );
140- }
141- }
142-
143- .hds-badge--color-neutral-dark-mode {
144- & .hds-badge--type-filled {
145- color : var (--token-color-foreground-high-contrast );
146- background-color : var (--token-color-palette-neutral-500 );
147- }
148-
149- & .hds-badge--type-inverted {
150- color : var (--token-color-foreground-primary );
151- background-color : var (--token-color-surface-faint );
152- }
153-
154- & .hds-badge--type-outlined {
155- color : var (--token-color-foreground-high-contrast );
156- background-color : transparent ;
157- border-color : var (--token-color-palette-neutral-50 );
158- }
159- }
160-
161- @each $color in $hds-badge-colors-accents {
59+ @each $color in $hds-badge-colors {
16260 .hds-badge--color-#{$color } {
163- & .hds-badge--type-filled {
164- color : var (--token-color-foreground - #{$color } - on-surface );
165- background-color : var (--token-color-surface - #{$color } );
166- }
167-
168- & .hds-badge--type-inverted {
169- color : var (--token-color-foreground-high-contrast );
170- background-color : map .get ($hds-badge-colors-props , $color , " inverted-background-color" );
171- }
172-
173- & .hds-badge--type-outlined {
174- color : var (--token-color-foreground - #{$color } );
175- background-color : transparent ;
176- border-color : map .get ($hds-badge-colors-props , $color , " outlined-border-color" );
61+ @each $type in $hds-badge-types {
62+ & .hds-badge--type-#{$type } {
63+ color : var (--token-badge-foreground-color - #{$color } - #{$type } );
64+ background-color : var (--token-badge-surface-color - #{$color } - #{$type } );
65+
66+ @if $type == " outlined" {
67+ border-color : var (--token-badge-border-color - #{$color } - #{$type } );
68+ }
69+ }
17770 }
17871 }
17972}
0 commit comments