Skip to content

Commit

Permalink
refactor(multiple): change 'other' to 'base' in theming terminology
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed Aug 7, 2023
1 parent 3a32012 commit ba24bcd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/material-experimental/theming/_definition.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $theme-version: 1;
define-colors(map.get($config, color) or ()),
define-typography(map.get($config, typography) or ()),
define-density(map.get($config, density) or ()),
($internals: (other-tokens: m3-tokens.generate-other-tokens())),
($internals: (base-tokens: m3-tokens.generate-base-tokens())),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/material-experimental/theming/_m3-tokens.scss
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
/// Generates a set of namespaced tokens not related to color, typography, or density for all
/// components.
/// @return {Map} A map of namespaced tokens not related to color, typography, or density
@function generate-other-tokens() {
@function generate-base-tokens() {
// TODO(mmalerba): Exclude density tokens once implemented.
@return _generate-tokens((
md-sys-motion: mdc-tokens.md-sys-motion-values(),
Expand Down
10 changes: 7 additions & 3 deletions src/material/checkbox/_checkbox-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
@use '../core/tokens/m2/mdc/checkbox' as tokens-mdc-checkbox;

@mixin base($config-or-theme) {
// Add default values for tokens not related to color, typography, or density.
@include sass-utils.current-selector-or-root() {
@include mdc-checkbox-theme.theme(tokens-mdc-checkbox.get-unthemable-tokens());
@if inspection.get-theme-version($config-or-theme) == 1 {
@include _theme-from-tokens(inspection.get-theme-tokens($config-or-theme, base));
}
@else {
@include sass-utils.current-selector-or-root() {
@include mdc-checkbox-theme.theme(tokens-mdc-checkbox.get-unthemable-tokens());
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/material/core/theming/_inspection.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ $_internals: _mat-theming-internals-do-not-access;
/// systems.
/// @param {Map} $theme The theme to get tokens from.
/// @param {String...} $systems The theming systems to get tokens for. Valid values are: color,
/// typography, density, other. If no systems are passed, all tokens will be returned.
/// typography, density, base. If no systems are passed, all tokens will be returned.
/// @return {Map} The requested tokens for the theme.
@function get-theme-tokens($theme, $systems...) {
$systems: if(list.length($systems) == 0, (color, typography, density, other), $systems);
$systems: if(list.length($systems) == 0, (color, typography, density, base), $systems);
$err: _validate-theme-object($theme);
@if $err {
@error #{'Expected $theme to be an Angular Material theme object. Got:'} $theme;
}
$err: validation.validate-allowed-values($systems, color, typography, density, other);
$err: validation.validate-allowed-values($systems, color, typography, density, base);
@if $err {
@error
#{'Expected $systems to contain valid system names (color, typographt, density, or other).'}
#{'Expected $systems to contain valid system names (color, typographt, density, or base).'}
#{'Got invalid system names:'} $err;
}
$result: ();
Expand Down
18 changes: 9 additions & 9 deletions src/material/core/theming/_theming.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $_disable-color-backwards-compatibility: false;
$_emitted-color: () !default;
$_emitted-typography: () !default;
$_emitted-density: () !default;
$_emitted-other: () !default;
$_emitted-base: () !default;

/// Extracts a color from a palette or throws an error if it doesn't exist.
/// @param {Map} $palette The palette from which to extract a color.
Expand Down Expand Up @@ -387,13 +387,13 @@ $_internals: _mat-theming-internals-do-not-access;
density-scale: map.get($theme-or-color-config, $_internals, density-scale),
density-tokens: map.get($theme-or-color-config, $_internals, density-tokens),
));
$other-settings: _strip-empty-settings((
other-tokens: map.get($theme-or-color-config, $_internals, other-tokens),
$base-settings: _strip-empty-settings((
base-tokens: map.get($theme-or-color-config, $_internals, base-tokens),
));
$previous-color-settings: map.get($_emitted-color, $id) or ();
$previous-typography-settings: map.get($_emitted-typography, $id) or ();
$previous-density-settings: map.get($_emitted-density, $id) or ();
$previous-other-settings: map.get($_emitted-other, $id) or ();
$previous-base-settings: map.get($_emitted-base, $id) or ();

// Check if the color configuration has been generated before.
@if $color-settings != null {
Expand Down Expand Up @@ -422,19 +422,19 @@ $_internals: _mat-theming-internals-do-not-access;
$previous-density-settings: list.append($previous-density-settings, $density-settings);
}

// Check if the other configuration has been generated before.
@if $other-settings != null {
@if list.index($previous-other-settings, $other-settings) != null and
// Check if the base configuration has been generated before.
@if $base-settings != null {
@if list.index($previous-base-settings, $base-settings) != null and
not $theme-ignore-duplication-warnings {
@warn 'The same base theme styles are generated multiple times. ' + $_duplicate-warning;
}
$previous-other-settings: list.append($previous-other-settings, $other-settings);
$previous-base-settings: list.append($previous-base-settings, $base-settings);
}

$_emitted-color: map.set($_emitted-color, $id, $previous-color-settings) !global;
$_emitted-density: map.set($_emitted-density, $id, $previous-density-settings) !global;
$_emitted-typography: map.set($_emitted-typography, $id, $previous-typography-settings) !global;
$_emitted-other: map.set($_emitted-other, $id, $previous-other-settings) !global;
$_emitted-base: map.set($_emitted-base, $id, $previous-base-settings) !global;

@content;
}
Expand Down

0 comments on commit ba24bcd

Please sign in to comment.