Skip to content

refactor: merge m2 mdc and mat tokens #30748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 0 additions & 140 deletions src/material/button/_button-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,82 +3,50 @@
@use '../core/theming/validation';
@use '../core/tokens/token-utils';
@use '../core/typography/typography';
@use '../core/tokens/m2/mdc/filled-button' as tokens-mdc-filled-button;
@use '../core/tokens/m2/mat/filled-button' as tokens-mat-filled-button;
@use '../core/tokens/m2/mdc/outlined-button' as tokens-mdc-outlined-button;
@use '../core/tokens/m2/mat/outlined-button' as tokens-mat-outlined-button;
@use '../core/tokens/m2/mdc/protected-button' as tokens-mdc-protected-button;
@use '../core/tokens/m2/mat/protected-button' as tokens-mat-protected-button;
@use '../core/tokens/m2/mdc/text-button' as tokens-mdc-text-button;
@use '../core/tokens/m2/mat/text-button' as tokens-mat-text-button;
@use '../core/tokens/m2/mat/tonal-button' as tokens-mat-tonal-button;
@use '../core/style/sass-utils';

@mixin _text-button-variant($theme, $palette) {
$mdc-tokens: if(
$palette,
tokens-mdc-text-button.private-get-color-palette-color-tokens($theme, $palette),
tokens-mdc-text-button.get-color-tokens($theme)
);

$mat-tokens: if(
$palette,
tokens-mat-text-button.private-get-color-palette-color-tokens($theme, $palette),
tokens-mat-text-button.get-color-tokens($theme)
);

@include token-utils.create-token-values-mixed(tokens-mdc-text-button.$prefix, $mdc-tokens);
@include token-utils.create-token-values-mixed(tokens-mat-text-button.$prefix, $mat-tokens);
}

@mixin _filled-button-variant($theme, $palette) {
$mdc-tokens: if(
$palette,
tokens-mdc-filled-button.private-get-color-palette-color-tokens($theme, $palette),
tokens-mdc-filled-button.get-color-tokens($theme)
);

$mat-tokens: if(
$palette,
tokens-mat-filled-button.private-get-color-palette-color-tokens($theme, $palette),
tokens-mat-filled-button.get-color-tokens($theme)
);

@include token-utils.create-token-values-mixed(tokens-mdc-filled-button.$prefix, $mdc-tokens);
@include token-utils.create-token-values-mixed(tokens-mat-filled-button.$prefix, $mat-tokens);
}

@mixin _protected-button-variant($theme, $palette) {
$mdc-tokens: if(
$palette,
tokens-mdc-protected-button.private-get-color-palette-color-tokens($theme, $palette),
tokens-mdc-protected-button.get-color-tokens($theme)
);

$mat-tokens: if(
$palette,
tokens-mat-protected-button.private-get-color-palette-color-tokens($theme, $palette),
tokens-mat-protected-button.get-color-tokens($theme)
);

@include token-utils.create-token-values-mixed(tokens-mdc-protected-button.$prefix, $mdc-tokens);
@include token-utils.create-token-values-mixed(tokens-mat-protected-button.$prefix, $mat-tokens);
}

@mixin _outlined-button-variant($theme, $palette) {
$mdc-tokens: if(
$palette,
tokens-mdc-outlined-button.private-get-color-palette-color-tokens($theme, $palette),
tokens-mdc-outlined-button.get-color-tokens($theme)
);

$mat-tokens: if(
$palette,
tokens-mat-outlined-button.private-get-color-palette-color-tokens($theme, $palette),
tokens-mat-outlined-button.get-color-tokens($theme)
);

@include token-utils.create-token-values-mixed(tokens-mdc-outlined-button.$prefix, $mdc-tokens);
@include token-utils.create-token-values-mixed(tokens-mat-outlined-button.$prefix, $mat-tokens);
}

Expand All @@ -95,26 +63,6 @@
@include validation.selector-defined(
'Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector'
);
$mdc-text-button-tokens: token-utils.get-tokens-for(
$tokens,
tokens-mdc-text-button.$prefix,
$options...
);
$mdc-protected-button-tokens: token-utils.get-tokens-for(
$tokens,
tokens-mdc-protected-button.$prefix,
$options...
);
$mdc-filled-button-tokens: token-utils.get-tokens-for(
$tokens,
tokens-mdc-filled-button.$prefix,
$options...
);
$mdc-outlined-button-tokens: token-utils.get-tokens-for(
$tokens,
tokens-mdc-outlined-button.$prefix,
$options...
);
$mat-text-button-tokens: token-utils.get-tokens-for(
$tokens,
tokens-mat-text-button.$prefix,
Expand All @@ -141,19 +89,6 @@
$options...
);

@include token-utils.create-token-values(tokens-mdc-text-button.$prefix, $mdc-text-button-tokens);
@include token-utils.create-token-values(
tokens-mdc-protected-button.$prefix,
$mdc-protected-button-tokens
);
@include token-utils.create-token-values(
tokens-mdc-filled-button.$prefix,
$mdc-filled-button-tokens
);
@include token-utils.create-token-values(
tokens-mdc-outlined-button.$prefix,
$mdc-outlined-button-tokens
);
@include token-utils.create-token-values(tokens-mat-text-button.$prefix, $mat-text-button-tokens);
@include token-utils.create-token-values(
tokens-mat-protected-button.$prefix,
Expand Down Expand Up @@ -181,23 +116,6 @@
@include _theme-from-tokens(inspection.get-theme-tokens($theme, base));
} @else {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values-mixed(
tokens-mdc-text-button.$prefix,
tokens-mdc-text-button.get-unthemable-tokens()
);
@include token-utils.create-token-values-mixed(
tokens-mdc-filled-button.$prefix,
tokens-mdc-filled-button.get-unthemable-tokens()
);
@include token-utils.create-token-values-mixed(
tokens-mdc-protected-button.$prefix,
tokens-mdc-protected-button.get-unthemable-tokens()
);
@include token-utils.create-token-values-mixed(
tokens-mdc-outlined-button.$prefix,
tokens-mdc-outlined-button.get-unthemable-tokens()
);

@include token-utils.create-token-values-mixed(
tokens-mat-text-button.$prefix,
tokens-mat-text-button.get-unthemable-tokens()
Expand Down Expand Up @@ -318,23 +236,6 @@
@include _theme-from-tokens(inspection.get-theme-tokens($theme, typography));
} @else {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values-mixed(
tokens-mdc-text-button.$prefix,
tokens-mdc-text-button.get-typography-tokens($theme)
);
@include token-utils.create-token-values-mixed(
tokens-mdc-filled-button.$prefix,
tokens-mdc-filled-button.get-typography-tokens($theme)
);
@include token-utils.create-token-values-mixed(
tokens-mdc-protected-button.$prefix,
tokens-mdc-protected-button.get-typography-tokens($theme)
);
@include token-utils.create-token-values-mixed(
tokens-mdc-outlined-button.$prefix,
tokens-mdc-outlined-button.get-typography-tokens($theme)
);

@include token-utils.create-token-values-mixed(
tokens-mat-text-button.$prefix,
tokens-mat-text-button.get-typography-tokens($theme)
Expand Down Expand Up @@ -366,23 +267,6 @@
@include _theme-from-tokens(inspection.get-theme-tokens($theme, density));
} @else {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values-mixed(
tokens-mdc-text-button.$prefix,
tokens-mdc-text-button.get-density-tokens($theme)
);
@include token-utils.create-token-values-mixed(
tokens-mdc-filled-button.$prefix,
tokens-mdc-filled-button.get-density-tokens($theme)
);
@include token-utils.create-token-values-mixed(
tokens-mdc-protected-button.$prefix,
tokens-mdc-protected-button.get-density-tokens($theme)
);
@include token-utils.create-token-values-mixed(
tokens-mdc-outlined-button.$prefix,
tokens-mdc-outlined-button.get-density-tokens($theme)
);

@include token-utils.create-token-values-mixed(
tokens-mat-text-button.$prefix,
tokens-mat-text-button.get-density-tokens($theme)
Expand All @@ -409,52 +293,28 @@

/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
$mdc-filled-button-tokens: tokens-mdc-filled-button.get-token-slots();
$mat-filled-button-tokens: tokens-mat-filled-button.get-token-slots();
$mdc-outlined-button-tokens: tokens-mdc-outlined-button.get-token-slots();
$mat-outlined-button-tokens: tokens-mat-outlined-button.get-token-slots();
$mdc-protected-button-tokens: tokens-mdc-protected-button.get-token-slots();
$mat-protected-button-tokens: tokens-mat-protected-button.get-token-slots();
$mdc-text-button-tokens: tokens-mdc-text-button.get-token-slots();
$mat-text-button-tokens: tokens-mat-text-button.get-token-slots();
$mat-tonal-button-tokens: tokens-mat-tonal-button.get-token-slots();

@return (
(
namespace: tokens-mdc-filled-button.$prefix,
tokens: $mdc-filled-button-tokens,
prefix: 'filled-',
),
(
namespace: tokens-mat-filled-button.$prefix,
tokens: $mat-filled-button-tokens,
prefix: 'filled-',
),
(
namespace: tokens-mdc-outlined-button.$prefix,
tokens: $mdc-outlined-button-tokens,
prefix: 'outlined-',
),
(
namespace: tokens-mat-outlined-button.$prefix,
tokens: $mat-outlined-button-tokens,
prefix: 'outlined-',
),
(
namespace: tokens-mdc-protected-button.$prefix,
tokens: $mdc-protected-button-tokens,
prefix: 'protected-',
),
(
namespace: tokens-mat-protected-button.$prefix,
tokens: $mat-protected-button-tokens,
prefix: 'protected-',
),
(
namespace: tokens-mdc-text-button.$prefix,
tokens: $mdc-text-button-tokens,
prefix: 'text-',
),
(
namespace: tokens-mat-text-button.$prefix,
tokens: $mat-text-button-tokens,
Expand Down
63 changes: 15 additions & 48 deletions src/material/button/_fab-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
@use '../core/theming/theming';
@use '../core/theming/inspection';
@use '../core/theming/validation';
@use '../core/tokens/m2/mdc/fab' as tokens-mdc-fab;
@use '../core/tokens/m2/mdc/fab-small' as tokens-mdc-fab-small;
@use '../core/tokens/m2/mdc/extended-fab' as tokens-mdc-extended-fab;
@use '../core/tokens/m2/mat/extended-fab' as tokens-mat-extended-fab;
@use '../core/tokens/m2/mat/fab' as tokens-mat-fab;
@use '../core/tokens/m2/mat/fab-small' as tokens-mat-fab-small;
@use '../core/tokens/token-utils';
Expand All @@ -19,52 +17,38 @@
} @else {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values-mixed(
tokens-mdc-fab.$prefix,
tokens-mdc-fab.get-unthemable-tokens()
tokens-mat-fab.$prefix,
tokens-mat-fab.get-unthemable-tokens()
);
@include token-utils.create-token-values-mixed(
tokens-mdc-fab-small.$prefix,
tokens-mdc-fab-small.get-unthemable-tokens()
tokens-mat-fab-small.$prefix,
tokens-mat-fab-small.get-unthemable-tokens()
);
@include token-utils.create-token-values-mixed(
tokens-mdc-extended-fab.$prefix,
tokens-mdc-extended-fab.get-unthemable-tokens()
tokens-mat-extended-fab.$prefix,
tokens-mat-extended-fab.get-unthemable-tokens()
);
}
}
}

@mixin _fab-variant($theme, $palette) {
$mdc-tokens: if(
$palette,
tokens-mdc-fab.private-get-color-palette-color-tokens($theme, $palette),
tokens-mdc-fab.get-color-tokens($theme)
);

$mat-tokens: if(
$palette,
tokens-mat-fab.private-get-color-palette-color-tokens($theme, $palette),
tokens-mat-fab.get-color-tokens($theme)
);

@include token-utils.create-token-values-mixed(tokens-mdc-fab.$prefix, $mdc-tokens);
@include token-utils.create-token-values-mixed(tokens-mat-fab.$prefix, $mat-tokens);
}

@mixin _fab-small-variant($theme, $palette) {
$mdc-tokens: if(
$palette,
tokens-mdc-fab-small.private-get-color-palette-color-tokens($theme, $palette),
tokens-mdc-fab-small.get-color-tokens($theme)
);

$mat-tokens: if(
$palette,
tokens-mat-fab-small.private-get-color-palette-color-tokens($theme, $palette),
tokens-mat-fab-small.get-color-tokens($theme)
);

@include token-utils.create-token-values-mixed(tokens-mdc-fab-small.$prefix, $mdc-tokens);
@include token-utils.create-token-values-mixed(tokens-mat-fab-small.$prefix, $mat-tokens);
}

Expand All @@ -81,8 +65,8 @@
@include _fab-variant($theme, null);
@include _fab-small-variant($theme, null);
@include token-utils.create-token-values-mixed(
tokens-mdc-extended-fab.$prefix,
tokens-mdc-extended-fab.get-color-tokens($theme)
tokens-mat-extended-fab.$prefix,
tokens-mat-extended-fab.get-color-tokens($theme)
);

.mat-mdc-fab {
Expand Down Expand Up @@ -124,8 +108,8 @@
} @else {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values-mixed(
tokens-mdc-extended-fab.$prefix,
tokens-mdc-extended-fab.get-typography-tokens($theme)
tokens-mat-extended-fab.$prefix,
tokens-mat-extended-fab.get-typography-tokens($theme)
);
@include token-utils.create-token-values-mixed(
tokens-mat-fab.$prefix,
Expand Down Expand Up @@ -162,17 +146,8 @@
@function _define-overrides() {
@return (
(
namespace: tokens-mdc-fab.$prefix,
tokens: tokens-mdc-fab.get-token-slots(),
),
(
namespace: tokens-mdc-fab-small.$prefix,
tokens: tokens-mdc-fab-small.get-token-slots(),
prefix: 'small-',
),
(
namespace: tokens-mdc-extended-fab.$prefix,
tokens: tokens-mdc-extended-fab.get-token-slots(),
namespace: tokens-mat-extended-fab.$prefix,
tokens: tokens-mat-extended-fab.get-token-slots(),
prefix: 'extended-',
),
(
Expand Down Expand Up @@ -223,13 +198,7 @@
);
$mdc-extended-fab-tokens: token-utils.get-tokens-for(
$tokens,
tokens-mdc-extended-fab.$prefix,
$options...
);
$mdc-fab-tokens: token-utils.get-tokens-for($tokens, tokens-mdc-fab.$prefix, $options...);
$mdc-fab-small-tokens: token-utils.get-tokens-for(
$tokens,
tokens-mdc-fab-small.$prefix,
tokens-mat-extended-fab.$prefix,
$options...
);
$mat-fab-tokens: token-utils.get-tokens-for($tokens, tokens-mat-fab.$prefix, $options...);
Expand All @@ -239,11 +208,9 @@
$options...
);
@include token-utils.create-token-values(
tokens-mdc-extended-fab.$prefix,
tokens-mat-extended-fab.$prefix,
$mdc-extended-fab-tokens
);
@include token-utils.create-token-values(tokens-mdc-fab.$prefix, $mdc-fab-tokens);
@include token-utils.create-token-values(tokens-mdc-fab-small.$prefix, $mdc-fab-small-tokens);
@include token-utils.create-token-values(tokens-mat-fab.$prefix, $mat-fab-tokens);
@include token-utils.create-token-values(tokens-mat-fab-small.$prefix, $mat-fab-small-tokens);
}
Loading
Loading