Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
chore: rename "validate-theme-keys" to "validate-theme-styles"
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 479731656
  • Loading branch information
patrickrodee authored and copybara-github committed Oct 8, 2022
1 parent 395f1ce commit dadfb71
Show file tree
Hide file tree
Showing 23 changed files with 58 additions and 36 deletions.
5 changes: 3 additions & 2 deletions packages/mdc-banner/_banner-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ $light-theme: (
);

@mixin theme($theme, $resolvers: resolvers.$material) {
@include theme.validate-theme-keys($light-theme, $theme);
// TODO(b/251881053): Replace with `validate-theme`.
@include theme.validate-theme-styles($light-theme, $theme);
$theme: _resolve-theme($theme, $resolvers);
@include keys.declare-custom-properties($theme, banner);
}
Expand Down Expand Up @@ -123,7 +124,7 @@ $light-theme: (
$resolver: resolvers.$material,
$query: feature-targeting.all()
) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);
@include text-color(map.get($theme, supporting-text-color), $query: $query);
@include _supporting-text-typography(
(
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-button/_button-outlined-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ $light-theme: (
$resolver: resolvers.$material,
$query: feature-targeting.all()
) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);
$theme: keys.create-theme-properties(
$theme,
$prefix: $_custom-property-prefix
Expand Down
4 changes: 2 additions & 2 deletions packages/mdc-button/_button-text-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ $light-theme: (
$resolver: resolvers.$material,
$query: feature-targeting.all()
) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);
$theme: keys.create-theme-properties(
$theme,
$prefix: $_custom-property-prefix
Expand All @@ -89,7 +89,7 @@ $light-theme: (
$resolver: resolvers.$material,
$query: feature-targeting.all()
) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);
@include button-shared-theme.theme($theme, $resolver, $query: $query);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-card/_elevated-card-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $light-theme: (
}

@mixin theme-styles($theme, $resolver: resolvers.$material) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);
$theme: keys.create-theme-properties(
$theme,
$prefix: $custom-property-prefix
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-card/_filled-card-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $light-theme: (
}

@mixin theme-styles($theme, $resolver: resolvers.$material) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);
$theme: keys.create-theme-properties(
$theme,
$prefix: $custom-property-prefix
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-card/_outlined-card-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ $light-theme: (
}

@mixin theme-styles($theme, $resolver: resolvers.$material) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);
$theme: keys.create-theme-properties(
$theme,
$prefix: $custom-property-prefix
Expand Down
5 changes: 3 additions & 2 deletions packages/mdc-checkbox/_checkbox-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,16 @@ $forced-colors-theme: (
);

@mixin theme($theme) {
@include theme.validate-theme-keys($light-theme, $theme);
// TODO(b/251881053): Replace with `validate-theme`.
@include theme.validate-theme-styles($light-theme, $theme);
@include keys.declare-custom-properties(
$theme,
$prefix: $custom-property-prefix
);
}

@mixin theme-styles($theme) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);
$theme: keys.create-theme-properties(
$theme,
$prefix: $custom-property-prefix
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-chips/_chip-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ $_custom-property-prefix: 'chip';
}

@mixin theme-styles($theme, $resolvers: resolvers.$material) {
@include theme.validate-theme-keys($_light-theme, $theme);
@include theme.validate-theme-styles($_light-theme, $theme);
$theme: keys.create-theme-properties(
$theme,
$prefix: $_custom-property-prefix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ $light-theme: (
}

@mixin theme-styles($theme) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);

$theme: keys.create-theme-properties(
$theme,
Expand Down
5 changes: 3 additions & 2 deletions packages/mdc-dialog/_dialog-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ $light-theme: (
$custom-property-prefix: 'dialog';

@mixin theme($theme, $resolvers: resolvers.$material) {
@include theme.validate-theme-keys($light-theme, $theme);
// TODO(b/251881053): Replace with `validate-theme`.
@include theme.validate-theme-styles($light-theme, $theme);
$theme: _resolve-elevation($theme, map.get($resolvers, elevation));
@include keys.declare-custom-properties(
$theme,
Expand All @@ -90,7 +91,7 @@ $custom-property-prefix: 'dialog';
}

@mixin theme-styles($theme, $resolvers: resolvers.$material) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);
$theme: keys.create-theme-properties(
$theme,
$prefix: $custom-property-prefix
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-linear-progress/_linear-progress-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ $light-theme: (
}

@mixin theme-styles($theme) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);

$theme: keys.create-theme-properties(
$theme,
Expand Down
5 changes: 3 additions & 2 deletions packages/mdc-list/_list-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ $_light-theme: (
);

@mixin theme($theme, $resolvers: resolvers.$material) {
@include theme.validate-theme-keys($_light-theme, $theme);
// TODO(b/251881053): Replace with `validate-theme`.
@include theme.validate-theme-styles($_light-theme, $theme);
$theme: _resolve-theme($theme, $resolvers);
@include keys.declare-custom-properties(
$theme,
Expand Down Expand Up @@ -142,7 +143,7 @@ $_light-theme: (
}

@mixin theme-styles($theme, $resolvers: resolvers.$material) {
@include theme.validate-theme-keys($_light-theme, $theme);
@include theme.validate-theme-styles($_light-theme, $theme);
$theme: keys.create-theme-properties(
$theme,
$prefix: $custom-property-prefix
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-radio/_radio-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ $light-theme: (
}

@mixin theme-styles($theme) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);

$theme: keys.create-theme-properties(
$theme,
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-ripple/_ripple-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ $_ripple-theme: (
}

@mixin internal-theme-styles($theme, $ripple-target: '&') {
@include theme.validate-theme-keys($_ripple-theme, $theme);
@include theme.validate-theme-styles($_ripple-theme, $theme);

@include states-base-color(
map.get($theme, hover-state-layer-color),
Expand Down
3 changes: 2 additions & 1 deletion packages/mdc-select/_select-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ $_light-theme: (
);

@mixin theme-styles($theme, $resolvers: resolvers.$material) {
@include theme.validate-theme-keys($_light-theme, $theme);
// TODO(b/251881053): Replace with `validate-theme`.
@include theme.validate-theme-styles($_light-theme, $theme);

@include container-fill-color(
(
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-slider/_slider-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ $light-theme: (
$feat-structure: feature-targeting.create-target($query, structure);
$feat-typography: feature-targeting.create-target($query, typography);

@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);
$theme: keys.create-theme-properties($theme, $_custom-property-prefix);

@include thumb-color(
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-snackbar/_snackbar-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ $light-theme: (
}

@mixin theme-styles($theme, $resolver: resolvers.$material) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);

.mdc-snackbar__action {
@include button-text-theme.theme-styles(
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-switch/_switch-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ $forced-colors-theme: (
}

@mixin theme-styles($theme, $resolvers: resolvers.$material) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);

$theme: keys.create-theme-properties($theme, switch);

Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-textfield/_text-field-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ $_light-theme: (
);

@mixin theme-styles($theme, $resolvers: resolvers.$material) {
@include theme.validate-theme-keys($_light-theme, $theme);
@include theme.validate-theme-styles($_light-theme, $theme);

@include _caret-color(
(
Expand Down
35 changes: 26 additions & 9 deletions packages/mdc-theme/_theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -271,18 +271,24 @@
/// Validates theme configuration keys by comparing it with original theme
/// configuration, also validates theme values to see if it has any unsupported
/// value formats.
///
/// Use this in internal `theme()` mixins to validate library-provided
/// `$theme` maps and ensure that all tokens are correct and present.
///
/// @example
/// @mixin theme($theme) {
/// @include theme.validate-theme($light-theme, $theme);
/// ...
/// }
///
/// @see validate-theme-styles to validate only theme keys.
///
/// @param {Map} $origin-theme - Original theme configuration in Sass map format
/// that has all supported keys.
/// @param {Map} $custom-theme - Provided theme configuration in Sass map format
/// that should be validated against `$origin-theme`.
/// @examples
/// @mixin theme($theme) {
/// @include theme.validate-theme($light-theme, $theme);
///
/// // ...
/// }
@mixin validate-theme($origin-theme, $custom-theme, $test-only: false) {
@include validate-theme-keys(
@include validate-theme-styles(
$origin-theme,
$custom-theme,
$test-only: $test-only
Expand All @@ -292,12 +298,23 @@

/// Validates theme configuration keys by comparing it with original theme
/// configuration.
/// @see Use `validate-theme()` to validate both theme keys and theme values.
///
/// Use this in internal `theme-styles()` mixins to validate library-provided
/// `$theme` maps and ensure that all tokens are correct and present.
///
/// @example
/// @mixin theme-styles($theme) {
/// @include theme.validate-theme-styles($light-theme, $theme);
/// ...
/// }
///
/// @see validate-theme to validate both theme keys and theme values.
///
/// @param {Map} $origin-theme - Original theme configuration in Sass map format
/// that has all supported keys.
/// @param {Map} $custom-theme - Provided theme configuration in Sass map format
/// that should be validated against `$origin-theme`.
@mixin validate-theme-keys($origin-theme, $custom-theme, $test-only: false) {
@mixin validate-theme-styles($origin-theme, $custom-theme, $test-only: false) {
$origin-keys: map.keys($origin-theme);
$unsupported-keys: ();

Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-tooltip/_plain-tooltip-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $light-theme: (
}

@mixin theme-styles($theme, $resolver: resolvers.$material) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);
$theme: keys.create-theme-properties(
$theme,
$prefix: $custom-property-prefix
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-tooltip/_rich-tooltip-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ $light-theme: (
}

@mixin theme-styles($theme, $resolver: resolvers.$material) {
@include theme.validate-theme-keys($light-theme, $theme);
@include theme.validate-theme-styles($light-theme, $theme);
$theme: keys.create-theme-properties(
$theme,
$prefix: $custom-property-prefix
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-typography/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ $_typography-theme: (
);

@mixin theme-styles($theme) {
@include theme.validate-theme-keys($_typography-theme, $theme);
@include theme.validate-theme-styles($_typography-theme, $theme);

@include theme.property(font-family, map.get($theme, font));
@include theme.property(line-height, map.get($theme, line-height));
Expand Down

0 comments on commit dadfb71

Please sign in to comment.