Skip to content

Commit

Permalink
fix(all)!: use shape.resolve-tokens and remove shape.resolve-theme
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 509284550
  • Loading branch information
dfreedm authored and copybara-github committed Feb 13, 2023
1 parent 1afd925 commit 44a8d74
Show file tree
Hide file tree
Showing 29 changed files with 92 additions and 268 deletions.
16 changes: 8 additions & 8 deletions autocomplete/lib/_filled-autocomplete.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
@use '../../field/filled-field';
@use '../../menusurface/menu-surface';
@use '../../sass/theme';
@use '../../sass/shape';
@use '../../textfield/filled-text-field';
@use '../../tokens';
@use './shared';
@use '../../elevation/lib/elevation';

$custom-property-prefix: 'filled-autocomplete';
$dark-theme: tokens.md-comp-filled-autocomplete-values(
Expand All @@ -27,16 +28,18 @@ $dark-theme: tokens.md-comp-filled-autocomplete-values(
tokens.md-comp-filled-autocomplete-values(),
$tokens
);
$tokens: shared.resolve-tokens($tokens);
$tokens: elevation.resolve-tokens($tokens, 'menu-container-elevation');
$tokens: theme.create-theme-vars($tokens, $custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'text-field-container-shape');

@include theme.emit-theme-vars($tokens);
}

@mixin styles() {
$tokens: tokens.md-comp-filled-autocomplete-values();
$tokens: shared.resolve-tokens($tokens);
$tokens: elevation.resolve-tokens($tokens, 'menu-container-elevation');
$tokens: theme.create-theme-vars($tokens, $custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'text-field-container-shape');

:host {
@each $token, $value in $tokens {
Expand Down Expand Up @@ -170,11 +173,8 @@ $dark-theme: tokens.md-comp-filled-autocomplete-values(
// Textfield cannot resolve shape when created as vars.
@include filled-field.theme(
(
container-shape-start-start:
var(--_text-field-container-shape-start-start),
container-shape-start-end: var(--_text-field-container-shape-start-end),
container-shape-end-end: var(--_text-field-container-shape-end-end),
container-shape-end-start: var(--_text-field-container-shape-end-start),
container-shape:
shape.corners-to-shape-token('--_text-field-container-shape'),
)
);
}
Expand Down
17 changes: 8 additions & 9 deletions autocomplete/lib/_outlined-autocomplete.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
@use '../../sass/theme';
@use '../../textfield/outlined-text-field';
@use '../../tokens';
@use './shared';
@use '../../elevation/lib/elevation';
@use '../../sass/shape';

$custom-property-prefix: 'outlined-autocomplete';
$dark-theme: tokens.md-comp-outlined-autocomplete-values(
Expand All @@ -27,24 +28,25 @@ $dark-theme: tokens.md-comp-outlined-autocomplete-values(
tokens.md-comp-outlined-autocomplete-values(),
$theme
);
$tokens: shared.resolve-tokens($tokens);
$tokens: elevation.resolve-tokens($tokens, 'menu-container-elevation');
$tokens: theme.create-theme-vars($tokens, $custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'text-field-container-shape');

@include theme.emit-theme-vars($tokens);
}

@mixin styles() {
$tokens: tokens.md-comp-outlined-autocomplete-values();
$tokens: shared.resolve-tokens($tokens);
// TODO(b/251183088): Clean up container-shape once token is correct.
$tokens: map.merge(
$tokens,
(
text-field-container-shape: 4px,
)
);

$tokens: elevation.resolve-tokens($tokens, 'menu-container-elevation');
$tokens: theme.create-theme-vars($tokens, $custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'text-field-container-shape');

:host {
@each $token, $value in $tokens {
Expand Down Expand Up @@ -159,11 +161,8 @@ $dark-theme: tokens.md-comp-outlined-autocomplete-values(
// Textfield cannot resolve shape when created as vars.
@include outlined-field.theme(
(
container-shape-start-start:
var(--_text-field-container-shape-start-start),
container-shape-start-end: var(--_text-field-container-shape-start-end),
container-shape-end-end: var(--_text-field-container-shape-end-end),
container-shape-end-start: var(--_text-field-container-shape-end-start),
container-shape:
shape.corners-to-shape-token('--_text-field-container-shape'),
)
);
}
Expand Down
15 changes: 0 additions & 15 deletions autocomplete/lib/_shared.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,9 @@
// stylelint-disable selector-class-pattern --
// Selector '.md3-*' should only be used in this project.

@use 'sass:map';
@use '../../elevation/lib/elevation';
@use '../../sass/resolvers';
@use '../../sass/shape';

@mixin styles() {
.md3-autocomplete {
display: inline-flex;
flex: 1;
}
}

@function resolve-tokens($tokens) {
$tokens: elevation.resolve-tokens($tokens, 'menu-container-elevation');
$tokens: shape.resolve-theme(
$tokens,
map.get(resolvers.$material, shape),
text-field-container-shape
);
@return $tokens;
}
7 changes: 2 additions & 5 deletions button/lib/_elevated-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ $_custom-property-prefix: 'elevated-button';
);
$tokens: _resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'container-shape');

@include theme.emit-theme-vars($tokens);
}
Expand All @@ -38,6 +39,7 @@ $_custom-property-prefix: 'elevated-button';

$tokens: _resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'container-shape');

:host {
@each $token, $value in $tokens {
Expand All @@ -54,10 +56,5 @@ $_custom-property-prefix: 'elevated-button';
map.get(resolvers.$material, 'typography'),
'label-text'
);
$tokens: shape.resolve-theme(
$tokens,
map.get(resolvers.$material, 'shape'),
'container-shape'
);
@return elevation.resolve-tokens($tokens);
}
7 changes: 2 additions & 5 deletions button/lib/_filled-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ $_custom-property-prefix: 'filled-button';
$tokens: theme.validate-theme(tokens.md-comp-filled-button-values(), $tokens);
$tokens: _resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'container-shape');

@include theme.emit-theme-vars($tokens);
}
Expand All @@ -34,6 +35,7 @@ $_custom-property-prefix: 'filled-button';
$tokens: map.set($tokens, 'with-trailing-icon-spacing-trailing', 16px);
$tokens: _resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'container-shape');

:host {
@each $token, $value in $tokens {
Expand All @@ -50,10 +52,5 @@ $_custom-property-prefix: 'filled-button';
map.get(resolvers.$material, 'typography'),
'label-text'
);
$tokens: shape.resolve-theme(
$tokens,
map.get(resolvers.$material, 'shape'),
'container-shape'
);
@return elevation.resolve-tokens($tokens);
}
7 changes: 2 additions & 5 deletions button/lib/_outlined-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ $_custom-property-prefix: 'outlined-button';
);
$tokens: _resolve-theme($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'container-shape');

@include theme.emit-theme-vars($tokens);
}
Expand All @@ -39,6 +40,7 @@ $_custom-property-prefix: 'outlined-button';
$tokens: map.set($tokens, 'with-trailing-icon-spacing-trailing', 16px);
$tokens: _resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'container-shape');

:host {
@each $token, $value in $tokens {
Expand Down Expand Up @@ -87,10 +89,5 @@ $_custom-property-prefix: 'outlined-button';
map.get(resolvers.$material, 'typography'),
'label-text'
);
$tokens: shape.resolve-theme(
$tokens,
map.get(resolvers.$material, 'shape'),
'container-shape'
);
@return $tokens;
}
7 changes: 2 additions & 5 deletions button/lib/_text-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ $_custom-property-prefix: 'text-button';
$tokens: theme.validate-theme(tokens.md-comp-text-button-values(), $tokens);
$tokens: _resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'container-shape');

@include theme.emit-theme-vars($tokens);
}
Expand All @@ -33,6 +34,7 @@ $_custom-property-prefix: 'text-button';
$tokens: map.set($tokens, 'with-trailing-icon-spacing-trailing', 12px);
$tokens: _resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'container-shape');

:host {
@each $token, $value in $tokens {
Expand All @@ -55,10 +57,5 @@ $_custom-property-prefix: 'text-button';
map.get(resolvers.$material, 'typography'),
'label-text'
);
$tokens: shape.resolve-theme(
$tokens,
map.get(resolvers.$material, 'shape'),
'container-shape'
);
@return $tokens;
}
7 changes: 2 additions & 5 deletions button/lib/_tonal-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ $_custom-property-prefix: 'tonal-button';
);
$tokens: _resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'container-shape');

@include theme.emit-theme-vars($tokens);
}
Expand All @@ -37,6 +38,7 @@ $_custom-property-prefix: 'tonal-button';
$tokens: map.set($tokens, 'with-trailing-icon-spacing-trailing', 16px);
$tokens: _resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'container-shape');

:host {
@each $token, $value in $tokens {
Expand All @@ -53,10 +55,5 @@ $_custom-property-prefix: 'tonal-button';
map.get(resolvers.$material, 'typography'),
'label-text'
);
$tokens: shape.resolve-theme(
$tokens,
map.get(resolvers.$material, 'shape'),
'container-shape'
);
@return elevation.resolve-tokens($tokens);
}
6 changes: 4 additions & 2 deletions field/lib/_filled-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ $_animation-duration: 150ms;
$reference: map.merge($reference, shared.resolve-tokens($reference));
$tokens: theme.validate-theme($reference, $tokens);
$tokens: shared.resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, filled-field);
$tokens: theme.create-theme-vars($tokens, 'filled-field');
$tokens: shape.resolve-tokens($tokens, 'container-shape');

@include theme.emit-theme-vars($tokens);
}

@mixin styles() {
$tokens: md-comp-filled-field.values();
$tokens: shared.resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, filled-field);
$tokens: theme.create-theme-vars($tokens, 'filled-field');
$tokens: shape.resolve-tokens($tokens, 'container-shape');

:host {
@each $token, $value in $tokens {
Expand Down
7 changes: 5 additions & 2 deletions field/lib/_outlined-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@use 'sass:map';
@use '../../motion/animation';
@use '../../sass/theme';
@use '../../sass/shape';
@use './md-comp-outlined-field';
@use './shared';

Expand All @@ -20,15 +21,17 @@ $_animation-duration: 150ms;
$reference: map.merge($reference, shared.resolve-tokens($reference));
$tokens: theme.validate-theme($reference, $tokens);
$tokens: shared.resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, outlined-field);
$tokens: theme.create-theme-vars($tokens, 'outlined-field');
$tokens: shape.resolve-tokens($tokens, 'container-shape');

@include theme.emit-theme-vars($tokens);
}

@mixin styles() {
$tokens: md-comp-outlined-field.values();
$tokens: shared.resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, outlined-field);
$tokens: theme.create-theme-vars($tokens, 'outlined-field');
$tokens: shape.resolve-tokens($tokens, 'container-shape');

:host {
@each $token, $value in $tokens {
Expand Down
7 changes: 1 addition & 6 deletions field/lib/_shared.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

@use 'sass:map';
@use '../../sass/resolvers';
@use '../../sass/shape';
@use '../../sass/typography';
@use './content';
@use './label';
Expand Down Expand Up @@ -75,9 +74,5 @@
supporting-text
);

@return shape.resolve-theme(
$tokens,
map.get(resolvers.$material, shape),
container-shape
);
@return $tokens;
}
14 changes: 2 additions & 12 deletions focus/lib/_focus-ring.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@
@use 'sass:map';
@use '../../sass/theme';
@use '../../sass/shape';
@use '../../sass/resolvers';
@use './md-comp-focus-ring';

$_custom-property-prefix: 'focus-ring';

@mixin theme($tokens) {
$tokens: theme.validate-theme(md-comp-focus-ring.values(), $tokens);
$tokens: _resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'shape');

@include theme.emit-theme-vars($tokens);
}

@mixin styles() {
$tokens: md-comp-focus-ring.values();
$tokens: _resolve-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
$tokens: shape.resolve-tokens($tokens, 'shape');

:host {
@each $token, $value in $tokens {
Expand Down Expand Up @@ -50,12 +49,3 @@ $_custom-property-prefix: 'focus-ring';
display: flex;
}
}

@function _resolve-tokens($tokens) {
$tokens: shape.resolve-theme(
$tokens,
map.get(resolvers.$material, shape),
shape
);
@return $tokens;
}
4 changes: 2 additions & 2 deletions iconbutton/lib/_filled-icon-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ $_custom-property-prefix: 'filled-icon-button';
$tokens
);
$tokens: shared.flatten-disabled-colors($tokens, $variant: 'filled');
$tokens: shared.resolve-shape-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
$tokens: shared.resolve-shape-tokens($tokens);

@include theme.emit-theme-vars($tokens);
}

@mixin styles() {
$tokens: tokens.md-comp-filled-icon-button-values();
$tokens: shared.flatten-disabled-colors($tokens, $variant: 'filled');
$tokens: shared.resolve-shape-tokens($tokens);
$tokens: theme.create-theme-vars($tokens, $_custom-property-prefix);
$tokens: shared.resolve-shape-tokens($tokens);

:host {
@each $token, $value in $tokens {
Expand Down
Loading

0 comments on commit 44a8d74

Please sign in to comment.