refactor(docs-infra): clean up AIO Sass files (#42442)

Cleans up AIO's Sass files by:
* Switching them all over to the `@use`-based API from Angular Material.
* Removing the import of the Material theming API in a bunch of places that weren't using it.
* Migrating the new usages of Sass utility functions to the new syntax (e.g. `map.get` vs `map-get`).
* Fixing a few files that were using 4 spaces for indentation instead of 2.

PR Close #42442
This commit is contained in:
Kristiyan Kostadinov 2021-06-02 18:37:13 +02:00 committed by Andrew Kushnir
parent 0ac193c86c
commit 3d1c905c91
38 changed files with 193 additions and 179 deletions

View File

@ -1,7 +1,8 @@
@use 'sass:map';
@use '../constants';
@mixin theme($theme) {
$is-dark-theme: map-get($theme, is-dark);
$is-dark-theme: map.get($theme, is-dark);
body {
color: if($is-dark-theme, constants.$offwhite, constants.$darkgray);

View File

@ -1,13 +1,14 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@use '~@angular/material' as mat;
@mixin theme($theme) {
$primary: map-get($theme, primary);
$is-dark-theme: map-get($theme, is-dark);
$primary: map.get($theme, primary);
$is-dark-theme: map.get($theme, is-dark);
footer {
// Because the footer background is always the same color in both light and dark mode, there is no need to specify a foreground color
background-color: mat-color($primary, if($is-dark-theme, 900, 700));
background-color: mat.get-color-from-palette($primary, if($is-dark-theme, 900, 700));
aio-footer {
& > * {

View File

@ -1,13 +1,14 @@
@use 'sass:map';
@use '../../constants' ;
@import '~@angular/material/theming';
@use '~@angular/material' as mat;
@mixin theme($theme) {
$background: map-get($theme, background);
$is-dark-theme: map-get($theme, is-dark);
$background: map.get($theme, background);
$is-dark-theme: map.get($theme, is-dark);
html,
body,
.content {
background: if($is-dark-theme, mat-color($background, background), constants.$white);
background: if($is-dark-theme, mat.get-color-from-palette($background, background), constants.$white);
}
}

View File

@ -1,14 +1,15 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@use '~@angular/material' as mat;
@mixin theme($theme) {
$primary: map-get($theme, primary);
$foreground: map-get($theme, foreground);
$is-dark-theme: map-get($theme, is-dark);
$primary: map.get($theme, primary);
$foreground: map.get($theme, foreground);
$is-dark-theme: map.get($theme, is-dark);
.background-sky {
background: linear-gradient(145deg, mat-color($primary, 900), if($is-dark-theme, mat-color($primary, 700), #42a5f5));
color: mat-color($foreground, text);
background: linear-gradient(145deg, mat.get-color-from-palette($primary, 900), if($is-dark-theme, mat.get-color-from-palette($primary, 700), #42a5f5));
color: mat.get-color-from-palette($foreground, text);
}
section#intro {
@ -59,7 +60,7 @@
}
.marketing-banner {
background-color: if($is-dark-theme, mat-color($primary, 800), mat-color($primary, 600));
background-color: if($is-dark-theme, mat.get-color-from-palette($primary, 800), mat.get-color-from-palette($primary, 600));
.banner-headline {
color: constants.$white;

View File

@ -1,8 +1,8 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
$is-dark-theme: map-get($theme, is-dark);
$is-dark-theme: map.get($theme, is-dark);
.nf-response {
h1 {

View File

@ -1,12 +1,13 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@use '~@angular/material' as mat;
@mixin theme($theme) {
$background: map-get($theme, background);
$is-dark-theme: map-get($theme, is-dark);
$background: map.get($theme, background);
$is-dark-theme: map.get($theme, is-dark);
mat-sidenav-container.sidenav-container {
background-color: if($is-dark-theme, mat-color($background, background), constants.$white);
background-color: if($is-dark-theme, mat.get-color-from-palette($background, background), constants.$white);
mat-sidenav.sidenav {
background-color: if($is-dark-theme, constants.$deepgray, constants.$superlightgray);

View File

@ -1,21 +1,22 @@
@use 'sass:map';
@use '../../constants';
@use '../../mixins';
@import '~@angular/material/theming';
@use '~@angular/material' as mat;
@mixin theme($theme) {
$primary: map-get($theme, primary);
$is-dark-theme: map-get($theme, is-dark);
$primary: map.get($theme, primary);
$is-dark-theme: map.get($theme, is-dark);
mat-toolbar.app-toolbar {
@if $is-dark-theme {
&.mat-primary {
background: mat-color($primary, darker)
background: mat.get-color-from-palette($primary, darker)
}
}
// HOME PAGE OVERRIDE: TOPNAV TOOLBAR
.page-home & {
background: if($is-dark-theme, mat-color($primary, darker), constants.$blue);
background: if($is-dark-theme, mat.get-color-from-palette($primary, darker), constants.$blue);
}
mat-icon {

View File

@ -1,5 +1,6 @@
@use '../constants' as *;
@use '../mixins' as *;
@use 'sass:color';
@use '../constants';
@use '../mixins';
code-example,
code-tabs {
@ -52,7 +53,7 @@ code-example {
background-color: $accentblue;
border-radius: 5px 5px 0 0;
color: $offwhite;
@include font-size(16);
@include mixins.font-size(16);
padding: 8px 16px;
}
}
@ -110,21 +111,21 @@ aio-code {
}
span {
@include line-height(24);
@include mixins.line-height(24);
}
ol.linenums {
margin: 0;
color: lighten($mediumgray, 25%);
color: color.adjust($mediumgray, $lightness: 25%);
li {
margin: 0;
font-family: $code-font;
font-size: 90%;
@include line-height(24);
@include mixins.line-height(24);
&::marker {
color: lighten($mediumgray, 25%);
color: color.adjust($mediumgray, $lightness: 25%);
}
}
}

View File

@ -1,8 +1,8 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
$is-dark-theme: map-get($theme, is-dark);
$is-dark-theme: map.get($theme, is-dark);
.alert {
color: if($is-dark-theme, constants.$offwhite, constants.$darkgray);

View File

@ -1,9 +1,9 @@
@use 'sass:map';
@use '../../constants';
@use '../../mixins';
@import '~@angular/material/theming';
@mixin theme($theme) {
$is-dark-theme: map-get($theme, is-dark);
$is-dark-theme: map.get($theme, is-dark);
aio-api-list {
.api-filter {

View File

@ -1,5 +1,4 @@
@use '../../constants';
@import '~@angular/material/theming';
@mixin api-pages-theme($theme) {
.api-body {

View File

@ -1,5 +1,5 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
.symbol {
@ -10,10 +10,10 @@
// Symbol mapping variables in *constants*
@each $name, $symbol in constants.$api-symbols {
&.#{$name} {
background: map-get($symbol, background);
background: map.get($symbol, background);
&:before {
content: map-get($symbol, content);
content: map.get($symbol, content);
}
}
}

View File

@ -1,5 +1,5 @@
@use 'sass:color';
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
// This rule overrides some Angular Material styles defined for `.mat-button`
@ -20,7 +20,7 @@
&.button-subtle {
background: constants.$mediumgray;
color: darken(constants.$offwhite, 10%);
color: color.adjust(constants.$offwhite, $lightness: -10%);
&:hover {
color: rgba(constants.$white, 0.7);

View File

@ -1,40 +1,39 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
$is-dark-theme: map-get($theme, is-dark);
$is-dark-theme: map.get($theme, is-dark);
.callout {
header {
color: constants.$white;
}
.callout {
header {
color: constants.$white;
}
&.is-critical {
border-color: constants.$brightred;
background: rgba(constants.$brightred, if($is-dark-theme, 0.1, 0.05));
header {
background: constants.$brightred;
}
}
&.is-important {
border-color: constants.$orange;
background: rgba(constants.$orange,if($is-dark-theme, 0.1, 0.05));
header {
background: constants.$amber-700;
}
}
&.is-helpful {
border-color: constants.$blue;
background: rgba(constants.$blue, if($is-dark-theme, 0.1, 0.05));
header {
background: constants.$blue;
}
}
&.is-critical {
border-color: constants.$brightred;
background: rgba(constants.$brightred, if($is-dark-theme, 0.1, 0.05));
header {
background: constants.$brightred;
}
}
&.is-important {
border-color: constants.$orange;
background: rgba(constants.$orange,if($is-dark-theme, 0.1, 0.05));
header {
background: constants.$amber-700;
}
}
&.is-helpful {
border-color: constants.$blue;
background: rgba(constants.$blue, if($is-dark-theme, 0.1, 0.05));
header {
background: constants.$blue;
}
}
}
}

View File

@ -1,8 +1,8 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
$is-dark-theme: map-get($theme, is-dark);
@mixin theme($theme) {
$is-dark-theme: map.get($theme, is-dark);
.card-container {
.docs-card {

View File

@ -1,8 +1,9 @@
@use 'sass:color';
@use 'sass:map';
@use '../../constants';
@import "~@angular/material/theming";
@mixin theme($theme) {
$is-dark-theme: map-get($theme, is-dark);
$is-dark-theme: map.get($theme, is-dark);
code-example {
&:not(.no-box) {
@ -51,11 +52,11 @@
pre.prettyprint {
code {
ol.linenums {
color: lighten(constants.$mediumgray, 25%);
color: color.adjust(constants.$mediumgray, $lightness: 25%);
li {
&::marker {
color: lighten(constants.$mediumgray, 25%);
color: color.adjust(constants.$mediumgray, $lightness: 25%);
}
}
}

View File

@ -1,11 +1,12 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@use '~@angular/material' as mat;
@mixin theme($theme) {
$background: map-get($theme, background);
$background: map.get($theme, background);
aio-contributor {
background: mat-color($background, background);
background: mat.get-color-from-palette($background, background);
.contributor-info {
background: rgba(constants.$darkgray, 0.5);

View File

@ -1,18 +1,19 @@
@use 'sass:map';
@use '../../constants';
@use '../../mixins';
@mixin theme($theme) {
$is-dark-theme: map-get($theme, is-dark);
$is-dark-theme: map.get($theme, is-dark);
aio-shell.mode-archive {
@include mixins.deploy-theme(constants.$blue-grey-900, constants.$blue-grey-400, if($is-dark-theme, constants.$powderblue, constants.$blue-grey-900));
}
aio-shell.mode-next {
@include mixins.deploy-theme(constants.$brightred, constants.$darkred, if($is-dark-theme, constants.$powderblue, constants.$brightred));
}
aio-shell.mode-rc {
@include mixins.deploy-theme(constants.$tangerine, constants.$darkgoldenrod, if($is-dark-theme, constants.$powderblue, constants.$tangerine));
}
}
}

View File

@ -1,5 +1,4 @@
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
details {

View File

@ -1,3 +1,4 @@
@use 'sass:selector';
@use '../../constants';
@use '../../mixins';
@ -33,7 +34,7 @@ details {
i.material-icons.expand {
@include mixins.rotate(0deg);
@at-root #{selector-replace(&, 'details', 'details[open]')} {
@at-root #{selector.replace(&, 'details', 'details[open]')} {
@include mixins.rotate(180deg);
}
}

View File

@ -1,5 +1,4 @@
@use '../../constants';
@import "~@angular/material/theming";
@mixin theme($theme) {
.error-list {

View File

@ -1,5 +1,4 @@
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
.filetree {

View File

@ -1,10 +1,11 @@
@use 'sass:color';
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
$is-dark-theme: map-get($theme, is-dark);
$is-dark-theme: map.get($theme, is-dark);
.reviewed {
color: if($is-dark-theme, constants.$offwhite, lighten(constants.$darkgray, 10));
}
.reviewed {
color: if($is-dark-theme, constants.$offwhite, color.adjust(constants.$darkgray, $lightness: 10%));
}
}

View File

@ -1,5 +1,4 @@
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
.sidenav-content {

View File

@ -1,8 +1,8 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
$is-dark-theme: map-get($theme, is-dark);
$is-dark-theme: map.get($theme, is-dark);
hr {
background: if($is-dark-theme, constants.$mediumgray, constants.$lightgray);

View File

@ -1,8 +1,8 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
$is-dark-theme: map-get($theme, is-dark);
$is-dark-theme: map.get($theme, is-dark);
.content {
.lightbox {

View File

@ -1,36 +1,36 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
.api-header label {
color: constants.$white;
.api-header label {
color: constants.$white;
&.api-status-label {
background-color: constants.$mediumgray;
&.deprecated, &.security, &.impure-pipe {
background-color: constants.$brightred;
}
}
&.api-type-label {
background-color: constants.$accentblue;
@each $name, $symbol in constants.$api-symbols {
&.#{$name} {
background: map-get($symbol, background);
}
}
}
&.page-label {
background-color: constants.$mist;
color: constants.$mediumgray;
}
&.property-type-label {
background-color: constants.$darkgray;
color: constants.$white;
&.api-status-label {
background-color: constants.$mediumgray;
&.deprecated, &.security, &.impure-pipe {
background-color: constants.$brightred;
}
}
&.api-type-label {
background-color: constants.$accentblue;
@each $name, $symbol in constants.$api-symbols {
&.#{$name} {
background: map.get($symbol, background);
}
}
}
&.page-label {
background-color: constants.$mist;
color: constants.$mediumgray;
}
&.property-type-label {
background-color: constants.$darkgray;
color: constants.$white;
}
}
}

View File

@ -1,5 +1,4 @@
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
aio-notification {

View File

@ -1,9 +1,10 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@use '~@angular/material' as mat;
@mixin theme($theme) {
$background: map-get($theme, background);
$is-dark-theme: map-get($theme, is-dark);
$background: map.get($theme, background);
$is-dark-theme: map.get($theme, is-dark);
.presskit-container {
.presskit-section {
@ -18,7 +19,7 @@
background-color: constants.$white;
&-inverse {
background-color: if($is-dark-theme, mat-color($background, background), constants.$deepgray);
background-color: if($is-dark-theme, mat.get-color-from-palette($background, background), constants.$deepgray);
}
}
}

View File

@ -1,8 +1,8 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@mixin theme($theme) {
$is-dark-theme: map-get($theme, is-dark);
$is-dark-theme: map.get($theme, is-dark);
aio-resource-list {
.subcategory-title {

View File

@ -1,9 +1,11 @@
@use 'sass:color';
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@use '~@angular/material' as mat;
@mixin theme($theme) {
$foreground: map-get($theme, foreground);
$is-dark-theme: map-get($theme, is-dark);
$foreground: map.get($theme, foreground);
$is-dark-theme: map.get($theme, is-dark);
aio-search-results {
.search-results {
@ -17,7 +19,7 @@
ul {
.search-result-item {
color: if($is-dark-theme, constants.$offwhite , constants.$lightgray);
color: if($is-dark-theme, constants.$offwhite, constants.$lightgray);
&:hover {
color: constants.$white;
@ -27,11 +29,11 @@
}
.no-results {
color: mat-color($foreground, text);
color: mat.get-color-from-palette($foreground, text);
}
a {
color: mat-color($foreground, text);
color: mat.get-color-from-palette($foreground, text);
}
}
@ -43,7 +45,7 @@
}
.search-result-item {
color: if($is-dark-theme, constants.$offwhite ,lighten(constants.$darkgray, 10));
color: if($is-dark-theme, constants.$offwhite, color.adjust(constants.$darkgray, $lightness: 10%));
&:hover {
color: constants.$accentblue;
@ -52,7 +54,7 @@
}
.no-results {
color: mat-color($foreground, text);
color: mat.get-color-from-palette($foreground, text);
}
a {

View File

@ -1,9 +1,10 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@use '~@angular/material' as mat;
@mixin theme($theme) {
$background: map-get($theme, background);
$is-dark-theme: map-get($theme, is-dark);
$background: map.get($theme, background);
$is-dark-theme: map.get($theme, is-dark);
aio-select {
.form-select-button {
@ -23,7 +24,7 @@
}
.form-select-dropdown {
background: mat-color($background, background);
background: mat.get-color-from-palette($background, background);
box-shadow: 0 16px 16px rgba(constants.$black, 0.24), 0 0 16px rgba(constants.$black, 0.12);
li {

View File

@ -1,13 +1,14 @@
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@use '~@angular/material' as mat;
@mixin theme($theme) {
$background: map-get($theme, background);
$is-dark-theme: map-get($theme, is-dark);
$background: map.get($theme, background);
$is-dark-theme: map.get($theme, is-dark);
table {
box-shadow: 0 2px 2px rgba(constants.$mediumgray, 0.24), 0 0 2px rgba(if($is-dark-theme, constants.$white, constants.$black), 0.12);
background-color: if($is-dark-theme, mat-color($background, background), constants.$white);
background-color: if($is-dark-theme, mat.get-color-from-palette($background, background), constants.$white);
thead > {
tr > th {

View File

@ -1,9 +1,11 @@
@use 'sass:color';
@use 'sass:map';
@use '../../constants';
@import '~@angular/material/theming';
@use '~@angular/material' as mat;
@mixin theme($theme) {
$foreground: map-get($theme, foreground);
$is-dark-theme: map-get($theme, is-dark);
$foreground: map.get($theme, foreground);
$is-dark-theme: map.get($theme, is-dark);
aio-toc {
.toc-inner {
@ -46,7 +48,7 @@
}
a {
color: if($is-dark-theme, constants.$white, lighten(constants.$darkgray, 10));
color: if($is-dark-theme, constants.$white, color.adjust(constants.$darkgray, $lightness: 10%));
}
&:hover {
@ -84,7 +86,7 @@
.toc-inner {
.toc-heading {
&.secondary {
color: mat-color($foreground, text);
color: mat.get-color-from-palette($foreground, text);
}
}
}

View File

@ -1,3 +1,5 @@
@use 'sass:list';
@use 'sass:selector';
@use './constants';
// REM Font Adjustments
@ -127,7 +129,7 @@
);
@if $nestParentSelector and & {
@at-root #{selector-nest(#{$selectors}, &)} {
@at-root #{selector.nest(#{$selectors}, &)} {
@content;
}
} @else {
@ -179,10 +181,10 @@
'.page-presskit',
'.page-resources',
);
$selectors: join($marketingPagesSelectors, $extraSelectors, $separator: comma);
$selectors: list.join($marketingPagesSelectors, $extraSelectors, $separator: comma);
@if $nestParentSelector and & {
@at-root #{selector-nest(#{$selectors}, &)} {
@at-root #{selector.nest(#{$selectors}, &)} {
@content;
}
} @else {

View File

@ -1,10 +1,10 @@
@use '../app-theme';
@import "~@angular/material/theming";
@use '~@angular/material' as mat;
$ng-io-primary: mat-palette($mat-blue, 700, 600, 900);
$ng-io-accent: mat-palette($mat-red, 700, 600, 800);
$ng-io-warn: mat-palette($mat-red);
$ng-io-theme: mat-dark-theme($ng-io-primary, $ng-io-accent, $ng-io-warn);
$ng-io-primary: mat.define-palette(mat.$blue-palette, 700, 600, 900);
$ng-io-accent: mat.define-palette(mat.$red-palette, 700, 600, 800);
$ng-io-warn: mat.define-palette(mat.$red-palette);
$ng-io-theme: mat.define-dark-theme($ng-io-primary, $ng-io-accent, $ng-io-warn);
@include angular-material-theme($ng-io-theme);
@include mat.all-component-themes($ng-io-theme);
@include app-theme.theme($ng-io-theme);

View File

@ -1,10 +1,10 @@
@use '../app-theme';
@import '~@angular/material/theming';
@use '~@angular/material' as mat;
$ng-io-primary: mat-palette($mat-blue, 700, 600, 800);
$ng-io-accent: mat-palette($mat-red, 700, 600, 800);
$ng-io-warn: mat-palette($mat-red);
$ng-io-theme: mat-light-theme($ng-io-primary, $ng-io-accent, $ng-io-warn);
$ng-io-primary: mat.define-palette(mat.$blue-palette, 700, 600, 800);
$ng-io-accent: mat.define-palette(mat.$red-palette, 700, 600, 800);
$ng-io-warn: mat.define-palette(mat.$red-palette);
$ng-io-theme: mat.define-light-theme($ng-io-primary, $ng-io-accent, $ng-io-warn);
@include angular-material-theme($ng-io-theme);
@include mat.all-component-themes($ng-io-theme);
@include app-theme.theme($ng-io-theme);

View File

@ -6,8 +6,8 @@
// import print styles
@use './print';
@import '~@angular/material/theming';
@use '~@angular/material' as mat;
// Include the base styles for Angular Material core. We include this here so that you only
// have to load a single css file for Angular Material in your app.
@include mat-core();
@include mat.core();