Skip to content

fix(material/core): avoid solid ripples in buttons #28717

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 1 commit into from
Mar 13, 2024
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
4 changes: 3 additions & 1 deletion src/material/core/tokens/m2/mat/_fab-small.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use 'sass:map';
@use 'sass:meta';
@use '@material/ripple/ripple-theme' as mdc-ripple-theme;
@use '../../token-utils';
@use '../../../theming/theming';
Expand Down Expand Up @@ -63,8 +64,9 @@ $prefix: (mat, fab-small);
$foreground-color: null;
$state-layer-color: null;
$ripple-color: null;
$contrast-color: inspection.get-theme-color($theme, $palette-name, default-contrast);

@if (token-utils.$private-is-internal-build) {
@if (token-utils.$private-is-internal-build or meta.type-of($contrast-color) != 'color') {
$is-dark: inspection.get-theme-type($theme) == dark;
$container-color: inspection.get-theme-color($theme, $palette-name);
$contrast-tone: mdc-helpers.variable-safe-contrast-tone($container-color, $is-dark);
Expand Down
4 changes: 3 additions & 1 deletion src/material/core/tokens/m2/mat/_fab.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use 'sass:map';
@use 'sass:meta';
@use '@material/ripple/ripple-theme' as mdc-ripple-theme;
@use '../../token-utils';
@use '../../../theming/theming';
Expand Down Expand Up @@ -63,8 +64,9 @@ $prefix: (mat, fab);
$foreground-color: null;
$state-layer-color: null;
$ripple-color: null;
$contrast-color: inspection.get-theme-color($theme, $palette-name, default-contrast);

@if (token-utils.$private-is-internal-build) {
@if (token-utils.$private-is-internal-build or meta.type-of($contrast-color) != 'color') {
$is-dark: inspection.get-theme-type($theme) == dark;
$container-color: inspection.get-theme-color($theme, $palette-name);
$contrast-tone: mdc-helpers.variable-safe-contrast-tone($container-color, $is-dark);
Expand Down
4 changes: 3 additions & 1 deletion src/material/core/tokens/m2/mat/_filled-button.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use 'sass:map';
@use 'sass:meta';
@use '@material/ripple/ripple-theme' as mdc-ripple-theme;
@use '../../token-utils';
@use '../../../theming/theming';
Expand Down Expand Up @@ -58,10 +59,11 @@ $prefix: (mat, filled-button);
@function private-get-color-palette-color-tokens($theme, $palette-name) {
$state-layer-color: null;
$ripple-color: null;
$contrast-color: inspection.get-theme-color($theme, $palette-name, default-contrast);

// Ideally we would derive all values directly from the theme, but it causes a lot of regressions
// internally. For now we fall back to the old hardcoded behavior only for internal apps.
@if (token-utils.$private-is-internal-build) {
@if (token-utils.$private-is-internal-build or meta.type-of($contrast-color) != 'color') {
$is-dark: inspection.get-theme-type($theme) == dark;
$container-color: inspection.get-theme-color($theme, $palette-name);
$contrast-tone: mdc-helpers.variable-safe-contrast-tone($container-color, $is-dark);
Expand Down
6 changes: 5 additions & 1 deletion src/material/core/tokens/m2/mat/_icon-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ $prefix: (mat, icon-button);
// Generates the mapping for the properties that change based on the button palette color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
$color: inspection.get-theme-color($theme, $palette-name);
$ripple-opacity: 0.1;

@return (
state-layer-color: $color,
ripple-color: if(meta.type-of($color) == color, rgba($color, 0.1), $color),
ripple-color: if(
meta.type-of($color) == color,
rgba($color, $ripple-opacity),
inspection.get-theme-color($theme, foreground, base, $ripple-opacity)),
);
}

Expand Down
6 changes: 5 additions & 1 deletion src/material/core/tokens/m2/mat/_outlined-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ $prefix: (mat, outlined-button);
// Generates the mapping for the properties that change based on the button palette color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
$color: inspection.get-theme-color($theme, $palette-name);
$ripple-opacity: 0.1;

@return (
state-layer-color: $color,
ripple-color: if(meta.type-of($color) == color, rgba($color, 0.1), $color),
ripple-color: if(
meta.type-of($color) == color,
rgba($color, $ripple-opacity),
inspection.get-theme-color($theme, foreground, base, $ripple-opacity)),
);
}

Expand Down
4 changes: 3 additions & 1 deletion src/material/core/tokens/m2/mat/_protected-button.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use 'sass:map';
@use 'sass:meta';
@use '@material/ripple/ripple-theme' as mdc-ripple-theme;
@use '../../token-utils';
@use '../../../theming/theming';
Expand Down Expand Up @@ -58,10 +59,11 @@ $prefix: (mat, protected-button);
@function private-get-color-palette-color-tokens($theme, $palette-name) {
$state-layer-color: null;
$ripple-color: null;
$contrast-color: inspection.get-theme-color($theme, $palette-name, default-contrast);

// Ideally we would derive all values directly from the theme, but it causes a lot of regressions
// internally. For now we fall back to the old hardcoded behavior only for internal apps.
@if (token-utils.$private-is-internal-build) {
@if (token-utils.$private-is-internal-build or meta.type-of($contrast-color) != 'color') {
$is-dark: inspection.get-theme-type($theme) == dark;
$container-color: inspection.get-theme-color($theme, $palette-name);
$contrast-tone: mdc-helpers.variable-safe-contrast-tone($container-color, $is-dark);
Expand Down
6 changes: 5 additions & 1 deletion src/material/core/tokens/m2/mat/_text-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ $prefix: (mat, text-button);
// Generates the mapping for the properties that change based on the button palette color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
$color: inspection.get-theme-color($theme, $palette-name);
$ripple-opacity: 0.1;

@return (
state-layer-color: $color,
ripple-color: if(meta.type-of($color) == color, rgba($color, 0.1), $color),
ripple-color: if(
meta.type-of($color) == color,
rgba($color, $ripple-opacity),
inspection.get-theme-color($theme, foreground, base, $ripple-opacity)),
);
}

Expand Down