Skip to content

Commit 8ec9e0f

Browse files
author
Sebastian Thulin
committed
fix: prepare for inheriot colors & use alt in fields
1 parent 86eb284 commit 8ec9e0f

3 files changed

Lines changed: 29 additions & 24 deletions

File tree

component-design-tokens.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@
554554
"color--danger",
555555
"color--success",
556556
"color--surface",
557+
"color--surface-alt",
557558
"color--surface-border",
558559
"shadow-color",
559560
"shadow-amount",

source/components/field/component.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"color--danger",
1111
"color--success",
1212
"color--surface",
13+
"color--surface-alt",
1314
"color--surface-border",
1415
"shadow-color",
1516
"shadow-amount",

source/components/field/style.scss

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22
@use "../../sass/mixin/focus";
33
@use "../../sass/mixin/tokens";
44

5+
/* Inheritance properties */
6+
@property --inherit-color-background {
7+
syntax: "*";
8+
inherits: false;
9+
}
10+
511
/* Component name */
612
$_: "c-field";
713

814
/* Design tokens */
9-
@include tokens.create($_, getComponentTokens($_), (
10-
"base": "var(--base)",
11-
"border": tokens.use($_, "border-width", 1) solid tokens.get($_, "color--surface-border"),
12-
"background-color": tokens.get($_, "color--surface"),
13-
"height": "calc(var(--base) * 6)",
14-
"shadow": tokens.use($_, "shadow", 1),
15-
"shadow-hover": tokens.use($_, "shadow", 1.5)
16-
));
15+
@include tokens.create($_, getComponentTokens($_), ("base": "var(--base)",
16+
"border": tokens.use($_, "border-width", 1) solid tokens.get($_, "color--surface-border"),
17+
"background-color": tokens.get($_, "color--surface-alt"),
18+
"contrast-color": tokens.get($_, "color--surface-contrast"),
19+
"height": "calc(var(--base) * 6)",
20+
"shadow": tokens.use($_, "shadow", 1),
21+
"shadow-hover": tokens.use($_, "shadow", 1.5)));
1722

18-
$fields: "input, input[type="color"], input[type="text"], input[type="search"], input[type="tel"], input[type="time"], input[type="date"], input[type="datetime-local"], input[type="url"], input[type="week"], input[type="month"], input[type="number"], input[type="password"], input[type="email"], [data-js-select-action-overlay]";
23+
$fields: "input, input[type=" color"], input[type=" text"], input[type=" search"], input[type=" tel"], input[type=" time"], input[type=" date"], input[type=" datetime-local"], input[type=" url"], input[type=" week"], input[type=" month"], input[type=" number"], input[type=" password"], input[type=" email"], [data-js-select-action-overlay]";
1924

2025
/* Component */
2126
.#{$_} {
@@ -30,7 +35,7 @@ $fields: "input, input[type="color"], input[type="text"], input[type="search"],
3035
}
3136

3237
.#{$_}__label {
33-
color: tokens.get($_, "color--surface-contrast");
38+
color: tokens.get($_, "contrast-color");
3439
font-size: 0.75rem;
3540
font-weight: 700;
3641
text-transform: uppercase;
@@ -40,14 +45,14 @@ $fields: "input, input[type="color"], input[type="text"], input[type="search"],
4045

4146
.#{$_}__description {
4247
font-size: 0.75rem;
43-
color: tokens.get($_, "color--surface-contrast");
48+
color: tokens.get($_, "contrast-color");
4449
margin-top: 0;
4550
}
4651

4752
.#{$_}__helper {
4853
font-family: var(--font-family-base);
4954
font-size: var(--font-size-caption, 0.875rem);
50-
color: tokens.get($_, "color--surface-contrast");
55+
color: tokens.get($_, "contrast-color");
5156
margin-top: tokens.use($_, "space", 0.5);
5257
margin-left: tokens.use($_, "space", 0.25);
5358
}
@@ -62,7 +67,7 @@ $fields: "input, input[type="color"], input[type="text"], input[type="search"],
6267
padding: tokens.use($_, "space", 2);
6368
outline: 0;
6469
margin: 0;
65-
color: tokens.get($_, "color--surface-contrast");
70+
color: tokens.get($_, "contrast-color");
6671
}
6772

6873
.#{$_}__inner {
@@ -76,8 +81,8 @@ $fields: "input, input[type="color"], input[type="text"], input[type="search"],
7681
font-size: 0.95rem;
7782
line-height: calc(var(--base) * 2);
7883
border: tokens.get($_, "border");
79-
background: tokens.get($_, "background-color");
80-
color: tokens.get($_, "color--surface-contrast");
84+
background: var(--inherit-color-background, tokens.get($_, "background-color"));
85+
color: tokens.get($_, "contrast-color");
8186
border-radius: tokens.use($_, "border-radius");
8287
corner-shape: tokens.get($_, "corner-shape");
8388

@@ -141,11 +146,9 @@ $fields: "input, input[type="color"], input[type="text"], input[type="search"],
141146
height: 100%;
142147
width: calc(#{tokens.get($_, "base")} * 5);
143148
border-left: tokens.use($_, "border-width", 1) solid tokens.get($_, "color--surface-border");
144-
background-image: linear-gradient(
145-
to bottom,
146-
color-mix(in srgb, tokens.get($_, "color--surface-border") 14%, tokens.get($_, "background-color")),
147-
color-mix(in srgb, tokens.get($_, "color--surface-border") 8%, tokens.get($_, "background-color"))
148-
);
149+
background-image: linear-gradient(to bottom,
150+
color-mix(in srgb, tokens.get($_, "color--surface-border") 14%, tokens.get($_, "background-color")),
151+
color-mix(in srgb, tokens.get($_, "color--surface-border") 8%, tokens.get($_, "background-color")));
149152
border-top-right-radius: tokens.use($_, "border-radius");
150153
border-bottom-right-radius: tokens.use($_, "border-radius");
151154
pointer-events: none;
@@ -169,7 +172,7 @@ $fields: "input, input[type="color"], input[type="text"], input[type="search"],
169172
.#{$_}__icon,
170173
.#{$_}__prefix,
171174
.#{$_}__suffix {
172-
color: tokens.get($_, "color--surface-contrast");
175+
color: tokens.get($_, "contrast-color");
173176
}
174177

175178
.#{$_}__icon,
@@ -440,7 +443,7 @@ $fields: "input, input[type="color"], input[type="text"], input[type="search"],
440443
left: 0;
441444
right: 0;
442445
z-index: 4500;
443-
background-color: tokens.get($_, "background-color");
446+
background-color: var(--inherit-color-background, tokens.get($_, "background-color"));
444447
border: tokens.get($_, "border");
445448
border-radius: tokens.use($_, "border-radius");
446449
corner-shape: tokens.get($_, "corner-shape");
@@ -466,7 +469,7 @@ $fields: "input, input[type="color"], input[type="text"], input[type="search"],
466469
.#{$_}__search-results-link {
467470
display: block;
468471
text-decoration: none;
469-
color: tokens.get($_, "color--surface-contrast");
472+
color: tokens.get($_, "contrast-color");
470473
padding: tokens.use($_, "space", 1.25) tokens.use($_, "space", 2);
471474

472475
&:hover,
@@ -493,4 +496,4 @@ $fields: "input, input[type="color"], input[type="text"], input[type="search"],
493496
padding: 0 calc(var(--base, 8px) * 4);
494497
}
495498
}
496-
}
499+
}

0 commit comments

Comments
 (0)