Skip to content

fix: errors when building theme using CSS variables #15140

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
Feb 13, 2019

Conversation

crisbeto
Copy link
Member

  • Adds an extra theme to the build that will allow us to verify that everything still works if somebody passes in the palette colors as CSS variables.
  • Fixes a handful of places where Sass would either throw an error or would produce invalid CSS.

Fixes #15107.

@crisbeto crisbeto self-assigned this Feb 10, 2019
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Feb 10, 2019
@crisbeto crisbeto force-pushed the 15107/css-variables-check branch 3 times, most recently from 9250ab6 to f665356 Compare February 10, 2019 15:55
@crisbeto crisbeto changed the title wip: errors when building theme using CSS variables fix: errors when building theme using CSS variables Feb 10, 2019
@crisbeto crisbeto added the target: patch This PR is targeted for the next patch release label Feb 10, 2019
@crisbeto crisbeto assigned jelbourn and devversion and unassigned crisbeto Feb 10, 2019
Copy link
Member

@devversion devversion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on the bazel/gulp stuff.

._demo-css-variables-theme {
$palette: mat-palette($mat-blue-grey);
$theme: mat-dark-theme($palette, $palette, $palette);
@include angular-material-theme(replace-all-values($theme, var(--test-var)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious how things would actually look with the changes you've made, could we make a similar function that stores off the current values in the map (e.g. --test-var-#{n}: $value) and then updates the map with variables referring to the original value (e.g. var(--test-var-#{n})). That way we could compare how the app looks with the original theme and with the variable alias theme

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to get it to work, but I'd rather get this in first so we don't continue introducing new failures.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it doesn't make things any worse for users

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

$badge-opacity: opacity($badge-color);
background: mix($app-background, rgba($badge-color, 1), (1 - $badge-opacity) * 100%);

@if (type-of($badge-color) == color and type-of($app-background) == color) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment along the lines:

// If the given color is actually a color *type*, we _____. If the given background is not
// specifically a color (e.g. a css variable), use it directly.

(similar elsewhere)

* Adds an extra theme to the build that will allow us to verify that everything still works if somebody passes in the palette colors as CSS variables.
* Fixes a handful of places where Sass would either throw an error or would produce invalid CSS.

Fixes angular#15107.
@crisbeto crisbeto force-pushed the 15107/css-variables-check branch from f665356 to c2c57c8 Compare February 11, 2019 19:42
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Feb 11, 2019
@jelbourn jelbourn merged commit 35e89e5 into angular:master Feb 13, 2019
jelbourn pushed a commit that referenced this pull request Feb 20, 2019
* Adds an extra theme to the build that will allow us to verify that everything still works if somebody passes in the palette colors as CSS variables.
* Fixes a handful of places where Sass would either throw an error or would produce invalid CSS.

Fixes #15107.
@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 Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow CSS variables in color palettes
5 participants