Skip to content

Commit

Permalink
fix(material/checkbox): derive checkmark color from palette
Browse files Browse the repository at this point in the history
Fixes that the checkbox's checkmark color isn't derived from the palette.
  • Loading branch information
crisbeto committed Mar 4, 2024
1 parent cfdfa9a commit fd01ce1
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/material/core/tokens/m2/mdc/_checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,10 @@
@use '../../../theming/inspection';
@use '../../../style/sass-utils';
@use '../../token-utils';
@use '@material/theme/theme-color' as mdc-theme-color;

// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, checkbox);

// MDC logs a warning if the `contrast-tone` function is called with a CSS variable.
// This function falls back to determining the tone based on whether the theme is light or dark.
@function _contrast-tone($value, $is-dark, $light-color: '#fff', $dark-color: '#000') {
@if ($value == 'dark' or $value == 'light' or type-of($value) == 'color') {
@return if(mdc-theme-color.contrast-tone($value) == 'dark', $dark-color, $light-color);
}

@return if($is-dark, $light-color, $dark-color);
}

// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
Expand Down Expand Up @@ -69,7 +58,8 @@ $prefix: (mdc, checkbox);
// The color of the checkbox border when the checkbox is unselected and disabled.
disabled-unselected-icon-color: $disabled-color,
// The color of the checkmark when the checkbox is selected.
selected-checkmark-color: _contrast-tone($palette-selected, $is-dark),
selected-checkmark-color:
inspection.get-theme-color($theme, background, background, 1),
// The color of the checkbox fill when the checkbox is selected and focused.
selected-focus-icon-color: $palette-selected,
// The color of the checkbox fill when the checkbox is selected and hovered.
Expand Down

0 comments on commit fd01ce1

Please sign in to comment.