Skip to content

fix(material/button): remove concrete icon button theme styles #31367

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
40 changes: 4 additions & 36 deletions src/material/button/_icon-button-theme.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@use 'sass:map';
@use 'sass:math';
@use './m2-icon-button';
@use './m3-icon-button';
@use '../core/tokens/token-utils';
Expand Down Expand Up @@ -67,43 +66,12 @@
}

@mixin density($theme) {
$tokens: m2-icon-button.get-density-tokens($theme);
@if inspection.get-theme-version($theme) == 1 {
@include token-utils.values(map.get(m3-icon-button.get-tokens($theme), density));
} @else {
$icon-size: 24px;
$density-scale: inspection.get-theme-density($theme);
$size-map: (
0: 48px,
-1: 44px,
-2: 40px,
-3: 36px,
-4: 32px,
-5: 28px,
);
$calculated-size: map.get($size-map, $density-scale);

@include token-utils.values(
m2-icon-button.get-density-tokens(
$theme, $exclude: (icon-button-state-layer-size))
);

// Use `mat-mdc-button-base` to increase the specificity over the button's structural styles.
.mat-mdc-icon-button.mat-mdc-button-base {
// Match the styles that used to be present. This is necessary for backwards
// compat to match the previous implementations selector count (two classes).
--mdc-icon-button-state-layer-size: #{$calculated-size};
--mat-icon-button-state-layer-size: #{$calculated-size};

// TODO: Switch calculated-size to "var(--mat-icon-button-state-layer-size)"
// Currently fails validation because the variable is "undefined"
// in the sass stack.
// TODO: Switch icon-size to "var(--mat-icon-button-icon-size)". Currently
// fails validation because the variable is "undefined" in the sass stack.
width: var(--mat-icon-button-state-layer-size);
height: var(--mat-icon-button-state-layer-size);
padding: math.div($calculated-size - $icon-size, 2);
}
$tokens: map.get(m3-icon-button.get-tokens($theme), density);
}

@include token-utils.values($tokens);
}

/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
Expand Down
Loading