Skip to content

Commit

Permalink
refactor(multiple): Add base mixin for components with no base tokens (
Browse files Browse the repository at this point in the history
…#27893)

This ensures API consistency and gives us a place to put base tokens,
should any be added in the future.
  • Loading branch information
mmalerba authored and zarend committed Oct 6, 2023
1 parent 7784054 commit 9ddeec6
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/material/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@
@forward './core/core-theme' as core-* show core-color, core-theme, core-typography, core-density;
@forward './core/ripple/ripple-theme' as ripple-* show ripple-color, ripple-theme;
@forward './core/option/option-theme' as option-* show option-color, option-typography,
option-theme, option-density;
option-theme, option-density, option-base;
@forward './core/option/optgroup-theme' as optgroup-* show optgroup-color, optgroup-typography,
optgroup-theme, optgroup-density;
optgroup-theme, optgroup-density, optgroup-base;
@forward './core/selection/pseudo-checkbox/pseudo-checkbox-theme' as pseudo-checkbox-* show
pseudo-checkbox-color, pseudo-checkbox-typography, pseudo-checkbox-theme;
@forward './core/selection/pseudo-checkbox/pseudo-checkbox-common' as pseudo-checkbox-* show
pseudo-checkbox-legacy-size;
@forward './core/focus-indicators/focus-indicators-theme' as strong-focus-indicators-* show
strong-focus-indicators-color, strong-focus-indicators-theme;
@forward './autocomplete/autocomplete-theme' as autocomplete-* show autocomplete-theme,
autocomplete-color, autocomplete-typography, autocomplete-density;
autocomplete-color, autocomplete-typography, autocomplete-density, autocomplete-base;
@forward './badge/badge-theme' as badge-* show badge-theme, badge-color, badge-typography,
badge-density;
badge-density, badge-base;
@forward './bottom-sheet/bottom-sheet-theme' as bottom-sheet-* show bottom-sheet-theme,
bottom-sheet-color, bottom-sheet-typography, bottom-sheet-density;
@forward './button/button-theme' as button-* show button-theme, button-color, button-typography,
Expand All @@ -85,7 +85,7 @@
@forward './chips/chips-theme' as chips-* show chips-theme, chips-color, chips-typography,
chips-density;
@forward './datepicker/datepicker-theme' as datepicker-* show datepicker-theme, datepicker-color,
datepicker-typography, datepicker-date-range-colors, datepicker-density;
datepicker-typography, datepicker-date-range-colors, datepicker-density, datepicker-base;
@forward './dialog/dialog-theme' as dialog-* show dialog-theme, dialog-color, dialog-typography,
dialog-density, dialog-base;
@forward './dialog/dialog-legacy-padding' as dialog-* show dialog-legacy-padding;
Expand All @@ -96,15 +96,16 @@
@forward './form-field/form-field-theme' as form-field-* show form-field-theme,
form-field-color, form-field-typography, form-field-density;
@forward './grid-list/grid-list-theme' as grid-list-* show grid-list-theme, grid-list-color,
grid-list-typography, grid-list-density;
@forward './icon/icon-theme' as icon-* show icon-theme, icon-color, icon-typography, icon-density;
grid-list-typography, grid-list-density, grid-list-base;
@forward './icon/icon-theme' as icon-* show icon-theme, icon-color, icon-typography, icon-density,
icon-base;
@forward './input/input-theme' as input-* show input-theme, input-color, input-typography,
input-density;
input-density, input-base;
@forward './list/list-theme' as list-* show list-theme, list-color, list-typography,
list-density, list-base;
@forward './menu/menu-theme' as menu-* show menu-theme, menu-color, menu-typography, menu-density;
@forward './paginator/paginator-theme' as paginator-* show paginator-theme, paginator-color,
paginator-typography, paginator-density;
paginator-typography, paginator-density, paginator-base;
@forward './progress-bar/progress-bar-theme' as progress-bar-* show
progress-bar-theme, progress-bar-color, progress-bar-typography,
progress-bar-density, progress-bar-base;
Expand All @@ -114,7 +115,7 @@ list-density, list-base;
@forward './radio/radio-theme' as radio-* show radio-theme, radio-color, radio-typography,
radio-density, radio-base;
@forward './select/select-theme' as select-* show select-theme, select-color, select-typography,
select-density;
select-density, select-base;
@forward './sidenav/sidenav-theme' as sidenav-* show sidenav-theme, sidenav-color,
sidenav-typography, sidenav-density;
@forward './slide-toggle/slide-toggle-theme' as slide-toggle-* show
Expand All @@ -125,12 +126,12 @@ list-density, list-base;
snack-bar-typography, snack-bar-density, snack-bar-base;
@forward './sort/sort-theme' as sort-* show sort-theme, sort-color, sort-typography, sort-density;
@forward './stepper/stepper-theme' as stepper-* show stepper-theme, stepper-color,
stepper-typography, stepper-density;
stepper-typography, stepper-density, stepper-base;
@forward './table/table-theme' as table-* show table-theme, table-color, table-typography,
table-density;
@forward './tabs/tabs-theme' as tabs-* show tabs-theme, tabs-color, tabs-typography, tabs-density;
@forward './toolbar/toolbar-theme' as toolbar-* show toolbar-theme, toolbar-color,
toolbar-typography, toolbar-density;
toolbar-typography, toolbar-density, toolbar-base;
@forward './tooltip/tooltip-theme' as tooltip-* show tooltip-theme, tooltip-color,
tooltip-typography, tooltip-density, tooltip-base;
@forward './tree/tree-theme' as tree-* show tree-theme, tree-color, tree-typography, tree-density;
Expand Down
3 changes: 3 additions & 0 deletions src/material/autocomplete/_autocomplete-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
@use '../core/tokens/token-utils';
@use '../core/tokens/m2/mat/autocomplete' as tokens-mat-autocomplete;

@mixin base($theme) {}

@mixin color($theme) {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(tokens-mat-autocomplete.$prefix,
Expand All @@ -18,6 +20,7 @@

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-autocomplete') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down
3 changes: 3 additions & 0 deletions src/material/badge/_badge-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ $_emit-fallback-vars: true;
}
}

@mixin base($theme) {}

@mixin color($theme) {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(tokens-mat-badge.$prefix,
Expand Down Expand Up @@ -204,6 +206,7 @@ $_emit-fallback-vars: true;
}
}

@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down
3 changes: 3 additions & 0 deletions src/material/core/option/_optgroup-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
@use '../theming/inspection';
@use '../typography/typography';

@mixin base($theme) {}

@mixin color($theme) {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(tokens-mat-optgroup.$prefix,
Expand All @@ -25,6 +27,7 @@

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-optgroup') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down
3 changes: 3 additions & 0 deletions src/material/core/option/_option-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
@use '../theming/inspection';
@use '../typography/typography';

@mixin base($theme) {}

@mixin color($theme) {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(tokens-mat-option.$prefix,
Expand Down Expand Up @@ -35,6 +37,7 @@

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-option') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down
3 changes: 3 additions & 0 deletions src/material/datepicker/_datepicker-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ $calendar-weekday-table-font-size: 11px !default;
map.merge($calendar-tokens, $range-tokens));
}

@mixin base($theme) {}

@mixin color($theme) {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(tokens-mat-datepicker.$prefix,
Expand Down Expand Up @@ -96,6 +98,7 @@ $calendar-weekday-table-font-size: 11px !default;

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-datepicker') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down
2 changes: 2 additions & 0 deletions src/material/grid-list/_grid-list-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@use '../core/style/sass-utils';
@use '../core/tokens/token-utils';

@mixin base($theme) {}

// Include this empty mixin for consistency with the other components.
@mixin color($theme) {}
Expand All @@ -20,6 +21,7 @@

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-grid-list') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down
3 changes: 3 additions & 0 deletions src/material/icon/_icon-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
@include token-utils.create-token-values(tokens-mat-icon.$prefix, $tokens);
}

@mixin base($theme) {}

@mixin color($theme) {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(tokens-mat-icon.$prefix,
Expand Down Expand Up @@ -37,6 +39,7 @@

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-icon') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down
3 changes: 3 additions & 0 deletions src/material/input/_input-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
@use '../core/theming/inspection';
@use '../core/typography/typography';

@mixin base($theme) {}

@mixin color($theme) {}

@mixin typography($theme) {}
Expand All @@ -10,6 +12,7 @@

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-input') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down
3 changes: 3 additions & 0 deletions src/material/paginator/_paginator-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
@use '../core/tokens/token-utils';
@use '../form-field/form-field-density';

@mixin base($theme) {}

@mixin color($theme) {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(tokens-mat-paginator.$prefix,
Expand Down Expand Up @@ -45,6 +47,7 @@

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-paginator') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down
3 changes: 3 additions & 0 deletions src/material/select/_select-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
@use '../core/theming/inspection';
@use '../core/typography/typography';

@mixin base($theme) {}

@mixin color($theme) {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(tokens-mat-select.$prefix,
Expand Down Expand Up @@ -58,6 +60,7 @@

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-select') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down
3 changes: 3 additions & 0 deletions src/material/stepper/_stepper-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
@use '../core/tokens/token-utils';
@use '../core/tokens/m2/mat/stepper' as tokens-mat-stepper;

@mixin base($theme) {}

@mixin color($theme) {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(tokens-mat-stepper.$prefix,
Expand Down Expand Up @@ -38,6 +40,7 @@

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-stepper') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down
3 changes: 3 additions & 0 deletions src/material/toolbar/_toolbar-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
);
}

@mixin base($theme) {}

@mixin color($theme) {
@if inspection.get-theme-version($theme) == 1 {
@include _theme-from-tokens(inspection.get-theme-tokens($theme, color));
Expand Down Expand Up @@ -75,6 +77,7 @@
@include _theme-from-tokens(inspection.get-theme-tokens($theme));
}
@else {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down

0 comments on commit 9ddeec6

Please sign in to comment.