Skip to content

feat(material/core): expose new @use-based Sass API #22173

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
Mar 19, 2021

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Mar 10, 2021

Reworks the public Sass API to take advantage of @use in order to allow for a single
entry point into @angular/material or @angular/cdk. Some mixins and variables were
renamed in order be a better reflection of what they do.

Before:

@import '~@angular/material/theming';
@include mat-core();

$candy-app-primary: mat-palette($mat-indigo);
$candy-app-accent:  mat-palette($mat-pink, A200, A100, A400);
$candy-app-warn:    mat-palette($mat-red);

$candy-app-theme: mat-light-theme((
  color: (
    primary: $candy-app-primary,
    accent: $candy-app-accent,
    warn: $candy-app-warn,
  )
));

@include angular-material-theme($candy-app-theme);

After:

@use '~@angular/material' as mat;
@include mat.core();

$candy-app-primary: mat.define-palette(mat.$indigo-palette);
$candy-app-accent:  mat.define-palette(mat.$pink-palette, A200, A100, A400);
$candy-app-warn:    mat.define-palette(mat.$red-palette);

$candy-app-theme: mat.define-light-theme((
  color: (
    primary: $candy-app-primary,
    accent: $candy-app-accent,
    warn: $candy-app-warn,
  )
));

@include mat.all-component-themes($candy-app-theme);

@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Mar 10, 2021
@@ -0,0 +1,88 @@
// Theming APIs
@forward './core/theming/theming' show define-light-theme, define-dark-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.

Technically we don't need to list out all the APIs with show, but I liked being explicit about what we expose. I'm open towards changing it since this could result in us forgetting to re-export a new API.

Copy link
Member

Choose a reason for hiding this comment

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

+1, I like this being explicit as well; from here it's easy to see our entire Sass API surface

@@ -12,7 +12,7 @@
}

// Gets the line height for a level inside a typography config.
@function height($config, $level) {
@function line-height($config, $level) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes an accidental rename that happened during the automated migration.

@crisbeto crisbeto force-pushed the sass-api-revamp branch 4 times, most recently from 956ad5d to 36ddb8b Compare March 10, 2021 17:25
@crisbeto crisbeto marked this pull request as ready for review March 10, 2021 17:30
@crisbeto crisbeto added P2 The issue is important to a large percentage of users, with a workaround target: major This PR is targeted for the next major release labels Mar 10, 2021
@crisbeto crisbeto added this to the 12.0.0 milestone Mar 10, 2021
@josephperrott josephperrott removed the request for review from a team March 10, 2021 17:32
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.

Overall amazing, text-field is the only actual comment. I'll start a presubmit now, though, and see what comes up

@@ -0,0 +1,88 @@
// Theming APIs
@forward './core/theming/theming' show define-light-theme, define-dark-theme,
Copy link
Member

Choose a reason for hiding this comment

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

+1, I like this being explicit as well; from here it's easy to see our entire Sass API surface

@jelbourn
Copy link
Member

jelbourn commented Mar 10, 2021

Ah, we should also add the deprecations to the commit for the changelog

@crisbeto crisbeto force-pushed the sass-api-revamp branch 4 times, most recently from b38346a to b757526 Compare March 11, 2021 20:29
@crisbeto
Copy link
Member Author

crisbeto commented Mar 11, 2021

@jelbourn I've addressed the feedback by doing the following:

  1. Switched a few of our internal themes to use the new API (dev app, e2e app etc). I had to revert my changes to the prebuilt themes, because I couldn't figure out how to format the path correctly. It would have to be something like @use '../../index' as mat;, but the compiler complained about it.
  2. Split up the text-field mixin from the CDK into text-field-autosize and text-field-autofill.

Note that the CI is currently failing, because CircleCI is down. I'll make sure that it's green once Circle is back up.

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

@jelbourn jelbourn added merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note action: merge The PR is ready for merge by the caretaker labels Mar 11, 2021
@crisbeto crisbeto force-pushed the sass-api-revamp branch 8 times, most recently from f1270bc to dd6ae86 Compare March 15, 2021 22:21
Reworks the public Sass API to take advantage of `@use` in order to allow for a single
entry point into `@angular/material` or `@angular/cdk`. Some mixins and variables were
renamed in order be a better reflection of what they do.

Before:

```
@import '~@angular/material/theming';
@include mat-core();

$candy-app-primary: mat-palette($mat-indigo);
$candy-app-accent:  mat-palette($mat-pink, A200, A100, A400);
$candy-app-warn:    mat-palette($mat-red);

$candy-app-theme: mat-light-theme((
  color: (
    primary: $candy-app-primary,
    accent: $candy-app-accent,
    warn: $candy-app-warn,
  )
));

@include angular-material-theme($candy-app-theme);
```

After:
```
@use '~@angular/material' as mat;
@include mat.core();

$candy-app-primary: mat.define-palette(mat.$indigo-palette);
$candy-app-accent:  mat.define-palette(mat.$pink-palette, A200, A100, A400);
$candy-app-warn:    mat.define-palette(mat.$red-palette);

$candy-app-theme: mat.define-light-theme((
  color: (
    primary: $candy-app-primary,
    accent: $candy-app-accent,
    warn: $candy-app-warn,
  )
));

@include mat.all-component-themes($candy-app-theme);
```
jelbourn added a commit to jelbourn/components that referenced this pull request Mar 17, 2021
This change completely rewrites the theming guide to be more complete, correct, and concise.

Summary of changes:
* Explain the concepts of palettes, hues, and themes.
* Ensure all content is conceptual and not task-based.
* Use the new Sass `@use` API introduced in angular#22173
* Document usage of the theming system with shadow dom
* Document the fact that CSS overrides are strongly discouraged
* Be more explicit about which palettes we provide
* Consolidate on a single approach to including theme CSS in an app (assuming Angular CLI)

I will send follow-up PRs for the typography, theming-your-components, and customizing-component-styles guides.
@andrewseguin andrewseguin merged commit 40ceda2 into angular:master Mar 19, 2021
jelbourn added a commit to jelbourn/components that referenced this pull request Mar 22, 2021
This change completely rewrites the theming guide to be more complete, correct, and concise.

Summary of changes:
* Explain the concepts of palettes, hues, and themes.
* Ensure all content is conceptual and not task-based.
* Use the new Sass `@use` API introduced in angular#22173
* Document usage of the theming system with shadow dom
* Document the fact that CSS overrides are strongly discouraged
* Be more explicit about which palettes we provide
* Consolidate on a single approach to including theme CSS in an app (assuming Angular CLI)

I will send follow-up PRs for the typography, theming-your-components, and customizing-component-styles guides.
jelbourn added a commit to jelbourn/components that referenced this pull request Mar 22, 2021
This change completely rewrites the theming guide to be more complete, correct, and concise.

Summary of changes:
* Explain the concepts of palettes, hues, and themes.
* Ensure all content is conceptual and not task-based.
* Use the new Sass `@use` API introduced in angular#22173
* Document usage of the theming system with shadow dom
* Document the fact that CSS overrides are strongly discouraged
* Be more explicit about which palettes we provide
* Consolidate on a single approach to including theme CSS in an app (assuming Angular CLI)

I will send follow-up PRs for the typography, theming-your-components, and customizing-component-styles guides.
jelbourn added a commit to jelbourn/components that referenced this pull request Mar 22, 2021
This change completely rewrites the theming guide to be more complete, correct, and concise.

Summary of changes:
* Explain the concepts of palettes, hues, and themes.
* Ensure all content is conceptual and not task-based.
* Use the new Sass `@use` API introduced in angular#22173
* Document usage of the theming system with shadow dom
* Document the fact that CSS overrides are strongly discouraged
* Be more explicit about which palettes we provide
* Consolidate on a single approach to including theme CSS in an app (assuming Angular CLI)

I will send follow-up PRs for the typography, theming-your-components, and customizing-component-styles guides.
jelbourn added a commit to jelbourn/components that referenced this pull request Mar 23, 2021
This change completely rewrites the theming guide to be more complete, correct, and concise.

Summary of changes:
* Explain the concepts of palettes, hues, and themes.
* Ensure all content is conceptual and not task-based.
* Use the new Sass `@use` API introduced in angular#22173
* Document usage of the theming system with shadow dom
* Document the fact that CSS overrides are strongly discouraged
* Be more explicit about which palettes we provide
* Consolidate on a single approach to including theme CSS in an app (assuming Angular CLI)

I will send follow-up PRs for the typography, theming-your-components, and customizing-component-styles guides.
andrewseguin pushed a commit that referenced this pull request Mar 23, 2021
This change completely rewrites the theming guide to be more complete, correct, and concise.

Summary of changes:
* Explain the concepts of palettes, hues, and themes.
* Ensure all content is conceptual and not task-based.
* Use the new Sass `@use` API introduced in #22173
* Document usage of the theming system with shadow dom
* Document the fact that CSS overrides are strongly discouraged
* Be more explicit about which palettes we provide
* Consolidate on a single approach to including theme CSS in an app (assuming Angular CLI)

I will send follow-up PRs for the typography, theming-your-components, and customizing-component-styles guides.
jelbourn added a commit to jelbourn/components that referenced this pull request Mar 30, 2021
This change completely rewrites the typography guide to be more
complete, correct, and concise.

Summary of changes:
* Explain the concepts of "typography level" and "typography config".
* Ensure all content is conceptual and not task-based.
* Use new Sass `@use` API introduiced in angular#22173
* Split up level descriptions from CSS classes
* Clarify that the system currently uses the 2014-era typography levels

This is the second PR in a series, following angular#22268. After this will be
PRs for theming-your-components, customizing-component-styles, and new
docs for strong focus indicators.
jelbourn added a commit to jelbourn/components that referenced this pull request Mar 30, 2021
This change completely rewrites the typography guide to be more
complete, correct, and concise.

Summary of changes:
* Explain the concepts of "typography level" and "typography config".
* Ensure all content is conceptual and not task-based.
* Use new Sass `@use` API introduiced in angular#22173
* Split up level descriptions from CSS classes
* Clarify that the system currently uses the 2014-era typography levels

This is the second PR in a series, following angular#22268. After this will be
PRs for theming-your-components, customizing-component-styles, and new
docs for strong focus indicators.
jelbourn added a commit to jelbourn/components that referenced this pull request Mar 31, 2021
This change completely rewrites the typography guide to be more
complete, correct, and concise.

Summary of changes:
* Explain the concepts of "typography level" and "typography config".
* Ensure all content is conceptual and not task-based.
* Use new Sass `@use` API introduiced in angular#22173
* Split up level descriptions from CSS classes
* Clarify that the system currently uses the 2014-era typography levels

This is the second PR in a series, following angular#22268. After this will be
PRs for theming-your-components, customizing-component-styles, and new
docs for strong focus indicators.
jelbourn added a commit to jelbourn/components that referenced this pull request Mar 31, 2021
This change completely rewrites the typography guide to be more
complete, correct, and concise.

Summary of changes:
* Explain the concepts of "typography level" and "typography config".
* Ensure all content is conceptual and not task-based.
* Use new Sass `@use` API introduiced in angular#22173
* Split up level descriptions from CSS classes
* Clarify that the system currently uses the 2014-era typography levels

This is the second PR in a series, following angular#22268. After this will be
PRs for theming-your-components, customizing-component-styles, and new
docs for strong focus indicators.
annieyw pushed a commit that referenced this pull request Apr 1, 2021
This change completely rewrites the typography guide to be more
complete, correct, and concise.

Summary of changes:
* Explain the concepts of "typography level" and "typography config".
* Ensure all content is conceptual and not task-based.
* Use new Sass `@use` API introduiced in #22173
* Split up level descriptions from CSS classes
* Clarify that the system currently uses the 2014-era typography levels

This is the second PR in a series, following #22268. After this will be
PRs for theming-your-components, customizing-component-styles, and new
docs for strong focus indicators.
jelbourn added a commit to jelbourn/components that referenced this pull request Apr 12, 2021
This change completely rewrites the theming-your-components guide to be
more complete, correct, and concise.

Summary of changes:
* Start document with some explanatory content before diving into
  step-by-step tutorial.
* Use new Sass `@use` API introduced in angular#22173
* Document (and expose) `get-color-config` and `get-typography-config`
jelbourn added a commit to jelbourn/components that referenced this pull request Apr 13, 2021
This change completely rewrites the theming-your-components guide to be
more complete, correct, and concise.

Summary of changes:
* Start document with some explanatory content before diving into
  step-by-step tutorial.
* Use new Sass `@use` API introduced in angular#22173
* Document (and expose) `get-color-config` and `get-typography-config`
mmalerba pushed a commit that referenced this pull request Apr 14, 2021
This change completely rewrites the theming-your-components guide to be
more complete, correct, and concise.

Summary of changes:
* Start document with some explanatory content before diving into
  step-by-step tutorial.
* Use new Sass `@use` API introduced in #22173
* Document (and expose) `get-color-config` and `get-typography-config`
@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 Apr 19, 2021
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 merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note P2 The issue is important to a large percentage of users, with a workaround target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants