angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.27k stars 6.71k forks source link

Wrong checkbox checkmark color when palettes are set with CSS variables #27204

Open stephenrca opened 1 year ago

stephenrca commented 1 year ago

Is this a regression?

The previous version in which this bug was not present was

No response

Description

When defining palettes (accent or primary) with CSS variables, the chekmark color of mdc checkboxes is not the right one.

Indeed, on this line, type-of($value) == 'color' is always false when palettes are defined with CSS variables. When palettes are defined directly with web or hex colors, the mdc checkbox chekmark color is correct.

Reproduction

Steps to reproduce:

  1. Create an Angular project with angular 16
  2. Run the command ng add @angular/material @angular/cdk.
  3. Ad custom theme by defininng palette with CSS variables
  4. Add material mdc checkbox to a template

You can reproduce the problem with this demo on Stackblitz.

Expected Behavior

When color 500 of the accent palette is dark, the checkmark of the checkboxes must be white.

Actual Behavior

When color 500 of the accent palette is define by a CSS variable, the checkmark of the checkboxes is always black in a light-theme.

Environment

tinesoft commented 9 months ago

Hi all,

Any chance this get merged starting v16 of Angular ?

tinesoft commented 6 months ago

For anyone else having the problem on Angular Material 17+, I managed to solve it by adding this line in my custom theme.scss file:

// custom theme here....

// Include theme styles for core and each component used in your app.
// Alternatively, you can import and @include the theme mixins for each component
// that you are using.
@include mat.all-component-themes($your-theme);
+@include mat.all-component-colors($your-theme);