Skip to content
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

bug(THEME): Unable to use 'var' for defining theme colors #25997

Closed
1 task done
Enngage opened this issue Nov 17, 2022 · 2 comments
Closed
1 task done

bug(THEME): Unable to use 'var' for defining theme colors #25997

Enngage opened this issue Nov 17, 2022 · 2 comments
Labels
needs triage This issue needs to be triaged by the team

Comments

@Enngage
Copy link

Enngage commented Nov 17, 2022

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

14.x.y

Description

We have customizable theming and define theme such as:

 $primary: (
        50: var(--theme-primary-50),
        100: var(--theme-primary-100),
        200: var(--theme-primary-200),
        300: var(--theme-primary-300),
        400: var(--theme-primary-400),
        500: var(--theme-primary-500),
        600: var(--theme-primary-600),
        700: var(--theme-primary-700),
        800: var(--theme-primary-800),
        900: var(--theme-primary-900),
        A100: var(--theme-primary-A100),
        A200: var(--theme-primary-A200),
        A400: var(--theme-primary-A400),
        A700: var(--theme-primary-A700),
        contrast: (
            50: var(--theme-primary-contrast-50),
            100: var(--theme-primary-contrast-100),
            200: var(--theme-primary-contrast-200),
            300: var(--theme-primary-contrast-300),
            400: var(--theme-primary-contrast-400),
            500: var(--theme-primary-contrast-500),
            600: var(--theme-primary-contrast-600),
            700: var(--theme-primary-contrast-700),
            800: var(--theme-primary-contrast-800),
            900: var(--theme-primary-contrast-900),
            A100: var(--theme-primary-contrast-A100),
            A200: var(--theme-primary-contrast-A200),
            A400: var(--theme-primary-contrast-A400),
            A700: var(--theme-primary-contrast-A700)
        )
    );

And this worked perfectly fine in previous material versions, but in v15 we are getting exception such as:

HookWebpackError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: $color: var(--theme-accent-500) is not a color.
   ╷
16 │     track-color: color.adjust(mdc-theme-color.prop-value($color), $alpha: -0.75),
   │                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ╵
  node_modules\@angular\material\progress-bar\_progress-bar-theme.scss 16:18  -palette-styles()
  node_modules\@angular\material\progress-bar\_progress-bar-theme.scss 31:9   @content
  node_modules\@angular\material\core\mdc-helpers\_mdc-helpers.scss 176:5     @content
  node_modules\@angular\material\core\mdc-helpers\_mdc-helpers.scss 216:3     disable-mdc-fallback-declarations()
  node_modules\@angular\material\core\mdc-helpers\_mdc-helpers.scss 175:3     using-mdc-theme()
  node_modules\@angular\material\progress-bar\_progress-bar-theme.scss 26:3   color()
  node_modules\@angular\material\progress-bar\_progress-bar-theme.scss 53:7   @content
  node_modules\@angular\material\core\theming\_theming.scss 402:3             private-check-duplicate-theme-styles()
  node_modules\@angular\material\progress-bar\_progress-bar-theme.scss 47:3   theme()
  node_modules\@angular\material\core\theming\_all-theme.scss 47:5            @content
  node_modules\@angular\material\core\theming\_theming.scss 402:3             private-check-duplicate-theme-styles()
  node_modules\@angular\material\core\theming\_all-theme.scss 44:3            all-component-themes()
  node_modules\@angular\material\core\theming\_all-theme.scss 87:3            angular-material-theme()
  web\theme\trainer-app-theme.scss 567:5                                      app-theme()
  web\theme\trainer-theme.scss 24:5                                           root stylesheet

The problem is that you are currently now using color.adjust which doesn't seem to work in combination with var. Sure enough, if we replace var(--theme-accent-500) with any specific color ('red', '#FF0000') the error goes away.

Is this intended? Can this be fixed in some way?

Reproduction

Use 'var' to define theme colors

Expected Behavior

Same as in version 14.x.y

Actual Behavior

Project cannot be compiled with error such as HookWebpackError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js): SassError: $color: var(--theme-accent-500) is not a color.

Environment

Angular CLI: 15.0.0
Node: 16.18.0
Package Manager: npm 8.19.2
OS: win32 x64

Angular: 15.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, google-maps, language-service, material
... material-luxon-adapter, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package Version

@angular-devkit/architect 0.1500.0
@angular-devkit/build-angular 15.0.0
@angular-devkit/core 15.0.0
@angular-devkit/schematics 15.0.0
@schematics/angular 15.0.0
rxjs 7.5.7
typescript 4.9.3

@Enngage Enngage added the needs triage This issue needs to be triaged by the team label Nov 17, 2022
@Enngage
Copy link
Author

Enngage commented Nov 17, 2022

Oh, just noticed this was also reported in #25981

@Enngage Enngage closed this as completed Nov 17, 2022
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue needs to be triaged by the team
Projects
None yet
Development

No branches or pull requests

1 participant