From dadfb713e10bace5dbefa061562dd2747d5fa0ea Mon Sep 17 00:00:00 2001 From: Patty RoDee Date: Fri, 7 Oct 2022 21:59:23 -0700 Subject: [PATCH] chore: rename "validate-theme-keys" to "validate-theme-styles" PiperOrigin-RevId: 479731656 --- packages/mdc-banner/_banner-theme.scss | 5 +-- .../mdc-button/_button-outlined-theme.scss | 2 +- packages/mdc-button/_button-text-theme.scss | 4 +-- packages/mdc-card/_elevated-card-theme.scss | 2 +- packages/mdc-card/_filled-card-theme.scss | 2 +- packages/mdc-card/_outlined-card-theme.scss | 2 +- packages/mdc-checkbox/_checkbox-theme.scss | 5 +-- packages/mdc-chips/_chip-theme.scss | 2 +- .../_circular-progress-theme.scss | 2 +- packages/mdc-dialog/_dialog-theme.scss | 5 +-- .../_linear-progress-theme.scss | 2 +- packages/mdc-list/_list-theme.scss | 5 +-- packages/mdc-radio/_radio-theme.scss | 2 +- packages/mdc-ripple/_ripple-theme.scss | 2 +- packages/mdc-select/_select-theme.scss | 3 +- packages/mdc-slider/_slider-theme.scss | 2 +- packages/mdc-snackbar/_snackbar-theme.scss | 2 +- packages/mdc-switch/_switch-theme.scss | 2 +- packages/mdc-textfield/_text-field-theme.scss | 2 +- packages/mdc-theme/_theme.scss | 35 ++++++++++++++----- .../mdc-tooltip/_plain-tooltip-theme.scss | 2 +- packages/mdc-tooltip/_rich-tooltip-theme.scss | 2 +- packages/mdc-typography/_typography.scss | 2 +- 23 files changed, 58 insertions(+), 36 deletions(-) diff --git a/packages/mdc-banner/_banner-theme.scss b/packages/mdc-banner/_banner-theme.scss index 7738fcaa88a..745bf714a66 100644 --- a/packages/mdc-banner/_banner-theme.scss +++ b/packages/mdc-banner/_banner-theme.scss @@ -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); } @@ -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( ( diff --git a/packages/mdc-button/_button-outlined-theme.scss b/packages/mdc-button/_button-outlined-theme.scss index a6a5f469997..dc52425607f 100644 --- a/packages/mdc-button/_button-outlined-theme.scss +++ b/packages/mdc-button/_button-outlined-theme.scss @@ -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 diff --git a/packages/mdc-button/_button-text-theme.scss b/packages/mdc-button/_button-text-theme.scss index 42bef2c99ca..7ad5c98b6dc 100644 --- a/packages/mdc-button/_button-text-theme.scss +++ b/packages/mdc-button/_button-text-theme.scss @@ -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 @@ -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); } diff --git a/packages/mdc-card/_elevated-card-theme.scss b/packages/mdc-card/_elevated-card-theme.scss index bf2b562087c..681410e7f76 100644 --- a/packages/mdc-card/_elevated-card-theme.scss +++ b/packages/mdc-card/_elevated-card-theme.scss @@ -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 diff --git a/packages/mdc-card/_filled-card-theme.scss b/packages/mdc-card/_filled-card-theme.scss index 9e8655b5466..4f2b45187f6 100644 --- a/packages/mdc-card/_filled-card-theme.scss +++ b/packages/mdc-card/_filled-card-theme.scss @@ -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 diff --git a/packages/mdc-card/_outlined-card-theme.scss b/packages/mdc-card/_outlined-card-theme.scss index 4a61d2ec469..0a2dbcef0b6 100644 --- a/packages/mdc-card/_outlined-card-theme.scss +++ b/packages/mdc-card/_outlined-card-theme.scss @@ -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 diff --git a/packages/mdc-checkbox/_checkbox-theme.scss b/packages/mdc-checkbox/_checkbox-theme.scss index a462ed7590e..ee56a7793ac 100644 --- a/packages/mdc-checkbox/_checkbox-theme.scss +++ b/packages/mdc-checkbox/_checkbox-theme.scss @@ -118,7 +118,8 @@ $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 @@ -126,7 +127,7 @@ $forced-colors-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, $prefix: $custom-property-prefix diff --git a/packages/mdc-chips/_chip-theme.scss b/packages/mdc-chips/_chip-theme.scss index 38e8a0a0435..9920c09b14e 100644 --- a/packages/mdc-chips/_chip-theme.scss +++ b/packages/mdc-chips/_chip-theme.scss @@ -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 diff --git a/packages/mdc-circular-progress/_circular-progress-theme.scss b/packages/mdc-circular-progress/_circular-progress-theme.scss index 79cee32bd08..b165a87207a 100644 --- a/packages/mdc-circular-progress/_circular-progress-theme.scss +++ b/packages/mdc-circular-progress/_circular-progress-theme.scss @@ -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, diff --git a/packages/mdc-dialog/_dialog-theme.scss b/packages/mdc-dialog/_dialog-theme.scss index 99318b8ca62..2b03e9317c1 100644 --- a/packages/mdc-dialog/_dialog-theme.scss +++ b/packages/mdc-dialog/_dialog-theme.scss @@ -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, @@ -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 diff --git a/packages/mdc-linear-progress/_linear-progress-theme.scss b/packages/mdc-linear-progress/_linear-progress-theme.scss index b0f3788302d..fbf0468fc8a 100644 --- a/packages/mdc-linear-progress/_linear-progress-theme.scss +++ b/packages/mdc-linear-progress/_linear-progress-theme.scss @@ -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, diff --git a/packages/mdc-list/_list-theme.scss b/packages/mdc-list/_list-theme.scss index 212e68dd2ef..a691eee57c7 100644 --- a/packages/mdc-list/_list-theme.scss +++ b/packages/mdc-list/_list-theme.scss @@ -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, @@ -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 diff --git a/packages/mdc-radio/_radio-theme.scss b/packages/mdc-radio/_radio-theme.scss index f6100c86dd7..d1a30dc8809 100644 --- a/packages/mdc-radio/_radio-theme.scss +++ b/packages/mdc-radio/_radio-theme.scss @@ -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, diff --git a/packages/mdc-ripple/_ripple-theme.scss b/packages/mdc-ripple/_ripple-theme.scss index 4ffa1e84562..971f6f4ce81 100644 --- a/packages/mdc-ripple/_ripple-theme.scss +++ b/packages/mdc-ripple/_ripple-theme.scss @@ -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), diff --git a/packages/mdc-select/_select-theme.scss b/packages/mdc-select/_select-theme.scss index aa1a1f039b2..ee75abec30d 100644 --- a/packages/mdc-select/_select-theme.scss +++ b/packages/mdc-select/_select-theme.scss @@ -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( ( diff --git a/packages/mdc-slider/_slider-theme.scss b/packages/mdc-slider/_slider-theme.scss index bda55e8257f..ed82871b071 100644 --- a/packages/mdc-slider/_slider-theme.scss +++ b/packages/mdc-slider/_slider-theme.scss @@ -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( diff --git a/packages/mdc-snackbar/_snackbar-theme.scss b/packages/mdc-snackbar/_snackbar-theme.scss index 003d972485b..44f4e63f0e2 100644 --- a/packages/mdc-snackbar/_snackbar-theme.scss +++ b/packages/mdc-snackbar/_snackbar-theme.scss @@ -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( diff --git a/packages/mdc-switch/_switch-theme.scss b/packages/mdc-switch/_switch-theme.scss index f8767f68662..27dad97be71 100644 --- a/packages/mdc-switch/_switch-theme.scss +++ b/packages/mdc-switch/_switch-theme.scss @@ -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); diff --git a/packages/mdc-textfield/_text-field-theme.scss b/packages/mdc-textfield/_text-field-theme.scss index 8c5d1eb155d..496ef8a61d2 100644 --- a/packages/mdc-textfield/_text-field-theme.scss +++ b/packages/mdc-textfield/_text-field-theme.scss @@ -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( ( diff --git a/packages/mdc-theme/_theme.scss b/packages/mdc-theme/_theme.scss index 632420ae34e..3517eb2370a 100644 --- a/packages/mdc-theme/_theme.scss +++ b/packages/mdc-theme/_theme.scss @@ -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 @@ -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: (); diff --git a/packages/mdc-tooltip/_plain-tooltip-theme.scss b/packages/mdc-tooltip/_plain-tooltip-theme.scss index 52b94ef1a9a..763833e8431 100644 --- a/packages/mdc-tooltip/_plain-tooltip-theme.scss +++ b/packages/mdc-tooltip/_plain-tooltip-theme.scss @@ -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 diff --git a/packages/mdc-tooltip/_rich-tooltip-theme.scss b/packages/mdc-tooltip/_rich-tooltip-theme.scss index 1ed2688aff3..cd440639eda 100644 --- a/packages/mdc-tooltip/_rich-tooltip-theme.scss +++ b/packages/mdc-tooltip/_rich-tooltip-theme.scss @@ -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 diff --git a/packages/mdc-typography/_typography.scss b/packages/mdc-typography/_typography.scss index 8103102a8ba..2623caa3d80 100644 --- a/packages/mdc-typography/_typography.scss +++ b/packages/mdc-typography/_typography.scss @@ -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));