Skip to content

Commit db397ed

Browse files
asynclizcopybara-github
authored andcommitted
feat(sass): add config, theme, and token support libs
PiperOrigin-RevId: 401868592
1 parent fe65d5b commit db397ed

File tree

12 files changed

+730
-111
lines changed

12 files changed

+730
-111
lines changed

components/field/lib/_content-theme.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
@use 'sass:map';
1111
@use '@material/theme/color-palette';
1212
@use '@material/theme/state';
13-
@use '@material/theme/theme';
1413
@use './field-theme';
1514

1615
$_selectors: field-theme.$selectors;
@@ -49,7 +48,7 @@ $light-theme: (
4948
// Content elements provided to the field (such as <input>) may use
5049
// `currentColor` to inherit this property.
5150
.mdc-field__content {
52-
@include theme.property(color, $color);
51+
color: $color;
5352
}
5453
}
5554

@@ -65,6 +64,6 @@ $light-theme: (
6564

6665
@mixin _set-content-opacity($opacity) {
6766
.mdc-field__content {
68-
@include theme.property(opacity, $opacity);
67+
opacity: $opacity;
6968
}
7069
}

components/field/lib/_field-theme.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
@use 'sass:map';
8-
@use '@material/theme/theme';
98

109
$light-theme: (
1110
container-height: 56px,
@@ -24,5 +23,5 @@ $selectors: (
2423
}
2524

2625
@mixin _container-height($height) {
27-
@include theme.property(min-height, $height);
26+
min-height: $height;
2827
}

components/field/lib/_filled-field-theme.scss

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
@use 'sass:map';
1212
@use '@material/theme/color-palette';
1313
@use '@material/shape/shape';
14-
@use '@material/theme/keys';
1514
@use '@material/theme/state';
1615
@use '@material/theme/theme-color';
17-
@use '@material/theme/theme';
16+
@use '@material/mwc-../sass/theme';
17+
@use '@material/mwc-../sass/var';
1818
@use './content-theme';
1919
@use './field-theme';
2020
@use './label-theme';
@@ -48,21 +48,26 @@ $light-theme: map.merge(
4848
hover-state-layer-color: color-palette.$grey-800,
4949
hover-state-layer-opacity: 0.08,
5050
hover-stroke-color: color-palette.$grey-900,
51-
shape: small,
51+
shape: shape.$small-component-radius,
5252
stroke-color: color-palette.$grey-700,
5353
stroke-width: 1px,
5454
)
5555
);
5656

5757
@mixin theme($theme) {
58-
@include theme.validate-theme($light-theme, $theme);
59-
@include keys.declare-custom-properties($theme, filled-field);
58+
$theme: theme.create-theme-vars(
59+
theme.validate-theme($light-theme, $theme),
60+
filled-field
61+
);
62+
63+
@include theme.emit-theme-vars($theme);
6064
}
6165

6266
@mixin theme-styles($theme) {
63-
@include theme.validate-theme($light-theme, $theme);
64-
65-
$theme: keys.create-theme-properties($theme, filled-field);
67+
$theme: theme.create-theme-vars(
68+
theme.validate-theme-tokens($light-theme, $theme),
69+
filled-field
70+
);
6671

6772
@include field-theme.theme-styles($theme);
6873
@include content-theme.theme-styles($theme);
@@ -135,15 +140,15 @@ $light-theme: map.merge(
135140
@mixin _set-container-color($color) {
136141
.mdc-field__container {
137142
&::before {
138-
@include theme.property(background, $color);
143+
background: $color;
139144
}
140145
}
141146
}
142147

143148
@mixin _set-container-hover-color($color) {
144149
.mdc-field__container {
145150
&::after {
146-
@include theme.property(background, $color);
151+
background: $color;
147152
}
148153
}
149154
}
@@ -164,52 +169,48 @@ $light-theme: map.merge(
164169
@mixin _set-container-opacity($opacity) {
165170
.mdc-field__container {
166171
&::before {
167-
@include theme.property(opacity, $opacity);
172+
opacity: $opacity;
168173
}
169174
}
170175
}
171176

172177
@mixin _set-container-hover-opacity($opacity) {
173178
.mdc-field__container {
174179
&::after {
175-
@include theme.property(opacity, $opacity);
180+
opacity: $opacity;
176181
}
177182
}
178183
}
179184

180185
@mixin _container-padding-horizontal($padding) {
181186
.mdc-field__start {
182-
@include theme.property(padding-inline-start, $padding);
187+
padding-inline-start: $padding;
183188
}
184189

185190
.mdc-field__end {
186-
@include theme.property(padding-inline-end, $padding);
191+
padding-inline-end: $padding;
187192
}
188193
}
189194

190195
@mixin _container-padding-vertical($padding) {
191196
.mdc-field__container {
192-
@include theme.property(padding-top, $padding);
193-
@include theme.property(padding-bottom, $padding);
197+
padding-top: $padding;
198+
padding-bottom: $padding;
194199
}
195200
}
196201

197202
@mixin _floating-label-text-line-height($line-height) {
198203
&:not(.mdc-field--no-label) {
199204
.mdc-field__middle {
200-
@include theme.property(padding-top, $line-height);
205+
padding-top: $line-height;
201206
}
202207
}
203208
}
204209

205210
@mixin _shape($shape) {
206211
.mdc-field__container {
207-
// TODO(b/177368168): support percentages relative to density
208-
@include shape.radius(
209-
shape.mask-radius($shape, 1 1 0 0),
210-
$rtl-reflexive: true,
211-
$component-height: 56px
212-
);
212+
border-start-start-radius: $shape;
213+
broder-start-end-radius: $shape;
213214
}
214215
}
215216

@@ -234,13 +235,13 @@ $light-theme: map.merge(
234235

235236
@mixin _set-stroke-color($color) {
236237
.mdc-field__stroke::before {
237-
@include theme.property(border-bottom-color, $color);
238+
border-bottom-color: $color;
238239
}
239240
}
240241

241242
@mixin _set-stroke-focus-color($color) {
242243
.mdc-field__stroke::after {
243-
@include theme.property(border-bottom-color, $color);
244+
border-bottom-color: $color;
244245
}
245246
}
246247

@@ -262,25 +263,19 @@ $light-theme: map.merge(
262263

263264
@mixin _set-stroke-opacity($opacity) {
264265
.mdc-field__stroke::before {
265-
@include theme.property(opacity, $opacity);
266+
opacity: $opacity;
266267
}
267268
}
268269

269270
@mixin _stroke-width($widths) {
270271
.mdc-field__stroke {
271272
// Default/focus are on different elements and do not need state selectors
272273
&::before {
273-
@include theme.property(
274-
border-bottom-width,
275-
state.get-default-state($widths)
276-
);
274+
border-bottom-width: state.get-default-state($widths);
277275
}
278276

279277
&::after {
280-
@include theme.property(
281-
border-bottom-width,
282-
state.get-focus-state($widths)
283-
);
278+
border-bottom-width: state.get-focus-state($widths);
284279
}
285280
}
286281
}

components/field/lib/_label-theme.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// Selector '.mdc-*' should only be used in this project.
99

1010
@use 'sass:map';
11-
@use '@material/theme/theme';
1211

1312
$light-theme: (
1413
label-text-line-height: 24px,
@@ -45,6 +44,6 @@ $light-theme: (
4544
}
4645

4746
@mixin _set-label-text-font($font) {
48-
@include theme.property(font-size, map.get($font, size));
49-
@include theme.property(line-height, map.get($font, line-height));
47+
font-size: map.get($font, size);
48+
line-height: map.get($font, line-height);
5049
}

0 commit comments

Comments
 (0)