components icon indicating copy to clipboard operation
components copied to clipboard

theming: deprecate and remove legacy theme color generation

Open mrmokwa opened this issue 4 years ago • 5 comments

Is this a regression?

  • [ ] Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Don't know if it's intended behavior or not. Scss generated by mat.define-dark-theme or mat.define-light-theme have duplicated keys/values/styles.

Notice the duplicated values for:

  • primary
  • accent
  • warn
  • is-dark
  • foreground
  • background

Reproduction

Steps to reproduce:

  1. Create new project ng new 1.1 Choose SCSS as stylesheet
  2. Add angular material ng add @angular/material 2.1 For prebuild theme, choose custom option
  3. In styles.scss file, add @debug $name-of-app-theme image

Expected Behavior

Should exist only one definition for

  • primary
  • accent
  • warn
  • is-dark
  • foreground
  • background

Actual Behavior

Below I attached the result of @debug . Take a look at primary color, for example and notice the value is repeated for no reason. The only difference is the parenthesis before.

debug.txt

Environment

  • Angular: 13.0.1
  • CDK/Material: 13.0.0
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

mrmokwa avatar Nov 16 '21 19:11 mrmokwa

Setting a low priority on this, because this is only in memory, it won't result in more CSS being generated.

crisbeto avatar Nov 17 '21 13:11 crisbeto

This is actually an intentional duplication to ensure backwards compatibility since we changed some of the internals of the theming API in preparation for density with MDC etc.

We should mark this old pattern as deprecated in an upcoming minor and remove this in the future. Here is the related code:

https://github.com/angular/components/blob/df7c46b82a7ecdfe74aad136e0c880e5631c7b7b/src/material/core/theming/_theming.scss#L388-L411

devversion avatar Nov 18 '21 14:11 devversion

Just capturing this here: https://github.com/angular/components/pull/24835. In V15/V16 we will remove this.

devversion avatar Jul 12 '22 11:07 devversion

@crisbeto Did we explicitly deprecate the .import and legacy theming entry-point or can we just consider this being part of the PR above?

devversion avatar Jul 12 '22 11:07 devversion

I don't think that we've announced anywhere that the .import files are deprecated, but we haven't been exposing any new APIs through them.

crisbeto avatar Jul 12 '22 11:07 crisbeto