_id
stringlengths 21
254
| text
stringlengths 1
93.7k
| metadata
dict |
---|---|---|
components/src/material/core/theming/_all-theme.scss_0_4906 | // Import all the theming functionality.
@use '../core-theme';
@use '../../autocomplete/autocomplete-theme';
@use '../../badge/badge-theme';
@use '../../bottom-sheet/bottom-sheet-theme';
@use '../../button/button-theme';
@use '../../button/icon-button-theme';
@use '../../button/fab-theme';
@use '../../button-toggle/button-toggle-theme';
@use '../../card/card-theme';
@use '../../checkbox/checkbox-theme';
@use '../../chips/chips-theme';
@use '../../table/table-theme';
@use '../../datepicker/datepicker-theme';
@use '../../dialog/dialog-theme';
@use '../../divider/divider-theme';
@use '../../expansion/expansion-theme';
@use '../../grid-list/grid-list-theme';
@use '../../icon/icon-theme';
@use '../../input/input-theme';
@use '../../list/list-theme';
@use '../../menu/menu-theme';
@use '../../paginator/paginator-theme';
@use '../../progress-bar/progress-bar-theme';
@use '../../progress-spinner/progress-spinner-theme';
@use '../../radio/radio-theme';
@use '../../select/select-theme';
@use '../../sidenav/sidenav-theme';
@use '../../slide-toggle/slide-toggle-theme';
@use '../../slider/slider-theme';
@use '../../stepper/stepper-theme';
@use '../../sort/sort-theme';
@use '../../tabs/tabs-theme';
@use '../../toolbar/toolbar-theme';
@use '../../tooltip/tooltip-theme';
@use '../../tree/tree-theme';
@use '../../snack-bar/snack-bar-theme';
@use '../../form-field/form-field-theme';
@use '../../timepicker/timepicker-theme';
@use './theming';
// Create a theme.
@mixin all-component-themes($theme) {
$dedupe-key: 'angular-material-theme';
@include theming.private-check-duplicate-theme-styles($theme, $dedupe-key) {
@include core-theme.theme($theme);
@include card-theme.theme($theme);
@include progress-bar-theme.theme($theme);
@include tooltip-theme.theme($theme);
@include form-field-theme.theme($theme);
@include input-theme.theme($theme);
@include select-theme.theme($theme);
@include autocomplete-theme.theme($theme);
@include dialog-theme.theme($theme);
@include chips-theme.theme($theme);
@include slide-toggle-theme.theme($theme);
@include radio-theme.theme($theme);
@include slider-theme.theme($theme);
@include menu-theme.theme($theme);
@include list-theme.theme($theme);
@include paginator-theme.theme($theme);
@include tabs-theme.theme($theme);
@include checkbox-theme.theme($theme);
@include button-theme.theme($theme);
@include icon-button-theme.theme($theme);
@include fab-theme.theme($theme);
@include snack-bar-theme.theme($theme);
@include table-theme.theme($theme);
@include progress-spinner-theme.theme($theme);
@include badge-theme.theme($theme);
@include bottom-sheet-theme.theme($theme);
@include button-toggle-theme.theme($theme);
@include datepicker-theme.theme($theme);
@include divider-theme.theme($theme);
@include expansion-theme.theme($theme);
@include grid-list-theme.theme($theme);
@include icon-theme.theme($theme);
@include sidenav-theme.theme($theme);
@include stepper-theme.theme($theme);
@include sort-theme.theme($theme);
@include toolbar-theme.theme($theme);
@include tree-theme.theme($theme);
@include timepicker-theme.theme($theme);
}
}
@mixin all-component-bases($theme) {
@include core-theme.base($theme);
@include card-theme.base($theme);
@include progress-bar-theme.base($theme);
@include tooltip-theme.base($theme);
@include form-field-theme.base($theme);
@include input-theme.base($theme);
@include select-theme.base($theme);
@include autocomplete-theme.base($theme);
@include dialog-theme.base($theme);
@include chips-theme.base($theme);
@include slide-toggle-theme.base($theme);
@include radio-theme.base($theme);
@include slider-theme.base($theme);
@include menu-theme.base($theme);
@include list-theme.base($theme);
@include paginator-theme.base($theme);
@include tabs-theme.base($theme);
@include checkbox-theme.base($theme);
@include button-theme.base($theme);
@include icon-button-theme.base($theme);
@include fab-theme.base($theme);
@include snack-bar-theme.base($theme);
@include table-theme.base($theme);
@include progress-spinner-theme.base($theme);
@include badge-theme.base($theme);
@include bottom-sheet-theme.base($theme);
@include button-toggle-theme.base($theme);
@include datepicker-theme.base($theme);
@include divider-theme.base($theme);
@include expansion-theme.base($theme);
@include grid-list-theme.base($theme);
@include icon-theme.base($theme);
@include sidenav-theme.base($theme);
@include stepper-theme.base($theme);
@include sort-theme.base($theme);
@include toolbar-theme.base($theme);
@include tree-theme.base($theme);
@include timepicker-theme.base($theme);
}
// @deprecated Use `all-component-themes`.
@mixin angular-material-theme($theme) {
@include all-component-themes($theme);
}
| {
"end_byte": 4906,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/_all-theme.scss"
} |
components/src/material/core/theming/_theming.scss_0_7858 | @use 'sass:list';
@use 'sass:map';
@use 'sass:math';
@use 'sass:meta';
// Whether to enable compatibility with legacy methods for accessing theme information.
$theme-legacy-inspection-api-compatibility: true !default;
// Whether duplication warnings should be disabled. Warnings enabled by default.
$theme-ignore-duplication-warnings: false !default;
// Whether density should be generated by default.
$_generate-default-density: true !default;
// Warning that will be printed if duplicated styles are generated by a theme.
$_duplicate-warning: 'Read more about how style duplication can be avoided in a dedicated ' +
'guide. https://github.com/angular/components/blob/main/guides/duplicate-theming-styles.md';
// Warning that will be printed if the legacy theming API is used.
$private-legacy-theme-warning: 'Angular Material themes should be created from a map containing ' +
'the keys "color", "typography", and "density". The color value should be a map containing the ' +
'palette values for "primary", "accent", and "warn". ' +
'See https://material.angular.io/guide/theming for more information.';
// Flag whether to disable theme definitions copying color values to the top-level theme config.
// This copy is to preserve backwards compatibility.
$_disable-color-backwards-compatibility: false;
// These variable are not intended to be overridden externally. They use `!default` to
// avoid being reset every time this file is imported.
$_emitted-color: () !default;
$_emitted-typography: () !default;
$_emitted-density: () !default;
$_emitted-base: () !default;
//
// Private APIs
//
$private-internal-name: _mat-theming-internals-do-not-access;
// Checks if configurations that have been declared in the given theme have been generated
// before. If so, warnings will be reported. This should notify developers in case duplicate
// styles are accidentally generated due to wrong usage of the all-theme mixins.
//
// Additionally, this mixin controls the default value for the density configuration. By
// default, density styles are generated at scale zero. If the same density styles would be
// generated a second time though, the default value will change to avoid duplicate styles.
//
// The mixin keeps track of all configurations in a list that is scoped to the specified
// id. This is necessary because a given theme can be passed to multiple disjoint theme mixins
// (e.g. `all-component-themes` and `all-legacy-component-themes`) without causing any
// style duplication.
@mixin private-check-duplicate-theme-styles($theme-or-color-config, $id) {
// TODO(mmalerba): use get-theme-version for this check when its moved out of experimental.
@if map.get($theme-or-color-config, $private-internal-name, theme-version) == 1 {
@include _check-duplicate-theme-styles-v1($theme-or-color-config, $id) {
// Optionally, consumers of this mixin can wrap contents inside so that nested
// duplicate style checks do not report another warning. e.g. if developers include
// the `all-component-themes` mixin twice, only the top-level duplicate styles check
// should report a warning. Not all individual components should report a warning too.
$orig-mat-theme-ignore-duplication-warnings: $theme-ignore-duplication-warnings;
$theme-ignore-duplication-warnings: true !global;
@content;
$theme-ignore-duplication-warnings: $orig-mat-theme-ignore-duplication-warnings !global;
}
}
@else {
@include _check-duplicate-theme-styles-v0($theme-or-color-config, $id) {
// Optionally, consumers of this mixin can wrap contents inside so that nested
// duplicate style checks do not report another warning. e.g. if developers include
// the `all-component-themes` mixin twice, only the top-level duplicate styles check
// should report a warning. Not all individual components should report a warning too.
$orig-mat-theme-ignore-duplication-warnings: $theme-ignore-duplication-warnings;
$theme-ignore-duplication-warnings: true !global;
@content;
$theme-ignore-duplication-warnings: $orig-mat-theme-ignore-duplication-warnings !global;
}
}
}
/// Strip out any settings map entries that have empty values (null or ()).
@function _strip-empty-settings($settings) {
$result: ();
@each $key, $value in $settings {
@if $value != null and $value != () {
$result: map.set($result, $key, $value);
}
}
@return if($result == (), null, $result);
}
// Checks for duplicate styles in a `theme-version: 1` style theme.
@mixin _check-duplicate-theme-styles-v1($theme-or-color-config, $id) {
$color-settings: _strip-empty-settings((
theme-type: map.get($theme-or-color-config, $private-internal-name, theme-type),
color-tokens: map.get($theme-or-color-config, $private-internal-name, color-tokens),
));
$typography-settings: _strip-empty-settings((
typography-tokens:
map.get($theme-or-color-config, $private-internal-name, typography-tokens),
));
$density-settings: _strip-empty-settings((
density-scale:
map.get($theme-or-color-config, $private-internal-name, density-scale),
density-tokens:
map.get($theme-or-color-config, $private-internal-name, density-tokens),
));
$base-settings: _strip-empty-settings((
base-tokens: map.get($theme-or-color-config, $private-internal-name, base-tokens),
));
$previous-color-settings: map.get($_emitted-color, $id) or ();
$previous-typography-settings: map.get($_emitted-typography, $id) or ();
$previous-density-settings: map.get($_emitted-density, $id) or ();
$previous-base-settings: map.get($_emitted-base, $id) or ();
// Check if the color configuration has been generated before.
@if $color-settings != null {
@if list.index($previous-color-settings, $color-settings) != null and
not $theme-ignore-duplication-warnings {
@warn 'The same color styles are generated multiple times. ' + $_duplicate-warning;
}
$previous-color-settings: list.append($previous-color-settings, $color-settings);
}
// Check if the typography configuration has been generated before.
@if $typography-settings != null {
@if list.index($previous-typography-settings, $typography-settings) != null and
not $theme-ignore-duplication-warnings {
@warn 'The same typography styles are generated multiple times. ' + $_duplicate-warning;
}
$previous-typography-settings: list.append($previous-typography-settings, $typography-settings);
}
// Check if the density configuration has been generated before.
@if $density-settings != null {
@if list.index($previous-density-settings, $density-settings) != null and
not $theme-ignore-duplication-warnings {
@warn 'The same density styles are generated multiple times. ' + $_duplicate-warning;
}
$previous-density-settings: list.append($previous-density-settings, $density-settings);
}
// Check if the base configuration has been generated before.
@if $base-settings != null {
@if list.index($previous-base-settings, $base-settings) != null and
not $theme-ignore-duplication-warnings {
@warn 'The same base theme styles are generated multiple times. ' + $_duplicate-warning;
}
$previous-base-settings: list.append($previous-base-settings, $base-settings);
}
$_emitted-color: map.set($_emitted-color, $id, $previous-color-settings) !global;
$_emitted-density: map.set($_emitted-density, $id, $previous-density-settings) !global;
$_emitted-typography: map.set($_emitted-typography, $id, $previous-typography-settings) !global;
$_emitted-base: map.set($_emitted-base, $id, $previous-base-settings) !global;
@content;
}
// Checks for duplicate styles in a `theme-version: 0` style theme.
@mixin _check-duplicate-theme-styles-v0($theme-or-color-config, $id) | {
"end_byte": 7858,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/_theming.scss"
} |
components/src/material/core/theming/_theming.scss_7859_16167 | {
$theme: private-legacy-get-theme($theme-or-color-config);
$color-config: map.get($theme, $private-internal-name, m2-config, color) or
private-get-color-config($theme);
$density-config: map.get($theme, $private-internal-name, m2-config, density) or
private-get-density-config($theme);
$typography-config: map.get($theme, $private-internal-name, m2-config, typography) or
private-get-typography-config($theme);
// Lists of previous `color`, `density` and `typography` configurations.
$previous-color: map.get($_emitted-color, $id) or ();
$previous-typography: map.get($_emitted-typography, $id) or ();
$previous-density: map.get($_emitted-density, $id) or ();
// Whether duplicate legacy density styles would be generated.
$duplicate-legacy-density: false;
// Check if the color configuration has been generated before.
@if $color-config != null {
@if list.index($previous-color, $color-config) != null and
not $theme-ignore-duplication-warnings {
@warn 'The same color styles are generated multiple times. ' + $_duplicate-warning;
}
$previous-color: list.append($previous-color, $color-config);
}
// Check if the typography configuration has been generated before.
@if $typography-config != null {
@if list.index($previous-typography, $typography-config) != null and
not $theme-ignore-duplication-warnings {
@warn 'The same typography styles are generated multiple times. ' + $_duplicate-warning;
}
$previous-typography: list.append($previous-typography, $typography-config);
}
// Check if the density configuration has been generated before.
@if $density-config != null {
@if list.index($previous-density, $density-config) != null {
// Only report a warning if density styles would be duplicated for non-legacy theme
// definitions. For legacy themes, we have compatibility logic that avoids duplication
// of default density styles. We don't want to report a warning in those cases.
@if private-is-legacy-constructed-theme($theme) {
$duplicate-legacy-density: true;
}
@else if not $theme-ignore-duplication-warnings {
@warn 'The same density styles are generated multiple times. ' + $_duplicate-warning;
}
}
$previous-density: list.append($previous-density, $density-config);
}
$_emitted-color: map.merge($_emitted-color, ($id: $previous-color)) !global;
$_emitted-density: map.merge($_emitted-density, ($id: $previous-density)) !global;
$_emitted-typography: map.merge($_emitted-typography, ($id: $previous-typography)) !global;
@content;
}
// Checks whether the given value resolves to a theme object. Theme objects are always
// of type `map` and can optionally only specify `color`, `density` or `typography`.
@function private-is-theme-object($value) {
@return meta.type-of($value) == 'map' and (
map.has-key($value, color) or
map.has-key($value, density) or
map.has-key($value, typography) or
list.length($value) == 0
);
}
// Checks whether a given value corresponds to a legacy constructed theme.
@function private-is-legacy-constructed-theme($value) {
@return meta.type-of($value) == 'map' and map.get($value, '_is-legacy-theme');
}
// This is the implementation of the `m2-get-color-config` function.
// It's declared here to avoid a circular reference between this file and `m2/_theming.scss`.
@function private-get-color-config($theme, $default: null) {
// If a configuration has been passed, return the config directly.
@if not private-is-theme-object($theme) {
@return $theme;
}
// If the theme has been constructed through the legacy theming API, we use the theme object
// as color configuration instead of the dedicated `color` property. We do this because for
// backwards compatibility, we copied the color configuration from `$theme.color` to `$theme`.
// Hence developers could customize the colors at top-level and want to respect these changes
// TODO: Remove when legacy theming API is removed.
@if private-is-legacy-constructed-theme($theme) {
@return $theme;
}
@if map.has-key($theme, color) {
@return map.get($theme, color);
}
@return $default;
}
// This is the implementation of the `m2-get-density-config` function.
// It's declared here to avoid a circular reference between this file and `m2/_theming.scss`.
@function private-get-density-config($theme-or-config, $default: 0) {
// If a configuration has been passed, return the config directly.
@if not private-is-theme-object($theme-or-config) {
@return $theme-or-config;
}
// In case a theme has been passed, extract the configuration if present,
// or fall back to the default density config.
@if map.has-key($theme-or-config, density) {
@return map.get($theme-or-config, density);
}
@return $default;
}
// This is the implementation of the `m2-get-typography-config` function.
// It's declared here to avoid a circular reference between this file and `m2/_theming.scss`.
@function private-get-typography-config($theme-or-config, $default: null) {
// If a configuration has been passed, return the config directly.
@if not private-is-theme-object($theme-or-config) {
@return $theme-or-config;
}
// In case a theme has been passed, extract the configuration if present,
// or fall back to the default typography config.
@if (map.has-key($theme-or-config, typography)) {
@return map.get($theme-or-config, typography);
}
@return $default;
}
// Creates a backwards compatible theme. Previously in Angular Material, theme objects
// contained the color configuration directly. With the recent refactoring of the theming
// system to allow for density and typography configurations, this is no longer the case.
// To ensure that constructed themes which will be passed to custom theme mixins do not break,
// we copy the color configuration and put its properties at the top-level of the theme object.
// Here is an example of a pattern that should still work until it's officially marked as a
// breaking change:
//
// @mixin my-custom-component-theme($theme) {
// .my-comp {
// background-color: mat.m2-get-color-from-palette(map.get($theme, primary));
// }
// }
//
// Note that the `$theme.primary` key does usually not exist since the color configuration
// is stored in `$theme.color` which contains a property for `primary`. This method copies
// the map from `$theme.color` to `$theme` for backwards compatibility.
@function private-create-backwards-compatibility-theme($theme) {
@if ($_disable-color-backwards-compatibility or not map.get($theme, color)) {
@return $theme;
}
$color: map.get($theme, color);
@return map.merge($theme, $color);
}
// Gets the theme from the given value that is either already a theme, or a color configuration.
// This handles the legacy case where developers pass a color configuration directly to the
// theme mixin. Before we introduced the new pattern for constructing a theme, developers passed
// the color configuration directly to the theme mixins. This can be still the case if developers
// construct a theme manually and pass it to a theme. We support this for backwards compatibility.
// TODO(devversion): remove this in the future. Constructing themes manually is rare,
// and the code can be easily updated to the new API.
@function private-legacy-get-theme($theme-or-color-config) {
@if private-is-theme-object($theme-or-color-config) or
map.get($theme-or-color-config, $private-internal-name, theme-version) == 1 {
@return $theme-or-color-config;
}
@warn $private-legacy-theme-warning;
@return private-create-backwards-compatibility-theme((
_is-legacy-theme: true,
color: $theme-or-color-config
));
}
// Approximates an rgba color into a solid hex color, given a background color.
@function private-rgba-to-hex($color, $background-color) {
// We convert the rgba color into a solid one by taking the opacity from the rgba
// value and using it to determine the percentage of the background to put
// into foreground when mixing the colors together.
@return mix($background-color, rgba($color, 1), (1 - opacity($color)) * 100%);
}
// Clamps the density scale to a number between the given min and max. | {
"end_byte": 16167,
"start_byte": 7859,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/_theming.scss"
} |
components/src/material/core/theming/_theming.scss_16168_16662 | // 'minimum' and 'maximum' are converted to the given min or max number respectively.
@function clamp-density($density-scale, $min, $max: 0) {
@if $density-scale == minimum {
@return $min;
}
@if $density-scale == maximum {
@return $max;
}
@if meta.type-of($density-scale) != 'number' or not math.is-unitless($density-scale) {
@return 0;
}
@if $density-scale < $min {
@return $min;
}
@if $density-scale > $max {
@return $max;
}
@return $density-scale;
} | {
"end_byte": 16662,
"start_byte": 16168,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/_theming.scss"
} |
components/src/material/core/theming/_validation.scss_0_74 | @mixin selector-defined($msg) {
@if #{&} == '' {
@error $msg;
}
}
| {
"end_byte": 74,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/_validation.scss"
} |
components/src/material/core/theming/_theming-deprecated.scss_0_1038 | @use '../m2/theming' as m2-theming;
@use '../m2/palette' as m2-palette;
// @deprecated Use `get-color-from-palette`.
@function color($palette, $hue: default, $opacity: null) {
@return m2-theming.get-color-from-palette($palette, $hue, $opacity);
}
// @deprecated Use `get-contrast-color-from-palette`.
@function contrast($palette, $hue) {
@return m2-theming.get-contrast-color-from-palette($palette, $hue);
}
// @deprecated Use `define-palette`.
@function palette($base-palette, $default: 500, $lighter: 100, $darker: 700, $text: $default) {
@return m2-theming.define-palette($base-palette, $default, $lighter, $darker, $text);
}
// @deprecated Use `define-light-theme`.
@function dark-theme($primary, $accent: null, $warn: palette(m2-palette.$red-palette)) {
@return m2-theming.define-dark-theme($primary, $accent, $warn);
}
// @deprecated Use `define-light-theme`.
@function light-theme($primary, $accent: null, $warn: palette(m2-palette.$red-palette)) {
@return m2-theming.define-light-theme($primary, $accent, $warn);
}
| {
"end_byte": 1038,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/_theming-deprecated.scss"
} |
components/src/material/core/theming/tests/test-theming-bundle.scss_0_7417 | // Imports the theming bundle. Needs to be an absolute bin-dir import path as on Windows,
// runfiles are not symlinked, so the Sass compilation happens in the workspace directory
// with the include paths being set to the `bazel-bin` directory.
@use 'src/material' as mat;
// Disable theme style duplication warnings. This test intentionally generates
// the same themes multiple times.
mat.$theme-ignore-duplication-warnings: true;
// If one of these mixins or function is not available, the compilation will fail and the
// test will be reported as failing.
// Theme creation functions.
$theme: mat.m2-define-light-theme((
color: (
primary: mat.m2-define-palette(mat.$m2-red-palette),
accent: mat.m2-define-palette(mat.$m2-blue-palette),
),
typography: mat.m2-define-typography-config(),
density: -2,
));
$dark-theme: mat.m2-define-dark-theme($theme);
$rem-typography: mat.m2-define-rem-typography-config();
// All-* mixins.
@include mat.all-component-themes($theme);
@include mat.all-component-colors($theme);
@include mat.all-component-typographies($theme);
@include mat.all-component-densities($theme);
// Core mixins.
@include mat.strong-focus-indicators();
@include mat.strong-focus-indicators-theme($theme);
// Component theme mixins.
@include mat.core-theme($theme);
@include mat.core-color($theme);
@include mat.core-typography($theme);
@include mat.core-density($theme);
@include mat.option-theme($theme);
@include mat.option-color($theme);
@include mat.option-typography($theme);
@include mat.option-density($theme);
@include mat.optgroup-theme($theme);
@include mat.optgroup-color($theme);
@include mat.optgroup-typography($theme);
@include mat.optgroup-density($theme);
@include mat.autocomplete-theme($theme);
@include mat.autocomplete-color($theme);
@include mat.autocomplete-typography($theme);
@include mat.autocomplete-density($theme);
@include mat.badge-theme($theme);
@include mat.badge-color($theme);
@include mat.badge-typography($theme);
@include mat.badge-density($theme);
@include mat.bottom-sheet-theme($theme);
@include mat.bottom-sheet-color($theme);
@include mat.bottom-sheet-typography($theme);
@include mat.bottom-sheet-density($theme);
@include mat.button-theme($theme);
@include mat.button-color($theme);
@include mat.button-typography($theme);
@include mat.button-density($theme);
@include mat.icon-button-theme($theme);
@include mat.icon-button-color($theme);
@include mat.icon-button-typography($theme);
@include mat.icon-button-density($theme);
@include mat.fab-theme($theme);
@include mat.fab-color($theme);
@include mat.fab-typography($theme);
@include mat.fab-density($theme);
@include mat.button-toggle-theme($theme);
@include mat.button-toggle-color($theme);
@include mat.button-toggle-typography($theme);
@include mat.button-toggle-density($theme);
@include mat.card-theme($theme);
@include mat.card-color($theme);
@include mat.card-typography($theme);
@include mat.card-density($theme);
@include mat.checkbox-theme($theme);
@include mat.checkbox-color($theme);
@include mat.checkbox-typography($theme);
@include mat.checkbox-density($theme);
@include mat.chips-theme($theme);
@include mat.chips-color($theme);
@include mat.chips-typography($theme);
@include mat.chips-density($theme);
@include mat.datepicker-theme($theme);
@include mat.datepicker-color($theme);
@include mat.datepicker-typography($theme);
@include mat.datepicker-density($theme);
@include mat.dialog-theme($theme);
@include mat.dialog-color($theme);
@include mat.dialog-typography($theme);
@include mat.dialog-density($theme);
@include mat.divider-theme($theme);
@include mat.divider-color($theme);
@include mat.divider-typography($theme);
@include mat.divider-density($theme);
@include mat.expansion-theme($theme);
@include mat.expansion-color($theme);
@include mat.expansion-typography($theme);
@include mat.expansion-density($theme);
@include mat.form-field-theme($theme);
@include mat.form-field-color($theme);
@include mat.form-field-typography($theme);
@include mat.form-field-density($theme);
@include mat.grid-list-theme($theme);
@include mat.grid-list-color($theme);
@include mat.grid-list-typography($theme);
@include mat.grid-list-density($theme);
@include mat.icon-theme($theme);
@include mat.icon-color($theme);
@include mat.icon-typography($theme);
@include mat.icon-density($theme);
@include mat.input-theme($theme);
@include mat.input-color($theme);
@include mat.input-typography($theme);
@include mat.input-density($theme);
@include mat.list-theme($theme);
@include mat.list-color($theme);
@include mat.list-typography($theme);
@include mat.list-density($theme);
@include mat.menu-theme($theme);
@include mat.menu-color($theme);
@include mat.menu-typography($theme);
@include mat.menu-density($theme);
@include mat.paginator-theme($theme);
@include mat.paginator-color($theme);
@include mat.paginator-typography($theme);
@include mat.paginator-density($theme);
@include mat.progress-bar-theme($theme);
@include mat.progress-bar-color($theme);
@include mat.progress-bar-typography($theme);
@include mat.progress-bar-density($theme);
@include mat.progress-spinner-theme($theme);
@include mat.progress-spinner-color($theme);
@include mat.progress-spinner-typography($theme);
@include mat.progress-spinner-density($theme);
@include mat.radio-theme($theme);
@include mat.radio-color($theme);
@include mat.radio-typography($theme);
@include mat.radio-density($theme);
@include mat.select-theme($theme);
@include mat.select-color($theme);
@include mat.select-typography($theme);
@include mat.select-density($theme);
@include mat.sidenav-theme($theme);
@include mat.sidenav-color($theme);
@include mat.sidenav-typography($theme);
@include mat.sidenav-density($theme);
@include mat.slide-toggle-theme($theme);
@include mat.slide-toggle-color($theme);
@include mat.slide-toggle-typography($theme);
@include mat.slide-toggle-density($theme);
@include mat.slider-theme($theme);
@include mat.slider-color($theme);
@include mat.slider-typography($theme);
@include mat.slider-density($theme);
@include mat.snack-bar-theme($theme);
@include mat.snack-bar-color($theme);
@include mat.snack-bar-typography($theme);
@include mat.snack-bar-density($theme);
@include mat.sort-theme($theme);
@include mat.sort-color($theme);
@include mat.sort-typography($theme);
@include mat.sort-density($theme);
@include mat.stepper-theme($theme);
@include mat.stepper-color($theme);
@include mat.stepper-typography($theme);
@include mat.stepper-density($theme);
@include mat.table-theme($theme);
@include mat.table-color($theme);
@include mat.table-typography($theme);
@include mat.table-density($theme);
@include mat.tabs-theme($theme);
@include mat.tabs-color($theme);
@include mat.tabs-typography($theme);
@include mat.tabs-density($theme);
@include mat.toolbar-theme($theme);
@include mat.toolbar-color($theme);
@include mat.toolbar-typography($theme);
@include mat.toolbar-density($theme);
@include mat.tooltip-theme($theme);
@include mat.tooltip-color($theme);
@include mat.tooltip-typography($theme);
@include mat.tooltip-density($theme);
@include mat.tree-theme($theme);
@include mat.tree-color($theme);
@include mat.tree-typography($theme);
@include mat.tree-density($theme);
@include mat.timepicker-theme($theme);
@include mat.timepicker-color($theme);
@include mat.timepicker-typography($theme);
@include mat.timepicker-density($theme);
| {
"end_byte": 7417,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/test-theming-bundle.scss"
} |
components/src/material/core/theming/tests/theming-definition-api.spec.ts_0_1461 | import {parse} from 'postcss';
import {compileString} from 'sass';
import {runfiles} from '@bazel/runfiles';
import * as path from 'path';
import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer';
// Note: For Windows compatibility, we need to resolve the directory paths through runfiles
// which are guaranteed to reside in the source tree.
const testDir = path.join(runfiles.resolvePackageRelative('../_all-theme.scss'), '../tests');
const packagesDir = path.join(runfiles.resolveWorkspaceRelative('src/cdk/_index.scss'), '../..');
const localPackageSassImporter = createLocalAngularPackageImporter(packagesDir);
/** Transpiles given Sass content into CSS. */
function transpile(content: string) {
return compileString(
`
@use 'sass:list';
@use 'sass:map';
@use '../../../index' as mat;
$internals: _mat-theming-internals-do-not-access;
${content}
`,
{
loadPaths: [testDir],
importers: [localPackageSassImporter],
},
).css.toString();
}
function getRootVars(css: string) {
const result: {[key: string]: string} = {};
parse(css).each(node => {
if (node.type === 'rule' && node.selector === ':root') {
node.walk(child => {
if (child.type === 'decl') {
if (child.prop.startsWith('--')) {
result[child.prop.substring(2)] = child.value;
}
}
});
}
});
return result;
} | {
"end_byte": 1461,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/theming-definition-api.spec.ts"
} |
components/src/material/core/theming/tests/theming-definition-api.spec.ts_1463_9165 | describe('theming definition api', () => {
describe('define-theme', () => {
it('should fill in defaults', () => {
const css = transpile(`
$theme: mat.define-theme();
$data: map.get($theme, $internals);
:root {
--keys: #{map.keys($data)};
--version: #{map.get($data, theme-version)};
--type: #{map.get($data, theme-type)};
--palettes: #{map.keys(map.get($data, palettes))};
--density: #{map.get($data, density-scale)};
--base-tokens: #{list.length(map.get($data, base-tokens)) > 0};
--color-tokens: #{list.length(map.get($data, color-tokens)) > 0};
--typography-tokens: #{list.length(map.get($data, typography-tokens)) > 0};
--density-tokens: #{list.length(map.get($data, density-tokens)) > 0};
--color-system-variables-prefix: #{map.get($data, color-system-variables-prefix)};
--typography-system-variables-prefix: #{map.get($data, typography-system-variables-prefix)};
}
`);
const vars = getRootVars(css);
expect(vars['keys'].split(', ')).toEqual([
'theme-version',
'theme-type',
'palettes',
'color-system-variables-prefix',
'color-tokens',
'font-definition',
'typography-system-variables-prefix',
'typography-tokens',
'density-scale',
'density-tokens',
'base-tokens',
]);
expect(vars['version']).toBe('1');
expect(vars['type']).toBe('light');
expect(vars['palettes'].split(', ')).toEqual([
'primary',
'secondary',
'tertiary',
'neutral',
'neutral-variant',
'error',
]);
expect(vars['density']).toBe('0');
expect(vars['base-tokens']).toBe('true');
expect(vars['color-tokens']).toBe('true');
expect(vars['typography-tokens']).toBe('true');
expect(vars['density-tokens']).toBe('true');
expect(vars['typography-system-variables-prefix']).toBe('mat-sys');
expect(vars['color-system-variables-prefix']).toBe('mat-sys');
});
it('should customize colors', () => {
const css = transpile(`
$theme: mat.define-theme((
color: (
theme-type: dark,
primary: mat.$yellow-palette,
tertiary: mat.$red-palette,
)
));
$data: map.get($theme, $internals);
:root {
--token-surface: #{map.get($data, color-tokens, (mdc, theme), surface)};
--token-primary: #{map.get($data, color-tokens, (mdc, theme), primary)};
--token-secondary: #{map.get($data, color-tokens, (mdc, theme), secondary)};
--token-tertiary: #{map.get($data, color-tokens, (mdc, theme), tertiary)};
--palette-primary: #{map.get($data, palettes, primary, 50)};
--palette-secondary: #{map.get($data, palettes, secondary, 50)};
--palette-tertiary: #{map.get($data, palettes, tertiary, 50)};
--type: #{map.get($data, theme-type)};
}
`);
const vars = getRootVars(css);
expect(vars['token-surface']).toBe('#14140f');
expect(vars['token-primary']).toBe('#cdcd00');
expect(vars['token-secondary']).toBe('#cac8a5');
expect(vars['token-tertiary']).toBe('#ffb4a8');
expect(vars['palette-primary']).toBe('#7b7b00');
expect(vars['palette-secondary']).toBe('#7a795a');
expect(vars['palette-tertiary']).toBe('#ef0000');
expect(vars['type']).toBe('dark');
});
it('should customize typography', () => {
const css = transpile(`
$theme: mat.define-theme((
typography: (
brand-family: Comic Sans,
plain-family: Wingdings,
bold-weight: 300,
medium-weight: 200,
regular-weight: 100,
)
));
$data: map.get($theme, $internals);
:root {
--display-font:
#{map.get($data, typography-tokens, (mdc, typography), display-large-font)};
--display-weight:
#{map.get($data, typography-tokens, (mdc, typography), display-large-weight)};
--title-font:
#{map.get($data, typography-tokens, (mdc, typography), title-small-font)};
--title-weight:
#{map.get($data, typography-tokens, (mdc, typography), title-small-weight)};
}
`);
const vars = getRootVars(css);
expect(vars['display-font']).toBe('Comic Sans');
expect(vars['display-weight']).toBe('100');
expect(vars['title-font']).toBe('Wingdings');
expect(vars['title-weight']).toBe('200');
});
it('should customize density', () => {
const css = transpile(`
$theme: mat.define-theme((
density: (
scale: -2
)
));
$data: map.get($theme, $internals);
:root {
--size: #{map.get($data, density-tokens, (mdc, checkbox), state-layer-size)};
}
`);
const vars = getRootVars(css);
expect(vars['size']).toBe('32px');
});
it('should throw for invalid system config', () => {
expect(() => transpile(`$theme: mat.define-theme(5)`)).toThrowError(
/\$config should be a configuration object\. Got: 5/,
);
});
it('should throw for invalid color config', () => {
expect(() => transpile(`$theme: mat.define-theme((color: 5))`)).toThrowError(
/\$config\.color should be a color configuration object\. Got: 5/,
);
});
it('should throw for invalid typography config', () => {
expect(() => transpile(`$theme: mat.define-theme((typography: 5))`)).toThrowError(
/\$config\.typography should be a typography configuration object\. Got: 5/,
);
});
it('should throw for invalid density config', () => {
expect(() => transpile(`$theme: mat.define-theme((density: 5))`)).toThrowError(
/\$config\.density should be a density configuration object\. Got: 5/,
);
});
it('should throw for invalid config property', () => {
expect(() => transpile(`$theme: mat.define-theme((fake: 5))`)).toThrowError(
/\$config has unexpected properties.*Found: fake/,
);
});
it('should throw for invalid color property', () => {
expect(() => transpile(`$theme: mat.define-theme((color: (fake: 5)))`)).toThrowError(
/\$config\.color has unexpected properties.*Found: fake/,
);
});
it('should throw for invalid typography property', () => {
expect(() => transpile(`$theme: mat.define-theme((typography: (fake: 5)))`)).toThrowError(
/\$config\.typography has unexpected properties.*Found: fake/,
);
});
it('should throw for invalid density property', () => {
expect(() => transpile(`$theme: mat.define-theme((density: (fake: 5)))`)).toThrowError(
/\$config\.density has unexpected properties.*Found: fake/,
);
});
it('should throw for invalid theme type', () => {
expect(() =>
transpile(`$theme: mat.define-theme((color: (theme-type: black)))`),
).toThrowError(/Expected \$config\.color.theme-type to be one of:.*Got: black/);
});
it('should throw for invalid palette', () => {
expect(() =>
transpile(`$theme: mat.define-theme((color: (tertiary: mat.$m2-red-palette)))`),
).toThrowError(/Expected \$config\.color\.tertiary to be a valid M3 palette\. Got:/);
});
it('should throw for invalid density scale', () => {
expect(() => transpile(`$theme: mat.define-theme((density: (scale: 10)))`)).toThrowError(
/Expected \$config\.density\.scale to be one of:.*Got: 10/,
);
});
}); | {
"end_byte": 9165,
"start_byte": 1463,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/theming-definition-api.spec.ts"
} |
components/src/material/core/theming/tests/theming-definition-api.spec.ts_9169_10652 | describe('define-colors', () => {
it('should omit non-color info', () => {
const css = transpile(`
$theme: mat.define-colors();
$data: map.get($theme, $internals);
:root {
--keys: #{map.keys($data)};
}
`);
const vars = getRootVars(css);
expect(vars['keys'].split(', ')).toEqual([
'theme-version',
'theme-type',
'palettes',
'color-system-variables-prefix',
'color-tokens',
]);
});
});
describe('define-typography', () => {
it('should omit non-typography info', () => {
const css = transpile(`
$theme: mat.define-typography();
$data: map.get($theme, $internals);
:root {
--keys: #{map.keys($data)};
}
`);
const vars = getRootVars(css);
expect(vars['keys'].split(', ')).toEqual([
'theme-version',
'font-definition',
'typography-system-variables-prefix',
'typography-tokens',
]);
});
});
describe('define-density', () => {
it('should omit non-density info', () => {
const css = transpile(`
$theme: mat.define-density();
$data: map.get($theme, $internals);
:root {
--keys: #{map.keys($data)};
}
`);
const vars = getRootVars(css);
expect(vars['keys'].split(', ')).toEqual([
'theme-version',
'density-scale',
'density-tokens',
]);
});
});
}); | {
"end_byte": 10652,
"start_byte": 9169,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/theming-definition-api.spec.ts"
} |
components/src/material/core/theming/tests/test-css-variables-theme.scss_0_1193 | @use 'sass:map';
@use 'sass:meta';
@use '../all-theme';
@use '../../m2/typography' as m2-typography;
@use '../../m2/palette' as m2-palette;
@use '../../m2/theming' as m2-theming;
// Recursively replaces all of the values inside a Sass map with a different value.
@function _replace-all-values($palette, $replacement) {
$output: ();
@each $key, $value in $palette {
@if $key != _mat-theming-internals-do-not-access {
@if (meta.type-of($value) == 'map') {
$output: map.merge(($key: _replace-all-values($value, $replacement)), $output);
}
@else {
$output: map.merge(($key: $replacement), $output);
}
}
}
@return $output;
}
// Theme used to test that our themes would compile if the colors were specified as CSS variables.
._demo-css-variables-theme {
$palette: m2-theming.define-palette(m2-palette.$blue-grey-palette);
$theme: m2-theming.define-dark-theme((
color: (
primary: $palette,
accent: $palette,
warn: $palette
),
typography: m2-typography.define-typography-config(),
));
$css-var-theme: _replace-all-values($theme, var(--test-var));
@include all-theme.all-component-themes($css-var-theme);
}
| {
"end_byte": 1193,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/test-css-variables-theme.scss"
} |
components/src/material/core/theming/tests/test-theming-api.scss_0_8339 | @use 'sass:map';
@use '../../density/private/all-density';
@use '../../color/all-color';
@use '../../typography/all-typography';
@use '../all-theme';
@use '../../typography/typography';
@use '../theming';
@use '../../m2/typography' as m2-typography;
@use '../../m2/palette' as m2-palette;
@use '../../m2/theming' as m2-theming;
// Disable theme style duplication warnings. This test intentionally generates
// the same themes multiple times.
theming.$theme-ignore-duplication-warnings: true;
// A new way to configure themes has been introduced. This Sass file ensures that the theming
// API is backwards compatible, so that the old pattern for configuring themes can be still
// used. The Sass compilation of this file will fail if one of the tests/assertions fails.
$primary: m2-theming.define-palette(m2-palette.$blue-palette);
$accent: m2-theming.define-palette(m2-palette.$grey-palette);
$warn: m2-theming.define-palette(m2-palette.$indigo-palette);
$default-warn: m2-theming.define-palette(m2-palette.$red-palette);
// Asserts that a given value matches the expected value. If not, an error is
// thrown with the given error message.
@mixin assert($value, $expected, $error-msg) {
@if $value != $expected {
@error 'Expected "#{$value}" to be "#{$expected}". #{$error-msg}';
}
}
// Asserts that the specified color configuration is configured properly.
@mixin assert-color-config($config, $primary, $accent, $warn, $is-dark) {
$color: map.get($config, color);
@include assert(map.get($color, primary), $primary,
'Primary palette does not match expected palette.');
@include assert(map.get($color, accent), $accent,
'Accent palette does not match expected palette.');
@include assert(map.get($color, warn), $warn,
'Warn palette does not match expected palette.');
@include assert(map.get($color, is-dark), $is-dark,
'Expected color config `is-dark` to be: #{$is-dark}');
}
$legacy-light-theme: m2-theming.define-light-theme($primary, $accent, $warn);
$legacy-dark-theme: m2-theming.define-dark-theme($primary, $accent, $warn);
$legacy-light-theme-default-warn: m2-theming.define-light-theme($primary, $accent);
$legacy-dark-theme-default-warn: m2-theming.define-dark-theme($primary, $accent);
$new-api-light-theme: m2-theming.define-light-theme((
color: (primary: $primary, accent: $accent, warn: $warn)
));
$new-api-dark-theme: m2-theming.define-dark-theme((
color: (primary: $primary, accent: $accent, warn: $warn)
));
$new-api-light-theme-default-warn: m2-theming.define-light-theme((
color: (primary: $primary, accent: $accent)
));
$new-api-dark-theme-default-warn: m2-theming.define-dark-theme((
color: (primary: $primary, accent: $accent)
));
$light-theme-only-density: m2-theming.define-light-theme((density: -2));
$dark-theme-only-density: m2-theming.define-dark-theme((density: -2));
$typography-config: m2-typography.define-typography-config();
$light-theme-only-typography: m2-theming.define-light-theme((typography: $typography-config));
$dark-theme-only-typography: m2-theming.define-dark-theme((typography: $typography-config));
// Test which ensures that constructed themes by default do not set configurations
// for the individual parts of the theming system (color, density, typography).
@mixin test-default-theming-system-configs() {
$themes: ($legacy-light-theme, $legacy-dark-theme, $new-api-light-theme, $new-api-dark-theme);
@each $theme in $themes {
@include assert(map.has-key($theme, color), true,
'Expected color to be explicitly configured.');
@include assert(map.has-key($theme, typography), false,
'Expected typography to be not explicitly configured.');
@include assert(map.has-key($theme, density), false,
'Expected density to be not explicitly configured.');
}
@include assert(map.has-key($light-theme-only-density, color), false,
'Expected color to be not explicitly configured.');
@include assert(map.has-key($dark-theme-only-density, color), false,
'Expected color to be not explicitly configured.');
}
// Test which ensures that constructed themes have the proper color configurations
// as specified in the `mat-light-theme` and `mat-dark-theme` functions.
@mixin test-create-color-config() {
@include assert-color-config($legacy-light-theme, $primary, $accent, $warn, false);
@include assert-color-config($legacy-dark-theme, $primary, $accent, $warn, true);
@include assert-color-config($legacy-light-theme-default-warn, $primary, $accent,
$default-warn, false);
@include assert-color-config($legacy-dark-theme-default-warn, $primary, $accent,
$default-warn, true);
@include assert-color-config($new-api-light-theme, $primary, $accent, $warn, false);
@include assert-color-config($new-api-dark-theme, $primary, $accent, $warn, true);
@include assert-color-config($new-api-light-theme-default-warn, $primary, $accent,
$default-warn, false);
@include assert-color-config($new-api-dark-theme-default-warn, $primary, $accent,
$default-warn, true);
}
// Test which ensures that constructed themes pass through the specified
// density and typography configurations.
@mixin test-density-typography-config-pass-through() {
@include assert(map.get($light-theme-only-density, density), -2,
'Expected density config to be included in theme.');
@include assert(map.get($dark-theme-only-density, density), -2,
'Expected density config to be included in theme.');
@include assert(map.get($light-theme-only-typography, typography), $typography-config,
'Expected typography config to be included in theme.');
@include assert(map.get($dark-theme-only-typography, typography), $typography-config,
'Expected typography config to be included in theme.');
}
// Test which ensures that color configurations can be properly read from
// theme objects passed to individual component theme mixins.
@mixin test-get-color-config() {
$color-config: map.get($legacy-light-theme, color);
$no-color-light-theme: m2-theming.define-light-theme((color: null));
$no-color-dark-theme: m2-theming.define-dark-theme((color: null));
@include assert(m2-theming.get-color-config($color-config), $color-config,
'Expected that passing a color config to a theme will work for backwards compatibility.');
// For legacy constructed themes, the color configuration is the actual `$theme` object.
// This is done for backwards compatibility because developers could modify colors directly
// by updating immediate properties on the `$theme` object.
@include assert(m2-theming.get-color-config($legacy-light-theme), $legacy-light-theme,
'Expected that the theme object is used for the color configuration.');
@include assert(m2-theming.get-color-config($new-api-dark-theme),
map.get($new-api-dark-theme, color),
'Expected that a color config can be read from a theme object.');
@include assert(m2-theming.get-color-config($light-theme-only-density), null,
'Expected that by default, no color configuration is used.');
@include assert(m2-theming.get-color-config($no-color-light-theme), null,
'Expected that no color configuration can be explicitly specified.');
@include assert(m2-theming.get-color-config($no-color-dark-theme), null,
'Expected that no color configuration can be explicitly specified.');
}
// Test which ensures that density configurations can be properly read from
// theme objects passed to individual component theme mixins.
@mixin test-get-density-config() {
$density-config: map.get($light-theme-only-density, density);
$no-density-light-theme: m2-theming.define-light-theme((density: null));
$no-density-dark-theme: m2-theming.define-dark-theme((density: null));
@include assert(m2-theming.get-density-config($light-theme-only-density), -2,
'Expected that a density config can be read from a theme object.');
@include assert(m2-theming.get-density-config($light-theme-only-typography), 0,
'Expected that by default, the density system will be configured.');
@include assert(m2-theming.get-density-config($no-density-light-theme), null,
'Expected that no density configuration can be explicitly specified.');
@include assert(m2-theming.get-density-config($no-density-dark-theme), null,
'Expected that no density configuration can be explicitly specified.');
} | {
"end_byte": 8339,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/test-theming-api.scss"
} |
components/src/material/core/theming/tests/test-theming-api.scss_8341_14049 | // Test which ensures that typography configurations can be properly read from
// theme objects passed to individual component theme mixins.
@mixin test-get-typography-config() {
$no-typography-light-theme: m2-theming.define-light-theme((density: null));
$no-typography-dark-theme: m2-theming.define-dark-theme((density: null));
@include assert(m2-theming.get-typography-config($light-theme-only-typography),
$typography-config, 'Expected that a typography config can be read from a theme object.');
@include assert(m2-theming.get-typography-config($legacy-light-theme), null,
'Expected that by default, no typography configuration is used.');
@include assert(m2-theming.get-typography-config($no-typography-light-theme), null,
'Expected that no typography configuration can be explicitly specified.');
@include assert(m2-theming.get-typography-config($no-typography-dark-theme), null,
'Expected that no typography configuration can be explicitly specified.');
}
// Test which ensures that all Angular Material theme mixins accept a theme
// object without throwing any exception.
@mixin test-theme-mixins-successful-compilation() {
@include all-theme.all-component-themes($legacy-light-theme);
@include all-theme.all-component-themes($legacy-light-theme-default-warn);
@include all-theme.all-component-themes($legacy-dark-theme);
@include all-theme.all-component-themes($legacy-dark-theme-default-warn);
@include all-theme.all-component-themes($new-api-light-theme);
@include all-theme.all-component-themes($new-api-light-theme-default-warn);
@include all-theme.all-component-themes($new-api-dark-theme);
@include all-theme.all-component-themes($new-api-dark-theme-default-warn);
@include all-theme.all-component-themes($light-theme-only-density);
@include all-theme.all-component-themes($dark-theme-only-density);
@include all-theme.all-component-themes($light-theme-only-typography);
@include all-theme.all-component-themes($dark-theme-only-typography);
}
// Custom theme mixin used by the custom theme backwards compatibility test.
// This replicates a custom theme that expects legacy theme objects.
@mixin _my-custom-theme-legacy($theme) {
.demo-custom-comp {
border-color: m2-theming.get-color-from-palette(map.get($theme, primary));
}
}
@mixin _my-custom-theme-new-api-color($config-or-theme) {
$config: m2-theming.get-color-config($config-or-theme);
.demo-custom-comp {
border-color: m2-theming.get-color-from-palette(map.get($config, primary));
}
}
@mixin _my-custom-theme-new-api-density($config-or-theme) {
$density-scale: m2-theming.get-density-config($config-or-theme);
.demo-custom-comp {
// Simulates logic for computing density according to the Material Design
// specification.
height: 48 - (4px * $density-scale);
}
}
// Custom theme mixin used by the custom theme backwards compatibility test.
@mixin _my-custom-theme-new-api($theme-or-color-config) {
$theme: theming.private-legacy-get-theme($theme-or-color-config);
$color: m2-theming.get-color-config($theme);
$density: m2-theming.get-density-config($theme);
@if $color != null {
@include _my-custom-theme-new-api-color($color);
}
@if $density != null {
@include _my-custom-theme-new-api-density($density);
}
}
@mixin test-custom-theme-backwards-compatibility() {
@include _my-custom-theme-legacy($legacy-light-theme);
@include _my-custom-theme-legacy($legacy-dark-theme);
@include _my-custom-theme-legacy($new-api-light-theme);
@include _my-custom-theme-legacy($new-api-dark-theme);
@include _my-custom-theme-new-api($legacy-light-theme);
@include _my-custom-theme-new-api($legacy-dark-theme);
@include _my-custom-theme-new-api($new-api-light-theme);
@include _my-custom-theme-new-api($new-api-dark-theme);
}
// Test which ensures that either theme objects, or individual system configurations
// can be passed to the all-density, all-typography or all-color mixins.
@mixin test-all-theme-mixins-arguments() {
$test-themes: (
$legacy-light-theme,
$legacy-dark-theme,
$new-api-light-theme,
$new-api-dark-theme
);
@each $theme in $test-themes {
@include all-typography.all-component-typographies($theme);
@include all-color.all-component-colors($theme);
@include all-density.all-component-densities($theme);
}
@include all-typography.all-component-typographies(
map.get($light-theme-only-typography, typography));
@include all-typography.all-component-typographies($light-theme-only-typography);
@include all-density.all-component-densities(map.get($light-theme-only-density, density));
@include all-density.all-component-densities($light-theme-only-density);
}
@mixin test-individual-system-mixins-unwrap() {
@include _my-custom-theme-new-api-color($new-api-dark-theme);
@include _my-custom-theme-new-api-color(map.get($new-api-dark-theme, color));
@include _my-custom-theme-new-api($new-api-dark-theme);
@include _my-custom-theme-new-api(map.get($new-api-dark-theme, color));
@include all-theme.all-component-themes($new-api-dark-theme);
@include all-theme.all-component-themes(map.get($new-api-dark-theme, color));
}
// Include all tests. Sass will throw if one of the tests fails.
@include test-create-color-config();
@include test-default-theming-system-configs();
@include test-density-typography-config-pass-through();
@include test-theme-mixins-successful-compilation();
@include test-get-color-config();
@include test-get-density-config();
@include test-get-typography-config();
@include test-custom-theme-backwards-compatibility();
@include test-all-theme-mixins-arguments();
@include test-individual-system-mixins-unwrap(); | {
"end_byte": 14049,
"start_byte": 8341,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/test-theming-api.scss"
} |
components/src/material/core/theming/tests/test-typography-font-family.scss_0_6243 | @use 'sass:string';
@use 'sass:map';
@use 'sass:meta';
@use '../../m2/typography' as m2-typography;
$_font-family: string.unquote('Roboto, sans-serif');
@function assert-font-family($test-name, $obj, $expected) {
@each $level-name, $level in $obj {
@if (meta.type-of($level) == 'map' and map.get($level, 'font-family') != $expected) {
@error '[#{$test-name}]: Incorrect font-family in level "#{$level-name}". ' +
'Expected "#{$expected}", but received "#{map.get($level, 'font-family')}".';
}
}
@return $obj;
}
$no-font-family: assert-font-family(
'should take default MDC font family if none is specified',
m2-typography.define-typography-config(),
$_font-family);
$only-top-level-font-family: assert-font-family(
'should take custom font family if specified at top level',
m2-typography.define-typography-config($font-family: 'custom-top'),
'custom-top');
$individual-levels-without-font-families: assert-font-family(
'should set the default MDC font family if all keys are specified, but without a font-family',
m2-typography.define-typography-config(
$headline-1: m2-typography.define-typography-level($font-size: 1px),
$headline-2: m2-typography.define-typography-level($font-size: 1px),
$headline-3: m2-typography.define-typography-level($font-size: 1px),
$headline-4: m2-typography.define-typography-level($font-size: 1px),
$headline-5: m2-typography.define-typography-level($font-size: 1px),
$headline-6: m2-typography.define-typography-level($font-size: 1px),
$subtitle-1: m2-typography.define-typography-level($font-size: 1px),
$subtitle-2: m2-typography.define-typography-level($font-size: 1px),
$body-1: m2-typography.define-typography-level($font-size: 1px),
$body-2: m2-typography.define-typography-level($font-size: 1px),
$caption: m2-typography.define-typography-level($font-size: 1px),
$button: m2-typography.define-typography-level($font-size: 1px),
$overline: m2-typography.define-typography-level($font-size: 1px),
),
$_font-family
);
$individual-levels-without-font-families-with-top-level-family: assert-font-family(
'should set a custom top-level font family if all keys are specified, but without a font-family',
m2-typography.define-typography-config(
$font-family: 'custom-top',
$headline-1: m2-typography.define-typography-level($font-size: 1px),
$headline-2: m2-typography.define-typography-level($font-size: 1px),
$headline-3: m2-typography.define-typography-level($font-size: 1px),
$headline-4: m2-typography.define-typography-level($font-size: 1px),
$headline-5: m2-typography.define-typography-level($font-size: 1px),
$headline-6: m2-typography.define-typography-level($font-size: 1px),
$subtitle-1: m2-typography.define-typography-level($font-size: 1px),
$subtitle-2: m2-typography.define-typography-level($font-size: 1px),
$body-1: m2-typography.define-typography-level($font-size: 1px),
$body-2: m2-typography.define-typography-level($font-size: 1px),
$caption: m2-typography.define-typography-level($font-size: 1px),
$button: m2-typography.define-typography-level($font-size: 1px),
$overline: m2-typography.define-typography-level($font-size: 1px),
),
'custom-top'
);
$individual-levels-with-font-families: assert-font-family(
'should use the level font family if one is specified, but there is none at the top level',
m2-typography.define-typography-config(
$headline-1: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$headline-2: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$headline-3: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$headline-4: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$headline-5: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$headline-6: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$subtitle-1: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$subtitle-2: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$body-1: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$body-2: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$caption: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$button: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$overline: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
),
'custom'
);
$individual-levels-with-font-families-and-top-level-family: assert-font-family(
'should use the level font family if a top-level one is specified together with it',
m2-typography.define-typography-config(
$font-family: 'custom-top',
$headline-1: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$headline-2: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$headline-3: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$headline-4: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$headline-5: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$headline-6: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$subtitle-1: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$subtitle-2: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$body-1: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$body-2: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$caption: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$button: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
$overline: m2-typography.define-typography-level($font-size: 1px, $font-family: 'custom'),
),
'custom'
);
| {
"end_byte": 6243,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/test-typography-font-family.scss"
} |
components/src/material/core/theming/tests/m3-theme.spec.ts_0_8633 | import {runfiles} from '@bazel/runfiles';
import * as path from 'path';
import {parse} from 'postcss';
import {compileString} from 'sass';
import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer';
// Note: For Windows compatibility, we need to resolve the directory paths through runfiles
// which are guaranteed to reside in the source tree.
const testDir = path.join(runfiles.resolvePackageRelative('../_all-theme.scss'), '../tests');
const packagesDir = path.join(runfiles.resolveWorkspaceRelative('src/cdk/_index.scss'), '../..');
const localPackageSassImporter = createLocalAngularPackageImporter(packagesDir);
/** Transpiles given Sass content into CSS. */
function transpile(content: string) {
return compileString(
`
@use '../../../index' as mat;
$internals: _mat-theming-internals-do-not-access;
$theme: mat.define-theme();
${content}
`,
{
loadPaths: [testDir],
importers: [localPackageSassImporter],
},
).css.toString();
}
function union<T>(...sets: Set<T>[]): Set<T> {
return new Set(sets.flatMap(s => [...s]));
}
function intersection<T>(set: Set<T>, ...sets: Set<T>[]): Set<T> {
return new Set([...set].filter(i => sets.every(s => s.has(i))));
}
/** Expects the given warning to be reported in Sass. */
function expectWarning(message: RegExp) {
expect(getMatchingWarning(message)).withContext('Expected warning to be printed.').toBeDefined();
}
/** Expects the given warning not to be reported in Sass. */
function expectNoWarning(message: RegExp) {
expect(getMatchingWarning(message))
.withContext('Expected no warning to be printed.')
.toBeUndefined();
}
/**
* Gets first instance of the given warning reported in Sass. Dart sass directly writes
* to the `process.stderr` stream, so we spy on the `stderr.write` method. We
* cannot expect a specific amount of writes as Sass calls `stderr.write` multiple
* times for a warning (e.g. spacing and stack trace)
*/
function getMatchingWarning(message: RegExp) {
const writeSpy = process.stderr.write as jasmine.Spy;
return (writeSpy.calls?.all() ?? []).find(
(s: jasmine.CallInfo<typeof process.stderr.write>) =>
typeof s.args[0] === 'string' && message.test(s.args[0]),
);
}
describe('M3 theme', () => {
it('should emit all styles under the given selector', () => {
const root = parse(
transpile(`
html {
@include mat.all-component-themes($theme);
@include mat.all-component-bases($theme);
@include mat.all-component-colors($theme);
@include mat.all-component-typographies($theme);
@include mat.all-component-densities($theme);
}
`),
);
const selectors = new Set<string>();
root.walkRules(rule => {
selectors.add(rule.selector);
});
expect(Array.from(selectors)).toEqual(['html']);
});
it('should only emit CSS variables', () => {
const root = parse(transpile(`html { @include mat.all-component-themes($theme); }`));
const nonVarProps: string[] = [];
root.walkDecls(decl => {
if (!decl.prop.startsWith('--')) {
nonVarProps.push(decl.prop);
}
});
expect(nonVarProps).toEqual([]);
});
it('should not have overlapping tokens between theme dimensions', () => {
const css = transpile(`
$theme: mat.define-theme();
base {
@include mat.all-component-bases($theme);
}
color {
@include mat.all-component-colors($theme);
}
typography {
@include mat.all-component-typographies($theme);
}
density {
@include mat.all-component-densities($theme);
}
`);
const root = parse(css);
const propSets: {[key: string]: Set<string>} = {};
root.walkRules(rule => {
rule.walkDecls(decl => {
propSets[rule.selector] = propSets[rule.selector] || new Set();
propSets[rule.selector].add(decl.prop);
});
});
let overlap = new Set();
for (const [dimension1, props1] of Object.entries(propSets)) {
for (const [dimension2, props2] of Object.entries(propSets)) {
if (dimension1 !== dimension2) {
overlap = union(overlap, intersection(props1, props2));
}
}
}
expect([...overlap])
.withContext('Did you forget to wrap these in `_hardcode()`?')
.toEqual([]);
});
it('should throw if theme included at root', () => {
expect(() => transpile(`@include mat.all-component-themes($theme)`)).toThrowError(
/Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector/,
);
});
describe('theme override API', () => {
beforeEach(() => {
spyOn(process.stderr, 'write').and.callThrough();
});
it('should allow overriding non-ambiguous token value', () => {
const css = transpile(`
div {
@include mat.checkbox-overrides((selected-checkmark-color: magenta));
}
`);
expect(css).toContain('--mdc-checkbox-selected-checkmark-color: magenta');
expectNoWarning(/`selected-checkmark-color` is deprecated/);
});
it('should allow overriding ambiguous token value using prefix', () => {
const css = transpile(`
div {
@include mat.form-field-overrides((filled-caret-color: magenta));
}
`);
expect(css).toContain('--mdc-filled-text-field-caret-color: magenta');
expect(css).not.toContain('--mdc-outline-text-field-caret-color: magenta');
expectNoWarning(/`filled-caret-color` is deprecated/);
});
it('should allow overriding ambiguous token value without using prefix, but warn', () => {
const css = transpile(`
div {
@include mat.form-field-overrides((caret-color: magenta));
}
`);
expect(css).toContain('--mdc-filled-text-field-caret-color: magenta');
expect(css).toContain('--mdc-outlined-text-field-caret-color: magenta');
expectWarning(
/Token `caret-color` is deprecated. Please use one of the following alternatives: filled-caret-color, outlined-caret-color/,
);
});
it('should error on invalid token name', () => {
expect(() =>
transpile(`
div {
@include mat.form-field-overrides((fake: magenta));
}
`),
).toThrowError(/Invalid token name `fake`./);
});
it('should not error when calling theme override functions', () => {
// Ensures that no components have issues with ambiguous token names.
expect(() =>
transpile(`
html {
@include mat.core-overrides(());
@include mat.ripple-overrides(());
@include mat.option-overrides(());
@include mat.optgroup-overrides(());
@include mat.pseudo-checkbox-overrides(());
@include mat.autocomplete-overrides(());
@include mat.badge-overrides(());
@include mat.bottom-sheet-overrides(());
@include mat.button-overrides(());
@include mat.fab-overrides(());
@include mat.icon-button-overrides(());
@include mat.button-toggle-overrides(());
@include mat.card-overrides(());
@include mat.checkbox-overrides(());
@include mat.chips-overrides(());
@include mat.datepicker-overrides(());
@include mat.dialog-overrides(());
@include mat.divider-overrides(());
@include mat.expansion-overrides(());
@include mat.form-field-overrides(());
@include mat.grid-list-overrides(());
@include mat.icon-overrides(());
@include mat.list-overrides(());
@include mat.menu-overrides(());
@include mat.paginator-overrides(());
@include mat.progress-bar-overrides(());
@include mat.progress-spinner-overrides(());
@include mat.radio-overrides(());
@include mat.select-overrides(());
@include mat.sidenav-overrides(());
@include mat.slide-toggle-overrides(());
@include mat.slider-overrides(());
@include mat.snack-bar-overrides(());
@include mat.sort-overrides(());
@include mat.stepper-overrides(());
@include mat.table-overrides(());
@include mat.tabs-overrides(());
@include mat.toolbar-overrides(());
@include mat.tooltip-overrides(());
@include mat.tree-overrides(());
}
`),
).not.toThrow();
});
});
});
| {
"end_byte": 8633,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/m3-theme.spec.ts"
} |
components/src/material/core/theming/tests/theming-inspection-api.spec.ts_0_7746 | import {compileString} from 'sass';
import {runfiles} from '@bazel/runfiles';
import * as path from 'path';
import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer';
// Note: For Windows compatibility, we need to resolve the directory paths through runfiles
// which are guaranteed to reside in the source tree.
const testDir = path.join(runfiles.resolvePackageRelative('../_all-theme.scss'), '../tests');
const packagesDir = path.join(runfiles.resolveWorkspaceRelative('src/cdk/_index.scss'), '../..');
const localPackageSassImporter = createLocalAngularPackageImporter(packagesDir);
/** Transpiles given Sass content into CSS. */
function transpile(content: string) {
return compileString(
`
@use 'sass:map';
@use '../../../index' as mat;
${content}
`,
{
loadPaths: [testDir],
importers: [localPackageSassImporter],
},
).css.toString();
}
describe('theming inspection api', () => {
describe('for m2 theme', () => {
it('should get theme version', () => {
expect(
transpile(`
$theme: mat.m2-define-light-theme((
color: (
primary: mat.m2-define-palette(mat.$m2-red-palette),
accent: mat.m2-define-palette(mat.$m2-red-palette),
warn: mat.m2-define-palette(mat.$m2-red-palette),
),
typography: mat.m2-define-typography-config(),
density: 0,
));
div {
--theme-version: #{mat.get-theme-version($theme)};
}
`),
).toMatch('--theme-version: 0;');
});
it('should get theme type', () => {
expect(
transpile(`
$theme: mat.m2-define-dark-theme((
color: (
primary: mat.m2-define-palette(mat.$m2-red-palette),
accent: mat.m2-define-palette(mat.$m2-red-palette),
),
));
div {
--theme-type: #{mat.get-theme-type($theme)};
}
`),
).toMatch('--theme-type: dark;');
});
it('should get role color', () => {
expect(
transpile(`
$theme: mat.m2-define-light-theme((
color: (
primary: mat.m2-define-palette(mat.$m2-red-palette),
accent: mat.m2-define-palette(mat.$m2-green-palette)
)
));
div {
color: mat.get-theme-color($theme, accent);
}
`),
).toMatch('color: #4caf50;');
});
it('should get palette color', () => {
expect(
transpile(`
$theme: mat.m2-define-light-theme((
color: (
primary: mat.m2-define-palette(mat.$m2-red-palette),
accent: mat.m2-define-palette(mat.$m2-green-palette)
)
));
div {
color: mat.get-theme-color($theme, accent, A200);
}
`),
).toMatch('color: #69f0ae;');
});
it('should get typography properties from theme', () => {
const css = transpile(`
$theme: mat.m2-define-light-theme((
typography: mat.m2-define-typography-config()
));
div {
font: mat.get-theme-typography($theme, headline-1);
font-family: mat.get-theme-typography($theme, headline-1, font-family);
font-size: mat.get-theme-typography($theme, headline-1, font-size);
font-weight: mat.get-theme-typography($theme, headline-1, font-weight);
line-height: mat.get-theme-typography($theme, headline-1, line-height);
letter-spacing: mat.get-theme-typography($theme, headline-1, letter-spacing);
}
`);
expect(css).toMatch('font: 300 96px / 96px Roboto, sans-serif;');
expect(css).toMatch('font-family: Roboto, sans-serif;');
expect(css).toMatch('font-size: 96px;');
expect(css).toMatch('font-weight: 300;');
expect(css).toMatch('line-height: 96px;');
expect(css).toMatch('letter-spacing: -0.015625em;');
});
it('should get density scale', () => {
expect(
transpile(`
$theme: mat.m2-define-light-theme((
density: -1
));
div {
--density-scale: #{mat.get-theme-density($theme)};
}
`),
).toMatch('--density-scale: -1;');
});
it('should check what information the theme has', () => {
const css = transpile(`
$theme: mat.m2-define-light-theme((
color: (
primary: mat.m2-define-palette(mat.$m2-red-palette),
accent: mat.m2-define-palette(mat.$m2-red-palette),
),
typography: mat.m2-define-typography-config(),
density: -1,
));
$color-only: mat.m2-define-light-theme((
color: (
primary: mat.m2-define-palette(mat.$m2-red-palette),
accent: mat.m2-define-palette(mat.$m2-red-palette),
),
typography: null,
density: null,
));
$typography-only: mat.m2-define-light-theme((
color: null,
typography: mat.m2-define-typography-config(),
density: null,
));
$density-only: mat.m2-define-light-theme((
color: null,
typography: null,
density: -1,
));
div {
--base: #{(
mat.theme-has($theme, base),
mat.theme-has($color-only, base),
mat.theme-has($typography-only, base),
mat.theme-has($density-only, base),
)};
--color: #{(
mat.theme-has($theme, color),
mat.theme-has($color-only, color),
mat.theme-has($typography-only, color),
mat.theme-has($density-only, color),
)};
--typography: #{(
mat.theme-has($theme, typography),
mat.theme-has($color-only, typography),
mat.theme-has($typography-only, typography),
mat.theme-has($density-only, typography),
)};
--density: #{(
mat.theme-has($theme, density),
mat.theme-has($color-only, density),
mat.theme-has($typography-only, density),
mat.theme-has($density-only, density),
)};
}
`);
expect(css).toMatch(/--base: true, true, true, true;/);
expect(css).toMatch(/--color: true, true, false, false;/);
expect(css).toMatch(/--typography: true, false, true, false;/);
expect(css).toMatch(/--density: true, false, false, true;/);
});
it('should work with compatibility disabled', () => {
expect(
transpile(`
mat.$theme-legacy-inspection-api-compatibility: false;
$theme: mat.m2-define-dark-theme((
color: (
primary: mat.m2-define-palette(mat.$m2-red-palette),
accent: mat.m2-define-palette(mat.$m2-red-palette),
)
));
div {
--theme-type: #{mat.get-theme-type($theme)};
}
`),
).toMatch('--theme-type: dark;');
});
it('should not allow access via legacy APIs with compatibility disabled', () => {
expect(() =>
transpile(`
mat.$theme-legacy-inspection-api-compatibility: false;
$theme: mat.m2-define-dark-theme((
color: (
primary: mat.m2-define-palette(mat.$red-palette),
accent: mat.m2-define-palette(mat.$red-palette),
)
));
$color-config: mat.get-color-config($theme);
$primary: map.get($color-config, primary);
div {
color: #{mat.m2-get-color-from-palette($primary)};
}
`),
).toThrow();
});
}); | {
"end_byte": 7746,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/theming-inspection-api.spec.ts"
} |
components/src/material/core/theming/tests/theming-inspection-api.spec.ts_7750_15228 | describe('for m3 theme', () => {
it('should get theme version', () => {
expect(
transpile(`
$theme: mat.define-theme();
div {
--theme-version: #{mat.get-theme-version($theme)};
}
`),
).toMatch('--theme-version: 1;');
});
it('should get theme type', () => {
expect(
transpile(`
$theme: mat.define-theme();
div {
--theme-type: #{mat.get-theme-type($theme)};
}
`),
).toMatch('--theme-type: light;');
});
it('should get role color', () => {
expect(
transpile(`
$theme: mat.define-theme();
div {
color: mat.get-theme-color($theme, primary-container);
}
`),
).toMatch('color: #ecdcff;');
});
it('should error on invalid color role', () => {
expect(() =>
transpile(`
$theme: mat.define-theme();
div {
color: mat.get-theme-color($theme, fake-role);
}
`),
).toThrowError(/Valid color roles are.*Got: fake-role/);
});
it('should get palette color', () => {
expect(
transpile(`
$theme: mat.define-theme();
div {
color: mat.get-theme-color($theme, tertiary, 20);
}
`),
).toMatch('color: #42008a;');
});
it('should error on invalid color palette', () => {
expect(() =>
transpile(`
$theme: mat.define-theme();
div {
color: mat.get-theme-color($theme, fake-palette, 20);
}
`),
).toThrowError(/Valid palettes are.*Got: fake-palette/);
});
it('should error on invalid color hue', () => {
expect(() =>
transpile(`
$theme: mat.define-theme();
div {
color: mat.get-theme-color($theme, neutral, 11);
}
`),
).toThrowError(/Valid hues for neutral are.*Got: 11/);
});
it('should error on wrong number of get-color-theme args', () => {
expect(() =>
transpile(`
$theme: mat.define-theme();
div {
color: mat.get-theme-color($theme);
}
`),
).toThrowError(/Expected between 2 and 4 arguments\. Got: 1/);
});
it('should get typography properties from theme', () => {
const css = transpile(`
$theme: mat.define-theme();
div {
font: mat.get-theme-typography($theme, headline-large);
font-family: mat.get-theme-typography($theme, headline-large, font-family);
font-size: mat.get-theme-typography($theme, headline-large, font-size);
font-weight: mat.get-theme-typography($theme, headline-large, font-weight);
line-height: mat.get-theme-typography($theme, headline-large, line-height);
letter-spacing: mat.get-theme-typography($theme, headline-large, letter-spacing);
}
`);
expect(css).toMatch('font: 400 2rem / 2.5rem Roboto, sans-serif;');
expect(css).toMatch('font-family: Roboto, sans-serif;');
expect(css).toMatch('font-size: 2rem;');
expect(css).toMatch('font-weight: 400;');
expect(css).toMatch('line-height: 2.5rem;');
expect(css).toMatch('letter-spacing: 0;');
});
it('should error on invalid typescale', () => {
expect(() =>
transpile(`
$theme: mat.define-theme();
div {
font: mat.get-theme-typography($theme, subtitle-large);
}
`),
).toThrowError(/Valid typescales are:.*Got: subtitle-large/);
});
it('should error on invalid typography property', () => {
expect(() =>
transpile(`
$theme: mat.define-theme();
div {
text-transform: mat.get-theme-typography($theme, body-small, text-transform);
}
`),
).toThrowError(/Valid typography properties are:.*Got: text-transform/);
});
it('should get density scale', () => {
expect(
transpile(`
$theme: mat.define-theme();
div {
--density-scale: #{mat.get-theme-density($theme)};
}
`),
).toMatch('--density-scale: 0;');
});
it('should check what information the theme has', () => {
const css = transpile(`
$theme: mat.define-theme();
$color-only: mat.define-colors();
$typography-only: mat.define-typography();
$density-only: mat.define-density();
div {
--base: #{(
mat.theme-has($theme, base),
mat.theme-has($color-only, base),
mat.theme-has($typography-only, base),
mat.theme-has($density-only, base),
)};
--color: #{(
mat.theme-has($theme, color),
mat.theme-has($color-only, color),
mat.theme-has($typography-only, color),
mat.theme-has($density-only, color),
)};
--typography: #{(
mat.theme-has($theme, typography),
mat.theme-has($color-only, typography),
mat.theme-has($typography-only, typography),
mat.theme-has($density-only, typography),
)};
--density: #{(
mat.theme-has($theme, density),
mat.theme-has($color-only, density),
mat.theme-has($typography-only, density),
mat.theme-has($density-only, density),
)};
}
`);
expect(css).toMatch(/--base: true, false, false, false;/);
expect(css).toMatch(/--color: true, true, false, false;/);
expect(css).toMatch(/--typography: true, false, true, false;/);
expect(css).toMatch(/--density: true, false, false, true;/);
});
it('should error when reading theme type from a theme with no color information', () => {
expect(() =>
transpile(`
$theme: mat.define-density();
div {
color: mat.get-theme-type($theme);
}
`),
).toThrowError(/Color information is not available on this theme/);
});
it('should error when reading color from a theme with no color information', () => {
expect(() =>
transpile(`
$theme: mat.define-density();
div {
color: mat.get-theme-color($theme, primary);
}
`),
).toThrowError(/Color information is not available on this theme/);
});
it('should error when reading typography from a theme with no typography information', () => {
expect(() =>
transpile(`
$theme: mat.define-density();
div {
font: mat.get-theme-typography($theme, body-small);
}
`),
).toThrowError(/Typography information is not available on this theme/);
});
it('should error when reading density from a theme with no density information', () => {
expect(() =>
transpile(`
$theme: mat.define-colors();
div {
--density: #{mat.get-theme-density($theme)};
}
`),
).toThrowError(/Density information is not available on this theme/);
});
it('should not emit styles for removed theme dimensions', () => {
const css = transpile(`
$theme: mat.theme-remove(mat.define-theme(), base, color, typography, density);
div {
@include mat.all-component-themes($theme);
}`);
expect(css.trim()).toBe('');
});
});
}); | {
"end_byte": 15228,
"start_byte": 7750,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/theming-inspection-api.spec.ts"
} |
components/src/material/core/theming/tests/BUILD.bazel_0_2205 | load("//tools:defaults.bzl", "jasmine_node_test", "sass_binary", "ts_library")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
package(default_visibility = ["//visibility:public"])
# Test theme used to ensure that our themes will compile using CSS variables in
# the palettes.
sass_binary(
name = "test-css-variables-theme",
testonly = True,
src = "test-css-variables-theme.scss",
deps = [
"//src/material/core:theming_scss_lib",
],
)
# Sass binary which is used to ensure that our themes will compile with the
# pattern for configuring themes. For more information, inspect
# the `mat-light-theme` and `mat-dark-theme` theming functions.
sass_binary(
name = "test-theming-api",
testonly = True,
src = "test-theming-api.scss",
deps = [
"//src/material/core:theming_scss_lib",
],
)
# Sass binary used to ensure that the theming bundle works as expected.
sass_binary(
name = "test-theming-bundle",
testonly = True,
src = "test-theming-bundle.scss",
deps = ["//src/material:sass_lib"],
)
# Sass binary that asserts that setting the font family for a typography config works as expected.
sass_binary(
name = "test-typography-font-family",
testonly = True,
src = "test-typography-font-family.scss",
deps = ["//src/material:sass_lib"],
)
build_test(
name = "sass_compile_tests",
targets = [
":test-css-variables-theme",
":test-theming-api",
":test-theming-bundle",
":test-typography-font-family",
],
)
ts_library(
name = "unit_test_lib",
testonly = True,
srcs = glob([
"*.spec.ts",
]),
# TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`.
devmode_module = "commonjs",
deps = [
"//tools/postcss",
"//tools/sass:sass_lib",
"@npm//@bazel/runfiles",
"@npm//@types/jasmine",
"@npm//@types/node",
"@npm//postcss",
"@npm//sass",
],
)
jasmine_node_test(
name = "unit_tests",
srcs = [":unit_test_lib"],
data = [
"//src/material:sass_lib",
"//src/material-experimental:sass_lib",
],
shard_count = 4,
)
| {
"end_byte": 2205,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/BUILD.bazel"
} |
components/src/material/core/theming/tests/theming-typography-hierarchy.spec.ts_0_2682 | import {compileString} from 'sass';
import {runfiles} from '@bazel/runfiles';
import * as path from 'path';
import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer';
// Note: For Windows compatibility, we need to resolve the directory paths through runfiles
// which are guaranteed to reside in the source tree.
const testDir = path.join(runfiles.resolvePackageRelative('../_all-theme.scss'), '../tests');
const packagesDir = path.join(runfiles.resolveWorkspaceRelative('src/cdk/_index.scss'), '../..');
const localPackageSassImporter = createLocalAngularPackageImporter(packagesDir);
/** Transpiles given Sass content into CSS. */
function transpile(content: string) {
return compileString(
`
@use '../../../index' as mat;
$internals: _mat-theming-internals-do-not-access;
$theme: mat.define-theme();
${content}
`,
{
loadPaths: [testDir],
importers: [localPackageSassImporter],
},
).css.toString();
}
function verifyFullSelector(css: string, selector: string) {
expect(css).toMatch(
new RegExp(String.raw`(^|\n)` + selector.replace(/\./g, String.raw`\.`) + String.raw` \{`),
);
}
describe('typography hierarchy', () => {
describe('for M3', () => {
it('should emit styles for h1', () => {
const css = transpile('@include mat.typography-hierarchy($theme)');
verifyFullSelector(
css,
'.mat-display-large, .mat-typography .mat-display-large, .mat-typography h1',
);
});
it('should emit default body styles', () => {
const css = transpile('@include mat.typography-hierarchy($theme)');
verifyFullSelector(css, '.mat-body-large, .mat-typography .mat-body-large, .mat-typography');
});
it('should emit default body paragraph styles', () => {
const css = transpile('@include mat.typography-hierarchy($theme)');
verifyFullSelector(
css,
'.mat-body-large p, .mat-typography .mat-body-large p, .mat-typography p',
);
});
it('should emit m2 selectors when requested', () => {
const css = transpile('@include mat.typography-hierarchy($theme, $back-compat: true)');
verifyFullSelector(
css,
'.mat-display-large, .mat-typography .mat-display-large, .mat-typography h1, .mat-h1, .mat-typography .mat-h1, .mat-headline-1, .mat-typography .mat-headline-1',
);
});
it('should use custom selector prefix', () => {
const css = transpile(`@include mat.typography-hierarchy($theme, $selector: '.special')`);
verifyFullSelector(css, '.mat-display-large, .special .mat-display-large, .special h1');
});
});
});
| {
"end_byte": 2682,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/theming-typography-hierarchy.spec.ts"
} |
components/src/material/core/theming/tests/theming-mixin-api.spec.ts_0_773 | import {parse, Root, Rule} from 'postcss';
import {compileString} from 'sass';
import {runfiles} from '@bazel/runfiles';
import * as path from 'path';
import {compareNodes} from '../../../../../tools/postcss/compare-nodes';
import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer';
// Note: For Windows compatibility, we need to resolve the directory paths through runfiles
// which are guaranteed to reside in the source tree.
const testDir = path.join(runfiles.resolvePackageRelative('../_all-theme.scss'), '../tests');
const packagesDir = path.join(runfiles.resolveWorkspaceRelative('src/cdk/_index.scss'), '../..');
const localPackageSassImporter = createLocalAngularPackageImporter(packagesDir);
describe('theming api', () => | {
"end_byte": 773,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/theming-mixin-api.spec.ts"
} |
components/src/material/core/theming/tests/theming-mixin-api.spec.ts_774_9286 | {
/** Map of known selectors for density styles and their corresponding AST rule. */
let knownDensitySelectors: Map<string, Rule>;
// Before all tests, we collect all nodes specific to density styles. We can then
// use this check how density styles are generated. i.e. if they are properly scoped to a
// given selector.
beforeAll(() => {
knownDensitySelectors = new Map();
parse(transpile(`@include mat.all-component-densities(0);`)).each(node => {
if (node.type === 'rule') {
node.selectors.forEach(s => knownDensitySelectors.set(s, node));
}
});
});
it('should warn if color styles are duplicated', () => {
spyOn(process.stderr, 'write');
transpile(`
$theme: mat.m2-define-light-theme((
color: (
primary: mat.m2-define-palette(mat.$m2-red-palette),
accent: mat.m2-define-palette(mat.$m2-red-palette),
)
));
@include mat.all-component-themes($theme);
.dark-theme {
@include mat.all-component-themes($theme);
}
`);
expectWarning(/The same color styles are generated multiple times/);
});
it('should not warn if color styles and density are not duplicated', () => {
const parsed = parse(
transpile(`
$theme: mat.m2-define-light-theme((
color: (
primary: mat.m2-define-palette(mat.$m2-red-palette),
accent: mat.m2-define-palette(mat.$m2-red-palette),
)
));
$theme2: mat.m2-define-light-theme((
color: (
primary: mat.m2-define-palette(mat.$m2-red-palette),
accent: mat.m2-define-palette(mat.$m2-blue-palette),
)
));
@include mat.all-component-themes($theme);
.dark-theme {
@include mat.all-component-colors($theme2);
}
`),
);
expect(hasDensityStyles(parsed, null)).toBe('all');
expect(hasDensityStyles(parsed, '.dark-theme')).toBe('none');
expectNoWarning(/The same color styles are generated multiple times/);
});
it('should be possible to modify color configuration directly', () => {
const result = transpile(`
$theme: mat.m2-define-light-theme((
color: (
primary: mat.m2-define-palette(mat.$m2-red-palette),
accent: mat.m2-define-palette(mat.$m2-blue-palette),
)
));
// Updates the "icon" foreground color to hotpink.
$color: map-get($theme, color);
$theme: map-merge($color,
(foreground: map-merge(map-get($color, foreground), (icon: hotpink))));
@include mat.all-component-themes($theme);
`);
expect(result).toContain(': hotpink');
});
it('should warn if default density styles are duplicated', () => {
spyOn(process.stderr, 'write');
const parsed = parse(
transpile(`
@include mat.all-component-themes((color: null));
.dark-theme {
@include mat.all-component-themes((color: null));
}
`),
);
expect(hasDensityStyles(parsed, null)).toBe('all');
// TODO(mmalerba): Re-enable - disabled because this test does not account
// for the fact that:
// ```scss
// @include mat.button-theme($theme);
// @include mat.checkbox-theme($theme);
// ```
// produces different results than:
// ```scss
// html {
// @include mat.button-theme($theme);
// @include mat.checkbox-theme($theme);
// }
// ```
// expect(hasDensityStyles(parsed, '.dark-theme')).toBe('all');
expectWarning(/The same density styles are generated multiple times/);
});
it('should warn if density styles are duplicated', () => {
spyOn(process.stderr, 'write');
transpile(`
@include mat.all-component-themes((density: -1));
.dark-theme {
@include mat.all-component-themes((density: -1));
}
`);
expectWarning(/The same density styles are generated multiple times/);
});
it('should not warn if density styles are not duplicated', () => {
spyOn(process.stderr, 'write');
transpile(`
@include mat.all-component-themes((density: -1));
.dark-theme {
@include mat.all-component-themes((density: -2));
}
`);
expect(process.stderr.write).toHaveBeenCalledTimes(0);
});
it('should warn if typography styles are duplicated', () => {
spyOn(process.stderr, 'write');
transpile(`
$theme: (typography: mat.m2-define-typography-config(), density: null);
@include mat.all-component-themes($theme);
.dark-theme {
@include mat.all-component-themes($theme);
}
`);
expectWarning(/The same typography styles are generated multiple times/);
});
it('should not warn if typography styles are not duplicated', () => {
spyOn(process.stderr, 'write');
transpile(`
@include mat.all-component-themes((
typography: mat.m2-define-typography-config(),
density: null,
));
.dark-theme {
@include mat.all-component-themes((
typography: mat.m2-define-typography-config($font-family: "sans-serif"),
density: null,
));
}
`);
expect(process.stderr.write).toHaveBeenCalledTimes(0);
});
/**
* Checks whether the given parsed stylesheet contains density styles scoped to
* a given selector. If the selector is `null`, then density is expected to be
* generated at top-level.
*/
function hasDensityStyles(parsed: Root, baseSelector: string | null): 'all' | 'partial' | 'none' {
expect(parsed.nodes).withContext('Expected CSS to be not empty.').toBeDefined();
expect(knownDensitySelectors.size).not.toBe(0);
const missingDensitySelectors = new Set(knownDensitySelectors.keys());
const baseSelectorRegex = new RegExp(`^${baseSelector} `, 'g');
// Go through all rules in the stylesheet and check if they match with any
// of the density style selectors. If so, we remove it from the copied set
// of density selectors. If the set is empty at the end, we know that density
// styles have been generated as expected.
parsed.nodes!.forEach(node => {
if (node.type !== 'rule') {
return;
}
node.selectors.forEach(selector => {
if (baseSelector && selector === baseSelector) {
// Styles emitted directly to the baseSelector are emitted to html
// when there is no baseSelector.
selector = 'html';
} else {
// Only check selectors that match the specified base selector.
if (baseSelector && !baseSelectorRegex.test(selector)) {
return;
}
}
selector = selector.replace(baseSelectorRegex, '');
const matchingRule = knownDensitySelectors.get(selector);
if (matchingRule && compareNodes(node, matchingRule)) {
missingDensitySelectors.delete(selector);
}
});
});
// If there are no unmatched density selectors, then it's confirmed that
// all density styles have been generated (scoped to the given selector).
if (missingDensitySelectors.size === 0) {
return 'all';
}
// If no density selector has been matched at all, then no density
// styles have been generated.
if (missingDensitySelectors.size === knownDensitySelectors.size) {
return 'none';
}
console.error('MISSING!!! ', [...missingDensitySelectors].join(','));
return 'partial';
}
/** Transpiles given Sass content into CSS. */
function transpile(content: string) {
return compileString(
`
@use '../../../index' as mat;
${content}
`,
{
loadPaths: [testDir],
importers: [localPackageSassImporter],
},
).css.toString();
}
/** Expects the given warning to be reported in Sass. */
function expectWarning(message: RegExp) {
expect(getMatchingWarning(message))
.withContext('Expected warning to be printed.')
.toBeDefined();
}
/** Expects the given warning not to be reported in Sass. */
function expectNoWarning(message: RegExp) {
expect(getMatchingWarning(message))
.withContext('Expected no warning to be printed.')
.toBeUndefined();
}
/**
* Gets first instance of the given warning reported in Sass. Dart sass directly writes
* to the `process.stderr` stream, so we spy on the `stderr.write` method. We
* cannot expect a specific amount of writes as Sass calls `stderr.write` multiple
* times for a warning (e.g. spacing and stack trace)
*/ | {
"end_byte": 9286,
"start_byte": 774,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/theming-mixin-api.spec.ts"
} |
components/src/material/core/theming/tests/theming-mixin-api.spec.ts_9289_9581 | function getMatchingWarning(message: RegExp) {
const writeSpy = process.stderr.write as jasmine.Spy;
return (writeSpy.calls?.all() ?? []).find(
(s: jasmine.CallInfo<typeof process.stderr.write>) =>
typeof s.args[0] === 'string' && message.test(s.args[0]),
);
}
}); | {
"end_byte": 9581,
"start_byte": 9289,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/tests/theming-mixin-api.spec.ts"
} |
components/src/material/core/theming/prebuilt/magenta-violet.scss_0_655 | @use '../../theming/definition';
@use '../../theming/color-api-backwards-compatibility';
@use '../../theming/palettes';
@use '../all-theme';
@use '../../core';
@use '../../typography/typography';
@include core.app-background();
@include core.elevation-classes();
$theme: definition.define-theme((
color: (
theme-type: dark,
primary: palettes.$magenta-palette,
tertiary: palettes.$violet-palette,
),
density: (
scale: 0,
)
));
html {
@include all-theme.all-component-themes($theme);
}
@include color-api-backwards-compatibility.color-variants-backwards-compatibility($theme);
@include typography.typography-hierarchy($theme);
| {
"end_byte": 655,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/prebuilt/magenta-violet.scss"
} |
components/src/material/core/theming/prebuilt/deeppurple-amber.scss_0_606 | @use '../all-theme';
@use '../../core';
@use '../../m2';
@use '../../typography/typography';
@include core.app-background();
@include core.elevation-classes();
// Define a theme.
$primary: m2.define-palette(m2.$deep-purple-palette);
$accent: m2.define-palette(m2.$amber-palette, A200, A100, A400);
$theme: m2.define-light-theme((
color: (
primary: $primary,
accent: $accent,
),
typography: m2.define-typography-config(),
density: 0,
));
// Include all theme styles for the components.
@include all-theme.all-component-themes($theme);
@include typography.typography-hierarchy($theme);
| {
"end_byte": 606,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/prebuilt/deeppurple-amber.scss"
} |
components/src/material/core/theming/prebuilt/indigo-pink.scss_0_599 | @use '../all-theme';
@use '../../core';
@use '../../m2';
@use '../../typography/typography';
@include core.app-background();
@include core.elevation-classes();
// Define a theme.
$primary: m2.define-palette(m2.$indigo-palette);
$accent: m2.define-palette(m2.$pink-palette, A200, A100, A400);
$theme: m2.define-light-theme((
color: (
primary: $primary,
accent: $accent
),
typography: m2.define-typography-config(),
density: 0,
));
// Include all theme styles for the components.
@include all-theme.all-component-themes($theme);
@include typography.typography-hierarchy($theme);
| {
"end_byte": 599,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/prebuilt/indigo-pink.scss"
} |
components/src/material/core/theming/prebuilt/rose-red.scss_0_650 | @use '../../theming/definition';
@use '../../theming/color-api-backwards-compatibility';
@use '../../theming/palettes';
@use '../all-theme';
@use '../../core';
@use '../../typography/typography';
@include core.app-background();
@include core.elevation-classes();
$theme: definition.define-theme((
color: (
theme-type: light,
primary: palettes.$rose-palette,
tertiary: palettes.$red-palette,
),
density: (
scale: 0,
)
));
html {
@include all-theme.all-component-themes($theme);
}
@include color-api-backwards-compatibility.color-variants-backwards-compatibility($theme);
@include typography.typography-hierarchy($theme);
| {
"end_byte": 650,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/prebuilt/rose-red.scss"
} |
components/src/material/core/theming/prebuilt/pink-bluegrey.scss_0_616 | @use '../all-theme';
@use '../../core';
@use '../../m2';
@use '../../typography/typography';
@include core.app-background();
@include core.elevation-classes();
// Define a theme.
$primary: m2.define-palette(m2.$pink-palette, 700, 500, 900);
$accent: m2.define-palette(m2.$blue-grey-palette, A200, A100, A400);
$theme: m2.define-dark-theme((
color: (
primary: $primary,
accent: $accent
),
typography: m2.define-typography-config(),
density: 0,
));
// Include all theme styles for the components.
@include all-theme.all-component-themes($theme);
@include typography.typography-hierarchy($theme);
| {
"end_byte": 616,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/prebuilt/pink-bluegrey.scss"
} |
components/src/material/core/theming/prebuilt/purple-green.scss_0_614 | @use '../all-theme';
@use '../../core';
@use '../../m2';
@use '../../typography/typography';
@include core.app-background();
@include core.elevation-classes();
// Define a theme.
$primary: m2.define-palette(m2.$purple-palette, 700, 500, 800);
$accent: m2.define-palette(m2.$green-palette, A200, A100, A400);
$theme: m2.define-dark-theme((
color: (
primary: $primary,
accent: $accent
),
typography: m2.define-typography-config(),
density: 0,
));
// Include all theme styles for the components.
@include all-theme.all-component-themes($theme);
@include typography.typography-hierarchy($theme);
| {
"end_byte": 614,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/prebuilt/purple-green.scss"
} |
components/src/material/core/theming/prebuilt/azure-blue.scss_0_652 | @use '../../theming/definition';
@use '../../theming/color-api-backwards-compatibility';
@use '../../theming/palettes';
@use '../all-theme';
@use '../../core';
@use '../../typography/typography';
@include core.app-background();
@include core.elevation-classes();
$theme: definition.define-theme((
color: (
theme-type: light,
primary: palettes.$azure-palette,
tertiary: palettes.$blue-palette,
),
density: (
scale: 0,
)
));
html {
@include all-theme.all-component-themes($theme);
}
@include color-api-backwards-compatibility.color-variants-backwards-compatibility($theme);
@include typography.typography-hierarchy($theme);
| {
"end_byte": 652,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/prebuilt/azure-blue.scss"
} |
components/src/material/core/theming/prebuilt/cyan-orange.scss_0_652 | @use '../../theming/definition';
@use '../../theming/color-api-backwards-compatibility';
@use '../../theming/palettes';
@use '../all-theme';
@use '../../core';
@use '../../typography/typography';
@include core.app-background();
@include core.elevation-classes();
$theme: definition.define-theme((
color: (
theme-type: dark,
primary: palettes.$cyan-palette,
tertiary: palettes.$orange-palette,
),
density: (
scale: 0,
)
));
html {
@include all-theme.all-component-themes($theme);
}
@include color-api-backwards-compatibility.color-variants-backwards-compatibility($theme);
@include typography.typography-hierarchy($theme);
| {
"end_byte": 652,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/theming/prebuilt/cyan-orange.scss"
} |
components/src/material/core/private/ripple-loader.ts_0_7093 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {DOCUMENT} from '@angular/common';
import {
ANIMATION_MODULE_TYPE,
Injectable,
Injector,
NgZone,
OnDestroy,
inject,
} from '@angular/core';
import {
MAT_RIPPLE_GLOBAL_OPTIONS,
RippleRenderer,
RippleTarget,
defaultRippleAnimationConfig,
} from '../ripple';
import {Platform, _getEventTarget} from '@angular/cdk/platform';
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
/** The options for the MatRippleLoader's event listeners. */
const eventListenerOptions = {capture: true};
/**
* The events that should trigger the initialization of the ripple.
* Note that we use `mousedown`, rather than `click`, for mouse devices because
* we can't rely on `mouseenter` in the shadow DOM and `click` happens too late.
*/
const rippleInteractionEvents = ['focus', 'mousedown', 'mouseenter', 'touchstart'];
/** The attribute attached to a component whose ripple has not yet been initialized. */
const matRippleUninitialized = 'mat-ripple-loader-uninitialized';
/** Additional classes that should be added to the ripple when it is rendered. */
const matRippleClassName = 'mat-ripple-loader-class-name';
/** Whether the ripple should be centered. */
const matRippleCentered = 'mat-ripple-loader-centered';
/** Whether the ripple should be disabled. */
const matRippleDisabled = 'mat-ripple-loader-disabled';
/**
* Handles attaching ripples on demand.
*
* This service allows us to avoid eagerly creating & attaching MatRipples.
* It works by creating & attaching a ripple only when a component is first interacted with.
*
* @docs-private
*/
@Injectable({providedIn: 'root'})
export class MatRippleLoader implements OnDestroy {
private _document = inject(DOCUMENT, {optional: true});
private _animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true});
private _globalRippleOptions = inject(MAT_RIPPLE_GLOBAL_OPTIONS, {optional: true});
private _platform = inject(Platform);
private _ngZone = inject(NgZone);
private _injector = inject(Injector);
private _hosts = new Map<
HTMLElement,
{renderer: RippleRenderer; target: RippleTarget; hasSetUpEvents: boolean}
>();
constructor() {
this._ngZone.runOutsideAngular(() => {
for (const event of rippleInteractionEvents) {
this._document?.addEventListener(event, this._onInteraction, eventListenerOptions);
}
});
}
ngOnDestroy(): void {
const hosts = this._hosts.keys();
for (const host of hosts) {
this.destroyRipple(host);
}
for (const event of rippleInteractionEvents) {
this._document?.removeEventListener(event, this._onInteraction, eventListenerOptions);
}
}
/**
* Configures the ripple that will be rendered by the ripple loader.
*
* Stores the given information about how the ripple should be configured on the host
* element so that it can later be retrived & used when the ripple is actually created.
*/
configureRipple(
host: HTMLElement,
config: {
className?: string;
centered?: boolean;
disabled?: boolean;
},
): void {
// Indicates that the ripple has not yet been rendered for this component.
host.setAttribute(matRippleUninitialized, this._globalRippleOptions?.namespace ?? '');
// Store the additional class name(s) that should be added to the ripple element.
if (config.className || !host.hasAttribute(matRippleClassName)) {
host.setAttribute(matRippleClassName, config.className || '');
}
// Store whether the ripple should be centered.
if (config.centered) {
host.setAttribute(matRippleCentered, '');
}
if (config.disabled) {
host.setAttribute(matRippleDisabled, '');
}
}
/** Sets the disabled state on the ripple instance corresponding to the given host element. */
setDisabled(host: HTMLElement, disabled: boolean): void {
const ripple = this._hosts.get(host);
// If the ripple has already been instantiated, just disable it.
if (ripple) {
ripple.target.rippleDisabled = disabled;
if (!disabled && !ripple.hasSetUpEvents) {
ripple.hasSetUpEvents = true;
ripple.renderer.setupTriggerEvents(host);
}
} else if (disabled) {
// Otherwise, set an attribute so we know what the
// disabled state should be when the ripple is initialized.
host.setAttribute(matRippleDisabled, '');
} else {
host.removeAttribute(matRippleDisabled);
}
}
/**
* Handles creating and attaching component internals
* when a component is initially interacted with.
*/
private _onInteraction = (event: Event) => {
const eventTarget = _getEventTarget(event);
if (eventTarget instanceof HTMLElement) {
// TODO(wagnermaciel): Consider batching these events to improve runtime performance.
const element = eventTarget.closest(
`[${matRippleUninitialized}="${this._globalRippleOptions?.namespace ?? ''}"]`,
);
if (element) {
this._createRipple(element as HTMLElement);
}
}
};
/** Creates a MatRipple and appends it to the given element. */
private _createRipple(host: HTMLElement): void {
if (!this._document || this._hosts.has(host)) {
return;
}
// Create the ripple element.
host.querySelector('.mat-ripple')?.remove();
const rippleEl = this._document.createElement('span');
rippleEl.classList.add('mat-ripple', host.getAttribute(matRippleClassName)!);
host.append(rippleEl);
const isNoopAnimations = this._animationMode === 'NoopAnimations';
const globalOptions = this._globalRippleOptions;
const enterDuration = isNoopAnimations
? 0
: globalOptions?.animation?.enterDuration ?? defaultRippleAnimationConfig.enterDuration;
const exitDuration = isNoopAnimations
? 0
: globalOptions?.animation?.exitDuration ?? defaultRippleAnimationConfig.exitDuration;
const target: RippleTarget = {
rippleDisabled:
isNoopAnimations || globalOptions?.disabled || host.hasAttribute(matRippleDisabled),
rippleConfig: {
centered: host.hasAttribute(matRippleCentered),
terminateOnPointerUp: globalOptions?.terminateOnPointerUp,
animation: {
enterDuration,
exitDuration,
},
},
};
const renderer = new RippleRenderer(
target,
this._ngZone,
rippleEl,
this._platform,
this._injector,
);
const hasSetUpEvents = !target.rippleDisabled;
if (hasSetUpEvents) {
renderer.setupTriggerEvents(host);
}
this._hosts.set(host, {
target,
renderer,
hasSetUpEvents,
});
host.removeAttribute(matRippleUninitialized);
}
destroyRipple(host: HTMLElement): void {
const ripple = this._hosts.get(host);
if (ripple) {
ripple.renderer._removeTriggerEvents();
this._hosts.delete(host);
}
}
}
| {
"end_byte": 7093,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/private/ripple-loader.ts"
} |
components/src/material/core/private/index.ts_0_253 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export {MatRippleLoader} from './ripple-loader';
| {
"end_byte": 253,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/private/index.ts"
} |
components/src/material/core/line/line.ts_0_1793 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {NgModule, Directive, ElementRef, QueryList} from '@angular/core';
import {startWith} from 'rxjs/operators';
import {MatCommonModule} from '../common-behaviors/common-module';
/**
* Shared directive to count lines inside a text area, such as a list item.
* Line elements can be extracted with a @ContentChildren(MatLine) query, then
* counted by checking the query list's length.
*/
@Directive({
selector: '[mat-line], [matLine]',
host: {'class': 'mat-line'},
})
export class MatLine {}
/**
* Helper that takes a query list of lines and sets the correct class on the host.
* @docs-private
*/
export function setLines(
lines: QueryList<unknown>,
element: ElementRef<HTMLElement>,
prefix = 'mat',
) {
// Note: doesn't need to unsubscribe, because `changes`
// gets completed by Angular when the view is destroyed.
lines.changes.pipe(startWith(lines)).subscribe(({length}) => {
setClass(element, `${prefix}-2-line`, false);
setClass(element, `${prefix}-3-line`, false);
setClass(element, `${prefix}-multi-line`, false);
if (length === 2 || length === 3) {
setClass(element, `${prefix}-${length}-line`, true);
} else if (length > 3) {
setClass(element, `${prefix}-multi-line`, true);
}
});
}
/** Adds or removes a class from an element. */
function setClass(element: ElementRef<HTMLElement>, className: string, isAdd: boolean): void {
element.nativeElement.classList.toggle(className, isAdd);
}
@NgModule({
imports: [MatCommonModule, MatLine],
exports: [MatLine, MatCommonModule],
})
export class MatLineModule {}
| {
"end_byte": 1793,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/line/line.ts"
} |
components/src/material/core/m2/_index.scss_0_1215 | // M2-specific theming APIs which are separated out into this file so they
// can be renamed conditionally depending on whether we're in 1P or 3P.
@forward './theming' show
define-light-theme,
define-dark-theme,
define-palette,
get-contrast-color-from-palette,
get-color-from-palette,
get-color-config,
get-typography-config,
get-density-config;
@forward './palette' show
$red-palette,
$pink-palette,
$indigo-palette,
$purple-palette,
$deep-purple-palette,
$blue-palette,
$light-blue-palette,
$cyan-palette,
$teal-palette,
$green-palette,
$light-green-palette,
$lime-palette,
$yellow-palette,
$amber-palette,
$orange-palette,
$deep-orange-palette,
$brown-palette,
$grey-palette,
$gray-palette,
$blue-grey-palette,
$blue-gray-palette,
$light-theme-background-palette,
$dark-theme-background-palette,
$light-theme-foreground-palette,
$dark-theme-foreground-palette;
@forward './typography' show
define-typography-level,
define-rem-typography-config,
define-typography-config,
define-legacy-typography-config;
@forward './typography-utils' show
typography-level,
font-size,
line-height,
font-weight,
letter-spacing,
font-family;
| {
"end_byte": 1215,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/m2/_index.scss"
} |
components/src/material/core/m2/_palette.scss_0_4995 | @use 'sass:map';
// Color palettes from the Material Design spec.
// See https://material.io/design/color/
//
// Contrast colors are hard-coded because it is too difficult (probably impossible) to
// calculate them. These contrast colors are pulled from the public Material Design spec swatches.
// While the contrast colors in the spec are not prescriptive, we use them for convenience.
// @deprecated renamed to $dark-primary-text.
// @breaking-change 8.0.0
$black-87-opacity: rgba(black, 0.87);
// @deprecated renamed to $light-primary-text.
// @breaking-change 8.0.0
$white-87-opacity: rgba(white, 0.87);
// @deprecated use $dark-[secondary-text,disabled-text,dividers,focused] instead.
// @breaking-change 8.0.0
$black-12-opacity: rgba(black, 0.12);
// @deprecated use $light-[secondary-text,disabled-text,dividers,focused] instead.
// @breaking-change 8.0.0
$white-12-opacity: rgba(white, 0.12);
// @deprecated use $dark-[secondary-text,disabled-text,dividers,focused] instead.
// @breaking-change 8.0.0
$black-6-opacity: rgba(black, 0.06);
// @deprecated use $light-[secondary-text,disabled-text,dividers,focused] instead.
// @breaking-change 8.0.0
$white-6-opacity: rgba(white, 0.06);
$dark-primary-text: rgba(black, 0.87);
$dark-secondary-text: rgba(black, 0.54);
$dark-disabled-text: rgba(black, 0.38);
$dark-dividers: rgba(black, 0.12);
$dark-focused: rgba(black, 0.12);
$light-primary-text: white;
$light-secondary-text: rgba(white, 0.7);
$light-disabled-text: rgba(white, 0.5);
$light-dividers: rgba(white, 0.12);
$light-focused: rgba(white, 0.12);
$red-palette: (
50: #ffebee,
100: #ffcdd2,
200: #ef9a9a,
300: #e57373,
400: #ef5350,
500: #f44336,
600: #e53935,
700: #d32f2f,
800: #c62828,
900: #b71c1c,
A100: #ff8a80,
A200: #ff5252,
A400: #ff1744,
A700: #d50000,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $dark-primary-text,
500: $light-primary-text,
600: $light-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $light-primary-text,
A400: $light-primary-text,
A700: $light-primary-text,
)
);
$pink-palette: (
50: #fce4ec,
100: #f8bbd0,
200: #f48fb1,
300: #f06292,
400: #ec407a,
500: #e91e63,
600: #d81b60,
700: #c2185b,
800: #ad1457,
900: #880e4f,
A100: #ff80ab,
A200: #ff4081,
A400: #f50057,
A700: #c51162,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $dark-primary-text,
500: $light-primary-text,
600: $light-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $light-primary-text,
A400: $light-primary-text,
A700: $light-primary-text,
)
);
$purple-palette: (
50: #f3e5f5,
100: #e1bee7,
200: #ce93d8,
300: #ba68c8,
400: #ab47bc,
500: #9c27b0,
600: #8e24aa,
700: #7b1fa2,
800: #6a1b9a,
900: #4a148c,
A100: #ea80fc,
A200: #e040fb,
A400: #d500f9,
A700: #aa00ff,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $light-primary-text,
400: $light-primary-text,
500: $light-primary-text,
600: $light-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $light-primary-text,
A400: $light-primary-text,
A700: $light-primary-text,
)
);
$deep-purple-palette: (
50: #ede7f6,
100: #d1c4e9,
200: #b39ddb,
300: #9575cd,
400: #7e57c2,
500: #673ab7,
600: #5e35b1,
700: #512da8,
800: #4527a0,
900: #311b92,
A100: #b388ff,
A200: #7c4dff,
A400: #651fff,
A700: #6200ea,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $light-primary-text,
400: $light-primary-text,
500: $light-primary-text,
600: $light-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $light-primary-text,
A400: $light-primary-text,
A700: $light-primary-text,
)
);
$indigo-palette: (
50: #e8eaf6,
100: #c5cae9,
200: #9fa8da,
300: #7986cb,
400: #5c6bc0,
500: #3f51b5,
600: #3949ab,
700: #303f9f,
800: #283593,
900: #1a237e,
A100: #8c9eff,
A200: #536dfe,
A400: #3d5afe,
A700: #304ffe,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $light-primary-text,
400: $light-primary-text,
500: $light-primary-text,
600: $light-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $light-primary-text,
A400: $light-primary-text,
A700: $light-primary-text,
)
); | {
"end_byte": 4995,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/m2/_palette.scss"
} |
components/src/material/core/m2/_palette.scss_4997_9766 | $blue-palette: (
50: #e3f2fd,
100: #bbdefb,
200: #90caf9,
300: #64b5f6,
400: #42a5f5,
500: #2196f3,
600: #1e88e5,
700: #1976d2,
800: #1565c0,
900: #0d47a1,
A100: #82b1ff,
A200: #448aff,
A400: #2979ff,
A700: #2962ff,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $dark-primary-text,
500: $light-primary-text,
600: $light-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $light-primary-text,
A400: $light-primary-text,
A700: $light-primary-text,
)
);
$light-blue-palette: (
50: #e1f5fe,
100: #b3e5fc,
200: #81d4fa,
300: #4fc3f7,
400: #29b6f6,
500: #03a9f4,
600: #039be5,
700: #0288d1,
800: #0277bd,
900: #01579b,
A100: #80d8ff,
A200: #40c4ff,
A400: #00b0ff,
A700: #0091ea,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $dark-primary-text,
500: $light-primary-text,
600: $light-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $dark-primary-text,
A400: $dark-primary-text,
A700: $light-primary-text,
)
);
$cyan-palette: (
50: #e0f7fa,
100: #b2ebf2,
200: #80deea,
300: #4dd0e1,
400: #26c6da,
500: #00bcd4,
600: #00acc1,
700: #0097a7,
800: #00838f,
900: #006064,
A100: #84ffff,
A200: #18ffff,
A400: #00e5ff,
A700: #00b8d4,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $dark-primary-text,
500: $light-primary-text,
600: $light-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $dark-primary-text,
A400: $dark-primary-text,
A700: $dark-primary-text,
)
);
$teal-palette: (
50: #e0f2f1,
100: #b2dfdb,
200: #80cbc4,
300: #4db6ac,
400: #26a69a,
500: #009688,
600: #00897b,
700: #00796b,
800: #00695c,
900: #004d40,
A100: #a7ffeb,
A200: #64ffda,
A400: #1de9b6,
A700: #00bfa5,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $dark-primary-text,
500: $light-primary-text,
600: $light-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $dark-primary-text,
A400: $dark-primary-text,
A700: $dark-primary-text,
)
);
$green-palette: (
50: #e8f5e9,
100: #c8e6c9,
200: #a5d6a7,
300: #81c784,
400: #66bb6a,
500: #4caf50,
600: #43a047,
700: #388e3c,
800: #2e7d32,
900: #1b5e20,
A100: #b9f6ca,
A200: #69f0ae,
A400: #00e676,
A700: #00c853,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $dark-primary-text,
500: $dark-primary-text,
600: $light-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $dark-primary-text,
A400: $dark-primary-text,
A700: $dark-primary-text,
)
);
$light-green-palette: (
50: #f1f8e9,
100: #dcedc8,
200: #c5e1a5,
300: #aed581,
400: #9ccc65,
500: #8bc34a,
600: #7cb342,
700: #689f38,
800: #558b2f,
900: #33691e,
A100: #ccff90,
A200: #b2ff59,
A400: #76ff03,
A700: #64dd17,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $dark-primary-text,
500: $dark-primary-text,
600: $dark-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $dark-primary-text,
A400: $dark-primary-text,
A700: $dark-primary-text,
)
);
$lime-palette: (
50: #f9fbe7,
100: #f0f4c3,
200: #e6ee9c,
300: #dce775,
400: #d4e157,
500: #cddc39,
600: #c0ca33,
700: #afb42b,
800: #9e9d24,
900: #827717,
A100: #f4ff81,
A200: #eeff41,
A400: #c6ff00,
A700: #aeea00,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $dark-primary-text,
500: $dark-primary-text,
600: $dark-primary-text,
700: $dark-primary-text,
800: $dark-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $dark-primary-text,
A400: $dark-primary-text,
A700: $dark-primary-text,
)
); | {
"end_byte": 9766,
"start_byte": 4997,
"url": "https://github.com/angular/components/blob/main/src/material/core/m2/_palette.scss"
} |
components/src/material/core/m2/_palette.scss_9768_14707 | $yellow-palette: (
50: #fffde7,
100: #fff9c4,
200: #fff59d,
300: #fff176,
400: #ffee58,
500: #ffeb3b,
600: #fdd835,
700: #fbc02d,
800: #f9a825,
900: #f57f17,
A100: #ffff8d,
A200: #ffff00,
A400: #ffea00,
A700: #ffd600,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $dark-primary-text,
500: $dark-primary-text,
600: $dark-primary-text,
700: $dark-primary-text,
800: $dark-primary-text,
900: $dark-primary-text,
A100: $dark-primary-text,
A200: $dark-primary-text,
A400: $dark-primary-text,
A700: $dark-primary-text,
)
);
$amber-palette: (
50: #fff8e1,
100: #ffecb3,
200: #ffe082,
300: #ffd54f,
400: #ffca28,
500: #ffc107,
600: #ffb300,
700: #ffa000,
800: #ff8f00,
900: #ff6f00,
A100: #ffe57f,
A200: #ffd740,
A400: #ffc400,
A700: #ffab00,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $dark-primary-text,
500: $dark-primary-text,
600: $dark-primary-text,
700: $dark-primary-text,
800: $dark-primary-text,
900: $dark-primary-text,
A100: $dark-primary-text,
A200: $dark-primary-text,
A400: $dark-primary-text,
A700: $dark-primary-text,
)
);
$orange-palette: (
50: #fff3e0,
100: #ffe0b2,
200: #ffcc80,
300: #ffb74d,
400: #ffa726,
500: #ff9800,
600: #fb8c00,
700: #f57c00,
800: #ef6c00,
900: #e65100,
A100: #ffd180,
A200: #ffab40,
A400: #ff9100,
A700: #ff6d00,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $dark-primary-text,
500: $dark-primary-text,
600: $dark-primary-text,
700: $dark-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $dark-primary-text,
A400: $dark-primary-text,
A700: black,
)
);
$deep-orange-palette: (
50: #fbe9e7,
100: #ffccbc,
200: #ffab91,
300: #ff8a65,
400: #ff7043,
500: #ff5722,
600: #f4511e,
700: #e64a19,
800: #d84315,
900: #bf360c,
A100: #ff9e80,
A200: #ff6e40,
A400: #ff3d00,
A700: #dd2c00,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $dark-primary-text,
500: $light-primary-text,
600: $light-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $dark-primary-text,
A400: $light-primary-text,
A700: $light-primary-text,
)
);
$brown-palette: (
50: #efebe9,
100: #d7ccc8,
200: #bcaaa4,
300: #a1887f,
400: #8d6e63,
500: #795548,
600: #6d4c41,
700: #5d4037,
800: #4e342e,
900: #3e2723,
A100: #d7ccc8,
A200: #bcaaa4,
A400: #8d6e63,
A700: #5d4037,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $light-primary-text,
400: $light-primary-text,
500: $light-primary-text,
600: $light-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $dark-primary-text,
A400: $light-primary-text,
A700: $light-primary-text,
)
);
$grey-palette: (
50: #fafafa,
100: #f5f5f5,
200: #eeeeee,
300: #e0e0e0,
400: #bdbdbd,
500: #9e9e9e,
600: #757575,
700: #616161,
800: #424242,
900: #212121,
A100: #ffffff,
A200: #eeeeee,
A400: #bdbdbd,
A700: #616161,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $dark-primary-text,
500: $dark-primary-text,
600: $light-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $dark-primary-text,
A400: $dark-primary-text,
A700: $light-primary-text,
)
);
// Alias for alternate spelling.
$gray-palette: $grey-palette;
$blue-grey-palette: (
50: #eceff1,
100: #cfd8dc,
200: #b0bec5,
300: #90a4ae,
400: #78909c,
500: #607d8b,
600: #546e7a,
700: #455a64,
800: #37474f,
900: #263238,
A100: #cfd8dc,
A200: #b0bec5,
A400: #78909c,
A700: #455a64,
contrast: (
50: $dark-primary-text,
100: $dark-primary-text,
200: $dark-primary-text,
300: $dark-primary-text,
400: $light-primary-text,
500: $light-primary-text,
600: $light-primary-text,
700: $light-primary-text,
800: $light-primary-text,
900: $light-primary-text,
A100: $dark-primary-text,
A200: $dark-primary-text,
A400: $light-primary-text,
A700: $light-primary-text,
)
);
// Alias for alternate spelling.
$blue-gray-palette: $blue-grey-palette;
// Background palette for light themes. | {
"end_byte": 14707,
"start_byte": 9768,
"url": "https://github.com/angular/components/blob/main/src/material/core/m2/_palette.scss"
} |
components/src/material/core/m2/_palette.scss_14708_17385 | $light-theme-background-palette: (
status-bar: map.get($grey-palette, 300),
app-bar: map.get($grey-palette, 100),
background: map.get($grey-palette, 50),
hover: rgba(black, 0.04), // TODO(kara): check style with Material Design UX
card: white,
dialog: white,
disabled-button: rgba(black, 0.12),
raised-button: white,
focused-button: $dark-focused,
selected-button: map.get($grey-palette, 300),
selected-disabled-button: map.get($grey-palette, 400),
disabled-button-toggle: map.get($grey-palette, 200),
unselected-chip: map.get($grey-palette, 300),
disabled-list-option: map.get($grey-palette, 200),
tooltip: map.get($grey-palette, 700),
);
// Background palette for dark themes.
$dark-theme-background-palette: (
status-bar: black,
app-bar: map.get($grey-palette, 900),
background: #303030,
hover: rgba(white, 0.04), // TODO(kara): check style with Material Design UX
card: map.get($grey-palette, 800),
dialog: map.get($grey-palette, 800),
disabled-button: rgba(white, 0.12),
raised-button: map.get($grey-palette, 800),
focused-button: $light-focused,
selected-button: map.get($grey-palette, 900),
selected-disabled-button: map.get($grey-palette, 800),
disabled-button-toggle: black,
unselected-chip: map.get($grey-palette, 700),
disabled-list-option: rgba(white, 0.12),
tooltip: map.get($grey-palette, 700),
);
// Foreground palette for light themes.
$light-theme-foreground-palette: (
base: black,
divider: $dark-dividers,
dividers: $dark-dividers,
disabled: $dark-disabled-text,
disabled-button: rgba(black, 0.26),
disabled-text: $dark-disabled-text,
elevation: black,
hint-text: $dark-disabled-text,
secondary-text: $dark-secondary-text,
icon: rgba(black, 0.54),
icons: rgba(black, 0.54),
text: rgba(black, 0.87),
slider-min: rgba(black, 0.87),
slider-off: rgba(black, 0.26),
slider-off-active: rgba(black, 0.38),
);
// Foreground palette for dark themes.
$dark-theme-foreground-palette: (
base: white,
divider: $light-dividers,
dividers: $light-dividers,
disabled: $light-disabled-text,
disabled-button: rgba(white, 0.3),
disabled-text: $light-disabled-text,
elevation: black,
hint-text: $light-disabled-text,
secondary-text: $light-secondary-text,
icon: white,
icons: white,
text: white,
slider-min: white,
slider-off: rgba(white, 0.3),
slider-off-active: rgba(white, 0.3),
); | {
"end_byte": 17385,
"start_byte": 14708,
"url": "https://github.com/angular/components/blob/main/src/material/core/m2/_palette.scss"
} |
components/src/material/core/m2/_typography.scss_0_6312 | @use 'sass:map';
@use 'sass:math';
@use 'sass:meta';
@use 'sass:string';
$_default-font-family: string.unquote('Roboto, sans-serif');
@function _px-to-rem($px) {
@return math.div($px, 16px) * 1rem;
}
@function _get-letter-spacing($tracking, $font-size) {
@return math.div($tracking, $font-size * 16) * 1em;
}
$_mdc-levels: (
headline1: (
font-family: $_default-font-family,
font-size: _px-to-rem(96px),
line-height: _px-to-rem(96px),
font-weight: 300,
letter-spacing: _get-letter-spacing(-1.5, 6),
text-decoration: inherit,
text-transform: inherit,
),
headline2: (
font-family: $_default-font-family,
font-size: _px-to-rem(60px),
line-height: _px-to-rem(60px),
font-weight: 300,
letter-spacing: _get-letter-spacing(-0.5, 3.75),
text-decoration: inherit,
text-transform: inherit,
),
headline3: (
font-family: $_default-font-family,
font-size: _px-to-rem(48px),
line-height: _px-to-rem(50px),
font-weight: 400,
letter-spacing: normal,
text-decoration: inherit,
text-transform: inherit,
),
headline4: (
font-family: $_default-font-family,
font-size: _px-to-rem(34px),
line-height: _px-to-rem(40px),
font-weight: 400,
letter-spacing: _get-letter-spacing(0.25, 2.125),
text-decoration: inherit,
text-transform: inherit,
),
headline5: (
font-family: $_default-font-family,
font-size: _px-to-rem(24px),
line-height: _px-to-rem(32px),
font-weight: 400,
letter-spacing: normal,
text-decoration: inherit,
text-transform: inherit,
),
headline6: (
font-family: $_default-font-family,
font-size: _px-to-rem(20px),
line-height: _px-to-rem(32px),
font-weight: 500,
letter-spacing: _get-letter-spacing(0.25, 1.25),
text-decoration: inherit,
text-transform: inherit,
),
subtitle1: (
font-family: $_default-font-family,
font-size: _px-to-rem(16px),
line-height: _px-to-rem(28px),
font-weight: 400,
letter-spacing: _get-letter-spacing(0.15, 1),
text-decoration: inherit,
text-transform: inherit,
),
subtitle2: (
font-family: $_default-font-family,
font-size: _px-to-rem(14px),
line-height: _px-to-rem(22px),
font-weight: 500,
letter-spacing: _get-letter-spacing(0.1, 0.875),
text-decoration: inherit,
text-transform: inherit,
),
body1: (
font-family: $_default-font-family,
font-size: _px-to-rem(16px),
line-height: _px-to-rem(24px),
font-weight: 400,
letter-spacing: _get-letter-spacing(0.5, 1),
text-decoration: inherit,
text-transform: inherit,
),
body2: (
font-family: $_default-font-family,
font-size: _px-to-rem(14px),
line-height: _px-to-rem(20px),
font-weight: 400,
letter-spacing: _get-letter-spacing(0.25, 0.875),
text-decoration: inherit,
text-transform: inherit,
),
caption: (
font-family: $_default-font-family,
font-size: _px-to-rem(12px),
line-height: _px-to-rem(20px),
font-weight: 400,
letter-spacing: _get-letter-spacing(0.4, 0.75),
text-decoration: inherit,
text-transform: inherit,
),
button: (
font-family: $_default-font-family,
font-size: _px-to-rem(14px),
line-height: _px-to-rem(36px),
font-weight: 500,
letter-spacing: _get-letter-spacing(1.25, 0.875),
text-decoration: none,
text-transform: uppercase,
),
overline: (
font-family: $_default-font-family,
font-size: _px-to-rem(12px),
line-height: _px-to-rem(32px),
font-weight: 500,
letter-spacing: _get-letter-spacing(2, 0.75),
text-decoration: none,
text-transform: uppercase,
),
);
/// Defines a typography level from the Material Design spec.
/// @param {String} $font-size The font-size for this level.
/// @param {String | Number} $line-height The line-height for this level.
/// @param {String | Number} $font-weight The font-weight for this level.
/// @param {String} $font-family The font-family for this level.
/// @param {String} $letter-spacing The letter-spacing for this level.
/// @returns {Map} A map representing the definition of this typographic level.
@function define-typography-level(
$font-size,
$line-height: $font-size,
$font-weight: 400,
$font-family: null,
$letter-spacing: normal) {
@return (
font-size: $font-size,
line-height: $line-height,
font-weight: $font-weight,
font-family: $font-family,
letter-spacing: $letter-spacing
);
}
/// Defines a collection of typography levels to configure typography for an application.
/// Any level not specified defaults to the values defined in the Material Design specification:
/// https://material.io/guidelines/style/typography.html.
///
/// Note that the Material Design specification does not describe explicit letter-spacing values.
/// The values here come from reverse engineering the Material Design examples.
/// @param {String} $font-family Default font-family for levels that don't specify font-family.
/// @param {Map} $display-4 Configuration for the "display-4" typographic level.
/// @param {Map} $display-3 Configuration for the "display-3" typographic level.
/// @param {Map} $display-2 Configuration for the "display-2" typographic level.
/// @param {Map} $display-1 Configuration for the "display-1" typographic level.
/// @param {Map} $headline Configuration for the "headline" typographic level.
/// @param {Map} $title Configuration for the "title" typographic level.
/// @param {Map} $subheading-2 Configuration for the "subheading-2" typographic level.
/// @param {Map} $subheading-1 Configuration for the "subheading-1" typographic level.
/// @param {Map} $body-2 Configuration for the "body-2" typographic level.
/// @param {Map} $body-1 Configuration for the "body-1" typographic level.
/// @param {Map} $caption Configuration for the "caption" typographic level.
/// @param {Map} $button Configuration for the "button" typographic level.
/// @param {Map} $input Configuration for the "input" typographic level.
/// @returns {Map} A typography config for the application.
///
/// @deprecated Use `mat.m2-define-typography-config` instead. See https://v17.material.angular.io/guide/mdc-migration for information about migrating.
/// @breaking-change 17.0.0
@function define-legacy-typography-config | {
"end_byte": 6312,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/m2/_typography.scss"
} |
components/src/material/core/m2/_typography.scss_6312_13252 | (
$font-family: 'Roboto, "Helvetica Neue", sans-serif',
$display-4: define-typography-level(112px, 112px, 300, $letter-spacing: -0.05em),
$display-3: define-typography-level(56px, 56px, 400, $letter-spacing: -0.02em),
$display-2: define-typography-level(45px, 48px, 400, $letter-spacing: -0.005em),
$display-1: define-typography-level(34px, 40px, 400),
$headline: define-typography-level(24px, 32px, 400),
$title: define-typography-level(20px, 32px, 500),
$subheading-2: define-typography-level(16px, 28px, 400),
$subheading-1: define-typography-level(15px, 24px, 400),
$body-2: define-typography-level(14px, 24px, 500),
$body-1: define-typography-level(14px, 20px, 400),
$caption: define-typography-level(12px, 20px, 400),
$button: define-typography-level(14px, 14px, 500),
// Line-height must be unit-less fraction of the font-size.
$input: define-typography-level(inherit, 1.125, 400)
) {
// Declare an initial map with all of the levels.
$config: (
display-4: $display-4,
display-3: $display-3,
display-2: $display-2,
display-1: $display-1,
headline: $headline,
title: $title,
subheading-2: $subheading-2,
subheading-1: $subheading-1,
body-2: $body-2,
body-1: $body-1,
caption: $caption,
button: $button,
input: $input,
);
// Loop through the levels and set the `font-family` of the ones that don't have one to the base.
// Note that Sass can't modify maps in place, which means that we need to merge and re-assign.
@each $key, $level in $config {
@if map.get($level, font-family) == null {
$new-level: map.merge($level, (font-family: $font-family));
$config: map.merge($config, ($key: $new-level));
}
}
// Add the base font family to the config.
@return map.merge($config, (font-family: $font-family));
}
/// Generates an Angular Material typography config based on values from the official Material
/// Design spec implementation (MDC Web). All arguments are optional, but may be passed to override
/// the default values. The `mat-typography-level` function can be used to generate a custom
/// typography level map which can be passed to this function to override one of the default levels.
/// All default typography sizing generated by this function is in `px` units.
///
/// @param {String} $font-family The font family to use for levels where it is not explicitly
/// specified.
/// @param {Map} $headline-1 The font settings for the headline-1 font level.
/// @param {Map} $headline-2 The font settings for the headline-2 font level.
/// @param {Map} $headline-3 The font settings for the headline-3 font level.
/// @param {Map} $headline-4 The font settings for the headline-4 font level.
/// @param {Map} $headline-5 The font settings for the headline-5 font level.
/// @param {Map} $headline-6 The font settings for the headline-6 font level.
/// @param {Map} $subtitle-1 The font settings for the subtitle-1 font level.
/// @param {Map} $subtitle-2 The font settings for the subtitle-2 font level.
/// @param {Map} $body-1 The font settings for the body-1 font level.
/// @param {Map} $body-2 The font settings for the body-2 font level.
/// @param {Map} $caption The font settings for the caption font level.
/// @param {Map} $button The font settings for the button font level.
/// @param {Map} $overline The font settings for the overline font level.
/// @return {Map} A map containing font settings for each of the levels in the Material Design spec.
@function define-typography-config(
// TODO(mmalerba): rename this function to define-typography-config,
// and create a predefined px based config for people that need it.
$font-family: $_default-font-family,
$headline-1: null,
$headline-2: null,
$headline-3: null,
$headline-4: null,
$headline-5: null,
$headline-6: null,
$subtitle-1: null,
$subtitle-2: null,
$body-1: null,
$body-2: null,
$caption: null,
$button: null,
$overline: null,
) {
@return _apply-font-family($font-family, (
headline-1: $headline-1 or _rem-to-px(typography-config-level-from-mdc(headline1)),
headline-2: $headline-2 or _rem-to-px(typography-config-level-from-mdc(headline2)),
headline-3: $headline-3 or _rem-to-px(typography-config-level-from-mdc(headline3)),
headline-4: $headline-4 or _rem-to-px(typography-config-level-from-mdc(headline4)),
headline-5: $headline-5 or _rem-to-px(typography-config-level-from-mdc(headline5)),
headline-6: $headline-6 or _rem-to-px(typography-config-level-from-mdc(headline6)),
subtitle-1: $subtitle-1 or _rem-to-px(typography-config-level-from-mdc(subtitle1)),
subtitle-2: $subtitle-2 or _rem-to-px(typography-config-level-from-mdc(subtitle2)),
body-1: $body-1 or _rem-to-px(typography-config-level-from-mdc(body1)),
body-2: $body-2 or _rem-to-px(typography-config-level-from-mdc(body2)),
caption: $caption or _rem-to-px(typography-config-level-from-mdc(caption)),
button: $button or _rem-to-px(typography-config-level-from-mdc(button)),
overline: $overline or _rem-to-px(typography-config-level-from-mdc(overline)),
));
}
/// Generates an Angular Material typography config based on values from the official Material
/// Design spec implementation (MDC Web). All arguments are optional, but may be passed to override
/// the default values. The `mat-typography-level` function can be used to generate a custom
/// typography level map which can be passed to this function to override one of the default levels.
/// All default typography sizing generated by this function is in `rem` units.
///
/// @param {String} $font-family The font family to use for levels where it is not explicitly
/// specified.
/// @param {Map} $headline-1 The font settings for the headline-1 font level.
/// @param {Map} $headline-2 The font settings for the headline-2 font level.
/// @param {Map} $headline-3 The font settings for the headline-3 font level.
/// @param {Map} $headline-4 The font settings for the headline-4 font level.
/// @param {Map} $headline-5 The font settings for the headline-5 font level.
/// @param {Map} $headline-6 The font settings for the headline-6 font level.
/// @param {Map} $subtitle-1 The font settings for the subtitle-1 font level.
/// @param {Map} $subtitle-2 The font settings for the subtitle-2 font level.
/// @param {Map} $body-1 The font settings for the body-1 font level.
/// @param {Map} $body-2 The font settings for the body-2 font level.
/// @param {Map} $caption The font settings for the caption font level.
/// @param {Map} $button The font settings for the button font level.
/// @param {Map} $overline The font settings for the overline font level.
/// @return {Map} A map containing font settings for each of the levels in the Material Design spec. | {
"end_byte": 13252,
"start_byte": 6312,
"url": "https://github.com/angular/components/blob/main/src/material/core/m2/_typography.scss"
} |
components/src/material/core/m2/_typography.scss_13253_16287 | @function define-rem-typography-config(
// TODO(mmalerba): rename this function to define-typography-config,
// and create a predefined px based config for people that need it.
$font-family: $_default-font-family,
$headline-1: null,
$headline-2: null,
$headline-3: null,
$headline-4: null,
$headline-5: null,
$headline-6: null,
$subtitle-1: null,
$subtitle-2: null,
$body-1: null,
$body-2: null,
$caption: null,
$button: null,
$overline: null,
) {
@return _apply-font-family($font-family, (
headline-1: $headline-1 or typography-config-level-from-mdc(headline1),
headline-2: $headline-2 or typography-config-level-from-mdc(headline2),
headline-3: $headline-3 or typography-config-level-from-mdc(headline3),
headline-4: $headline-4 or typography-config-level-from-mdc(headline4),
headline-5: $headline-5 or typography-config-level-from-mdc(headline5),
headline-6: $headline-6 or typography-config-level-from-mdc(headline6),
subtitle-1: $subtitle-1 or typography-config-level-from-mdc(subtitle1),
subtitle-2: $subtitle-2 or typography-config-level-from-mdc(subtitle2),
body-1: $body-1 or typography-config-level-from-mdc(body1),
body-2: $body-2 or typography-config-level-from-mdc(body2),
caption: $caption or typography-config-level-from-mdc(caption),
button: $button or typography-config-level-from-mdc(button),
overline: $overline or typography-config-level-from-mdc(overline),
));
}
// Converts an MDC typography level config to an Angular Material one.
@function typography-config-level-from-mdc($mdc-level, $font-family: null) {
$mdc-level-config: map.get($_mdc-levels, $mdc-level);
// Explicitly default the font family to null since we'll apply it globally
// through the `define-typgraphy-config`/`define-legacy-typography-config`.
@return define-typography-level(
$font-family: $font-family,
$font-size: map.get($mdc-level-config, font-size),
$line-height: map.get($mdc-level-config, line-height),
$font-weight: map.get($mdc-level-config, font-weight),
$letter-spacing: map.get($mdc-level-config, letter-spacing)
);
}
// Converts a map containing rem values to a map containing px values.
@function _rem-to-px($x, $px-per-rem: 16px) {
@if meta.type-of($x) == 'map' {
@each $key, $val in $x {
$x: map.merge($x, ($key: _rem-to-px($val)));
}
@return $x;
}
@if meta.type-of($x) == 'number' and math.unit($x) == 'rem' {
@return math.div($x, 1rem) * $px-per-rem;
}
@else {
@return $x;
}
}
// Applies the default font family to all levels in a typography config.
@function _apply-font-family($font-family, $initial-config) {
$config: $initial-config;
@each $key, $level in $config {
@if map.get($level, 'font-family') == null {
// Sass maps are immutable so we have to re-assign the variable each time.
$config: map.set($config, $key, map.set($level, 'font-family', $font-family));
}
}
@return map.set($config, 'font-family', $font-family);
} | {
"end_byte": 16287,
"start_byte": 13253,
"url": "https://github.com/angular/components/blob/main/src/material/core/m2/_typography.scss"
} |
components/src/material/core/m2/_typography-utils.scss_0_2891 | @use 'sass:map';
@use 'sass:meta';
@use 'sass:string';
/// Emits CSS styles for the given typography level.
/// @param {Map} $config A typography config.
/// @param {Map} $level A typography level.
@mixin typography-level($config, $level) {
// we deliberately do not use the font shorthand here because it overrides
// certain font properties that can't be configured in the current typography
// config, e.g. the font-variant-caps or font-feature-settings property
font-size: font-size($config, $level);
font-weight: font-weight($config, $level);
line-height: line-height($config, $level);
font-family: font-family($config, $level);
letter-spacing: letter-spacing($config, $level);
}
// Utility for fetching a nested value from a typography config.
@function _mat-get-type-value($config, $level, $name) {
@if meta.type-of($config) != 'map' {
@error 'Typography config must be a map. Received #{meta.type-of($config)}.';
}
@if not map.has-key($config, $level) {
@error 'Typography config does not have a level called "#{$level}". ' +
'Available levels are: #{map.keys($config)}.';
}
@return map.get(map.get($config, $level), $name);
}
/// Gets the font size for a level inside a typography config.
/// @param {Map} $config A typography config.
/// @param {Map} $level A typography level.
@function font-size($config, $level) {
@return _mat-get-type-value($config, $level, font-size);
}
/// Gets the line height for a level inside a typography config.
/// @param {Map} $config A typography config.
/// @param {Map} $level A typography level.
@function line-height($config, $level) {
@return _mat-get-type-value($config, $level, line-height);
}
/// Gets the font weight for a level inside a typography config.
/// @param {Map} $config A typography config.
/// @param {Map} $level A typography level.
@function font-weight($config, $level) {
@return _mat-get-type-value($config, $level, font-weight);
}
/// Gets the letter spacing for a level inside a typography config.
/// @param {Map} $config A typography config.
/// @param {Map} $level A typography level.
@function letter-spacing($config, $level) {
@return _mat-get-type-value($config, $level, letter-spacing);
}
/// Gets the font-family from a typography config and removes the quotes around it.
/// @param {Map} $config A typography config.
/// @param {Map} $level A typography level.
@function font-family($config, $level: null) {
@if meta.type-of($config) != 'map' {
@error 'Typography config must be a map. Received #{meta.type-of($config)}.';
}
$font-family: map.get($config, font-family);
@if $level != null {
$font-family: _mat-get-type-value($config, $level, font-family);
}
// Guard against unquoting non-string values, because it's deprecated.
@return if(meta.type-of($font-family) == string, string.unquote($font-family), $font-family);
}
| {
"end_byte": 2891,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/m2/_typography-utils.scss"
} |
components/src/material/core/m2/_theming.scss_0_5975 | @use 'sass:list';
@use 'sass:map';
@use 'sass:meta';
@use '../theming/theming';
@use './palette';
/// Extracts a color from a palette or throws an error if it doesn't exist.
/// @param {Map} $palette The palette from which to extract a color.
/// @param {String | Number} $hue The hue for which to get the color.
@function _get-color-from-palette($palette, $hue) {
@if map.has-key($palette, $hue) {
@return map.get($palette, $hue);
}
@error 'Hue "' + $hue + '" does not exist in palette. Available hues are: ' + map.keys($palette);
}
/// For a given hue in a palette, return the contrast color from the map of contrast palettes.
/// @param {Map} $palette The palette from which to extract a color.
/// @param {String | Number} $hue The hue for which to get a contrast color.
/// @returns {Color} The contrast color for the given palette and hue.
@function get-contrast-color-from-palette($palette, $hue) {
@return map.get(map.get($palette, contrast), $hue);
}
/// Creates a map of hues to colors for a theme. This is used to define a theme palette in terms
/// of the Material Design hues.
/// @param {Map} $base-palette Map of hue keys to color values for the basis for this palette.
/// @param {String | Number} $default Default hue for this palette.
/// @param {String | Number} $lighter "lighter" hue for this palette.
/// @param {String | Number} $darker "darker" hue for this palette.
/// @param {String | Number} $text "text" hue for this palette.
/// @returns {Map} A complete Angular Material theming palette.
@function define-palette($base-palette, $default: 500, $lighter: 100, $darker: 700,
$text: $default) {
$result: map.merge($base-palette, (
default: _get-color-from-palette($base-palette, $default),
lighter: _get-color-from-palette($base-palette, $lighter),
darker: _get-color-from-palette($base-palette, $darker),
text: _get-color-from-palette($base-palette, $text),
default-contrast: get-contrast-color-from-palette($base-palette, $default),
lighter-contrast: get-contrast-color-from-palette($base-palette, $lighter),
darker-contrast: get-contrast-color-from-palette($base-palette, $darker)
));
// For each hue in the palette, add a "-contrast" color to the map.
@each $hue, $color in $base-palette {
$result: map.merge($result, (
'#{$hue}-contrast': get-contrast-color-from-palette($base-palette, $hue)
));
}
@return $result;
}
/// Gets a color from a theme palette (the output of mat-palette).
/// The hue can be one of the standard values (500, A400, etc.), one of the three preconfigured
/// hues (default, lighter, darker), or any of the aforementioned suffixed with "-contrast".
///
/// @param {Map} $palette The palette from which to extract a color.
/// @param {String | Number} $hue The hue from the palette to use. If this is a value between 0
// and 1, it will be treated as opacity.
/// @param {Number} $opacity The alpha channel value for the color.
/// @returns {Color} The color for the given palette, hue, and opacity.
@function get-color-from-palette($palette, $hue: default, $opacity: null) {
// If hueKey is a number between zero and one, then it actually contains an
// opacity value, so recall this function with the default hue and that given opacity.
@if meta.type-of($hue) == number and $hue >= 0 and $hue <= 1 {
@return get-color-from-palette($palette, default, $hue);
}
// We cast the $hue to a string, because some hues starting with a number, like `700-contrast`,
// might be inferred as numbers by Sass. Casting them to string fixes the map lookup.
$color: if(map.has-key($palette, $hue), map.get($palette, $hue), map.get($palette, $hue + ''));
@if (meta.type-of($color) != color) {
// If the $color resolved to something different from a color (e.g. a CSS variable),
// we can't apply the opacity anyway so we return the value as is, otherwise Sass can
// throw an error or output something invalid.
@return $color;
}
@return rgba($color, if($opacity == null, opacity($color), $opacity));
}
// Validates the specified theme by ensuring that the optional color config defines
// a primary, accent and warn palette. Returns the theme if no failures were found.
@function _mat-validate-theme($theme) {
@if map.get($theme, color) {
$color: map.get($theme, color);
@if not map.get($color, primary) {
@error 'Theme does not define a valid "primary" palette.';
}
@else if not map.get($color, accent) {
@error 'Theme does not define a valid "accent" palette.';
}
@else if not map.get($color, warn) {
@error 'Theme does not define a valid "warn" palette.';
}
}
@return $theme;
}
// Creates a light-themed color configuration from the specified
// primary, accent and warn palettes.
@function _mat-create-light-color-config($primary, $accent, $warn: null) {
@return (
primary: $primary,
accent: $accent,
warn: if($warn != null, $warn, define-palette(palette.$red-palette)),
is-dark: false,
foreground: palette.$light-theme-foreground-palette,
background: palette.$light-theme-background-palette,
);
}
// Creates a dark-themed color configuration from the specified
// primary, accent and warn palettes.
@function _mat-create-dark-color-config($primary, $accent, $warn: null) {
@return (
primary: $primary,
accent: $accent,
warn: if($warn != null, $warn, define-palette(palette.$red-palette)),
is-dark: true,
foreground: palette.$dark-theme-foreground-palette,
background: palette.$dark-theme-background-palette,
);
}
// TODO: Remove legacy API and rename `$primary` below to `$config`. Currently it cannot be renamed
// as it would break existing apps that set the parameter by name.
/// Creates a container object for a light theme to be given to individual component theme mixins.
/// @param {Map} $primary The theme configuration object.
/// @returns {Map} A complete Angular Material theme map. | {
"end_byte": 5975,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/m2/_theming.scss"
} |
components/src/material/core/m2/_theming.scss_5976_13796 | @function define-light-theme($primary, $accent: null, $warn: define-palette(palette.$red-palette)) {
// This function creates a container object for the individual component theme mixins. Consumers
// can construct such an object by calling this function, or by building the object manually.
// There are two possible ways to invoke this function in order to create such an object:
//
// (1) Passing in a map that holds optional configurations for individual parts of the
// theming system. For `color` configurations, the function only expects the palettes
// for `primary` and `accent` (and optionally `warn`). The function will expand the
// shorthand into an actual configuration that can be consumed in `-color` mixins.
// (2) Legacy pattern: Passing in the palettes as parameters. This is not as flexible
// as passing in a configuration map because only the `color` system can be configured.
//
// If the legacy pattern is used, we generate a container object only with a light-themed
// configuration for the `color` theming part.
@if $accent != null {
@warn theming.$private-legacy-theme-warning;
$theme: _mat-validate-theme((
_is-legacy-theme: true,
color: _mat-create-light-color-config($primary, $accent, $warn),
));
@return _internalize-theme(theming.private-create-backwards-compatibility-theme($theme));
}
// If the map pattern is used (1), we just pass-through the configurations for individual
// parts of the theming system, but update the `color` configuration if set. As explained
// above, the color shorthand will be expanded to an actual light-themed color configuration.
$result: $primary;
@if map.get($primary, color) {
$color-settings: map.get($primary, color);
$primary: map.get($color-settings, primary);
$accent: map.get($color-settings, accent);
$warn: map.get($color-settings, warn);
$result: map.merge($result, (color: _mat-create-light-color-config($primary, $accent, $warn)));
}
@return _internalize-theme(
theming.private-create-backwards-compatibility-theme(_mat-validate-theme($result)));
}
// TODO: Remove legacy API and rename below `$primary` to `$config`. Currently it cannot be renamed
// as it would break existing apps that set the parameter by name.
/// Creates a container object for a dark theme to be given to individual component theme mixins.
/// @param {Map} $primary The theme configuration object.
/// @returns {Map} A complete Angular Material theme map.
@function define-dark-theme($primary, $accent: null, $warn: define-palette(palette.$red-palette)) {
// This function creates a container object for the individual component theme mixins. Consumers
// can construct such an object by calling this function, or by building the object manually.
// There are two possible ways to invoke this function in order to create such an object:
//
// (1) Passing in a map that holds optional configurations for individual parts of the
// theming system. For `color` configurations, the function only expects the palettes
// for `primary` and `accent` (and optionally `warn`). The function will expand the
// shorthand into an actual configuration that can be consumed in `-color` mixins.
// (2) Legacy pattern: Passing in the palettes as parameters. This is not as flexible
// as passing in a configuration map because only the `color` system can be configured.
//
// If the legacy pattern is used, we generate a container object only with a dark-themed
// configuration for the `color` theming part.
@if $accent != null {
@warn theming.$private-legacy-theme-warning;
$theme: _mat-validate-theme((
_is-legacy-theme: true,
color: _mat-create-dark-color-config($primary, $accent, $warn),
));
@return _internalize-theme(theming.private-create-backwards-compatibility-theme($theme));
}
// If the map pattern is used (1), we just pass-through the configurations for individual
// parts of the theming system, but update the `color` configuration if set. As explained
// above, the color shorthand will be expanded to an actual dark-themed color configuration.
$result: $primary;
@if map.get($primary, color) {
$color-settings: map.get($primary, color);
$primary: map.get($color-settings, primary);
$accent: map.get($color-settings, accent);
$warn: map.get($color-settings, warn);
$result: map.merge($result, (color: _mat-create-dark-color-config($primary, $accent, $warn)));
}
@return _internalize-theme(
theming.private-create-backwards-compatibility-theme(_mat-validate-theme($result)));
}
/// Gets the color configuration from the given theme or configuration.
/// @param {Map} $theme The theme map returned from `define-light-theme` or `define-dark-theme`.
/// @param {Map} $default The default value returned if the given `$theme` does not include a
/// `color` configuration.
/// @returns {Map} Color configuration for a theme.
@function get-color-config($theme, $default: null) {
@return theming.private-get-color-config($theme, $default);
}
/// Gets the density configuration from the given theme or configuration.
/// @param {Map} $theme-or-config The theme map returned from `define-light-theme` or
/// `define-dark-theme`.
/// @param {Map} $default The default value returned if the given `$theme` does not include a
/// `density` configuration.
/// @returns {Map} Density configuration for a theme.
@function get-density-config($theme-or-config, $default: 0) {
@return theming.private-get-density-config($theme-or-config, $default);
}
/// Gets the typography configuration from the given theme or configuration.
/// For backwards compatibility, typography is not included by default.
/// @param {Map} $theme-or-config The theme map returned from `define-light-theme` or
/// `define-dark-theme`.
/// @param {Map} $default The default value returned if the given `$theme` does not include a
/// `typography` configuration.
/// @returns {Map} Typography configuration for a theme.
@function get-typography-config($theme-or-config, $default: null) {
@return theming.private-get-typography-config($theme-or-config, $default);
}
/// Copies the given theme object and nests it within itself under a secret key and replaces the
/// original map keys with error values. This allows the inspection API which is aware of the secret
/// key to access the real values, but attempts to directly access the map will result in errors.
/// @param {Map} $theme The theme map.
@function _internalize-theme($theme) {
@if map.has-key($theme, theming.$private-internal-name) {
@return $theme;
}
$internalized-theme: (
theming.$private-internal-name: (
theme-version: 0,
m2-config: $theme
)
);
@if (theming.$theme-legacy-inspection-api-compatibility) {
@return map.merge($theme, $internalized-theme);
}
$error-theme:
_replace-values-with-errors($theme, 'Theme may only be accessed via theme inspection API');
@return map.merge($error-theme, $internalized-theme);
}
/// Replaces concrete CSS values with errors in a theme object.
/// Errors are represented as a map `(ERROR: <message>)`. Because maps are not valid CSS values,
/// the Sass will not compile if the user tries to use any of the error theme values in their CSS.
/// Users will see a message about `(ERROR: <message>)` not being a valid CSS value. Using the
/// message, that winds up getting shown, we can help explain to users why they're getting the
/// error.
/// @param {*} $value The theme value to replace with errors.
/// @param {String} $message The error message to sow users.
/// @return {Map} A version of $value where concrete CSS values have been replaced with errors | {
"end_byte": 13796,
"start_byte": 5976,
"url": "https://github.com/angular/components/blob/main/src/material/core/m2/_theming.scss"
} |
components/src/material/core/m2/_theming.scss_13797_14325 | @function _replace-values-with-errors($value, $message) {
$value-type: meta.type-of($value);
@if $value-type == 'map' {
@each $k, $v in $value {
$value: map.set($value, $k, _replace-values-with-errors($v, $message));
}
@return $value;
}
@else if $value-type == 'list' and list.length($value) > 0 {
@for $i from 1 through list.length() {
$value: list.set-nth($value, $i, _replace-values-with-errors(list.nth($value, $i), $message));
}
@return $value;
}
@return (ERROR: $message);
} | {
"end_byte": 14325,
"start_byte": 13797,
"url": "https://github.com/angular/components/blob/main/src/material/core/m2/_theming.scss"
} |
components/src/material/core/typography/_typography.scss_0_5947 | @use 'sass:list';
@use 'sass:map';
@use 'sass:string';
@use 'typography-utils';
@use '../theming/inspection';
// Definition and versioning functions live in their own files to avoid circular dependencies, but
// we re-export them here so that historical imports from this file continue to work without needing
// to be updated.
@forward './versioning';
@mixin typography-hierarchy($theme, $selector: '.mat-typography', $back-compat: false) {
@if inspection.get-theme-version($theme) == 1 {
@include _m3-typography-hierarchy($theme, $selector, $back-compat);
}
@else {
@include _m2-typography-hierarchy($theme, $selector);
}
}
@function _get-selector($selectors, $prefix) {
$result: ();
@each $selector in $selectors {
// Don't add "naked" tag selectors, and don't nest prefix selector.
@if string.index($selector, '.') == 1 {
$result: list.append($result, $selector, $separator: comma);
}
// Don't nest the prefix selector in itself.
@if $selector != $prefix {
$result: list.append($result, '#{$prefix} #{$selector}', $separator: comma);
}
}
@return $result;
}
@mixin _m3-typography-level($theme, $selector-prefix, $level, $selectors, $margin: null) {
#{_get-selector($selectors, $selector-prefix)} {
// TODO(mmalerba): When we expose system tokens as CSS vars, we should change this to emit token
// slots.
font: inspection.get-theme-typography($theme, $level, font);
letter-spacing: inspection.get-theme-typography($theme, $level, letter-spacing);
@if $margin != null {
margin: 0 0 $margin;
}
}
}
@mixin _m3-typography-hierarchy($theme, $selector-prefix, $add-m2-selectors) {
$levels: (
display-large: (
selectors: ('.mat-display-large', 'h1'),
m2-selectors: ('.mat-h1', '.mat-headline-1'),
margin: 0.5em
),
display-medium: (
selectors: ('.mat-display-medium', 'h2'),
m2-selectors: ('.mat-h2', '.mat-headline-2'),
margin: 0.5em
),
display-small: (
selectors: ('.mat-display-small', 'h3'),
m2-selectors: ('.mat-h3', '.mat-headline-3'),
margin: 0.5em
),
headline-large: (
selectors: ('.mat-headline-large', 'h4'),
m2-selectors: ('.mat-h4', '.mat-headline-4'),
margin: 0.5em
),
headline-medium: (
selectors: ('.mat-headline-medium', 'h5'),
m2-selectors: ('.mat-h5', '.mat-headline-5'),
margin: 0.5em
),
headline-small: (
selectors: ('.mat-headline-small', 'h6'),
m2-selectors: ('.mat-h6', '.mat-headline-6'),
margin: 0.5em
),
title-large: (
selectors: ('.mat-title-large'),
m2-selectors: ('.mat-subtitle-1'),
),
title-medium: (
selectors: ('.mat-title-medium'),
m2-selectors: ('.mat-subtitle-2'),
),
title-small: (
selectors: ('.mat-title-small')
),
body-large: (
selectors: ('.mat-body-large', $selector-prefix),
m2-selectors: ('.mat-body', '.mat-body-strong', '.mat-body-2'),
),
body-medium: (
selectors: ('.mat-body-medium')
),
body-small: (
selectors: ('.mat-body-small')
),
label-large: (
selectors: ('.mat-label-large')
),
label-medium: (
selectors: ('.mat-label-medium')
),
label-small: (
selectors: ('.mat-label-small'),
m2-selectors: ('.mat-small', '.mat-caption')
),
);
@each $level, $options in $levels {
@if $add-m2-selectors {
$options: map.set($options, selectors,
list.join(map.get($options, selectors), map.get($options, m2-selectors) or ()));
}
$options: map.remove($options, m2-selectors);
// Apply styles for the level.
@include _m3-typography-level($theme, $selector-prefix, $level, $options...);
// Also style <p> inside body-large.
@if $level == body-large {
#{_get-selector(map.get($options, selectors), $selector-prefix)} {
p {
margin: 0 0 0.75em;
}
}
}
}
}
/// Emits baseline typographic styles based on a given config.
/// @param {Map} $config-or-theme A typography config for an entire theme.
/// @param {String} $selector Ancestor selector under which native elements, such as h1, will
/// be styled.
@mixin _m2-typography-hierarchy($theme, $selector) {
// Note that it seems redundant to prefix the class rules with the `$selector`, however it's
// necessary if we want to allow people to overwrite the tag selectors. This is due to
// selectors like `#{$selector} h1` being more specific than ones like `.mat-title`.
.mat-h1,
.mat-headline-5,
#{$selector} .mat-h1,
#{$selector} .mat-headline-5,
#{$selector} h1 {
font: inspection.get-theme-typography($theme, headline-5, font);
letter-spacing: inspection.get-theme-typography($theme, headline-5, letter-spacing);
margin: 0 0 16px;
}
.mat-h2,
.mat-headline-6,
#{$selector} .mat-h2,
#{$selector} .mat-headline-6,
#{$selector} h2 {
font: inspection.get-theme-typography($theme, headline-6, font);
letter-spacing: inspection.get-theme-typography($theme, headline-6, letter-spacing);
margin: 0 0 16px;
}
.mat-h3,
.mat-subtitle-1,
#{$selector} .mat-h3,
#{$selector} .mat-subtitle-1,
#{$selector} h3 {
font: inspection.get-theme-typography($theme, subtitle-1, font);
letter-spacing: inspection.get-theme-typography($theme, subtitle-1, letter-spacing);
margin: 0 0 16px;
}
.mat-h4,
.mat-body-1,
#{$selector} .mat-h4,
#{$selector} .mat-body-1,
#{$selector} h4 {
font: inspection.get-theme-typography($theme, body-1, font);
letter-spacing: inspection.get-theme-typography($theme, body-1, letter-spacing);
margin: 0 0 16px;
}
// Note: the spec doesn't have anything that would correspond to h5 and h6, but we add these for
// consistency. The font sizes come from the Chrome user agent styles which have h5 at 0.83em
// and h6 at 0.67em.
.mat-h5,
#{$selector} .mat-h5,
#{$selector} h5 {
@include typography-utils | {
"end_byte": 5947,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/typography/_typography.scss"
} |
components/src/material/core/typography/_typography.scss_5947_8564 | .font-shorthand(
// calc is used here to support css variables
calc(#{inspection.get-theme-typography($theme, body-2, font-size)} * 0.83),
inspection.get-theme-typography($theme, body-2, font-weight),
inspection.get-theme-typography($theme, body-2, line-height),
inspection.get-theme-typography($theme, body-2, font-family)
);
margin: 0 0 12px;
}
.mat-h6,
#{$selector} .mat-h6,
#{$selector} h6 {
@include typography-utils.font-shorthand(
// calc is used here to support css variables
calc(#{inspection.get-theme-typography($theme, body-2, font-size)} * 0.67),
inspection.get-theme-typography($theme, body-2, font-weight),
inspection.get-theme-typography($theme, body-2, line-height),
inspection.get-theme-typography($theme, body-2, font-family)
);
margin: 0 0 12px;
}
.mat-body-strong,
.mat-subtitle-2,
#{$selector} .mat-body-strong,
#{$selector} .mat-subtitle-2 {
font: inspection.get-theme-typography($theme, subtitle-2, font);
letter-spacing: inspection.get-theme-typography($theme, subtitle-2, letter-spacing);
}
.mat-body,
.mat-body-2,
#{$selector} .mat-body,
#{$selector} .mat-body-2,
#{$selector} {
font: inspection.get-theme-typography($theme, body-2, font);
letter-spacing: inspection.get-theme-typography($theme, body-2, letter-spacing);
p {
margin: 0 0 12px;
}
}
.mat-small,
.mat-caption,
#{$selector} .mat-small,
#{$selector} .mat-caption {
font: inspection.get-theme-typography($theme, caption, font);
letter-spacing: inspection.get-theme-typography($theme, caption, letter-spacing);
}
.mat-headline-1,
#{$selector} .mat-headline-1 {
font: inspection.get-theme-typography($theme, headline-1, font);
letter-spacing: inspection.get-theme-typography($theme, headline-1, letter-spacing);
margin: 0 0 56px;
}
.mat-headline-2,
#{$selector} .mat-headline-2 {
font: inspection.get-theme-typography($theme, headline-2, font);
letter-spacing: inspection.get-theme-typography($theme, headline-2, letter-spacing);
margin: 0 0 64px;
}
.mat-headline-3,
#{$selector} .mat-headline-3 {
font: inspection.get-theme-typography($theme, headline-3, font);
letter-spacing: inspection.get-theme-typography($theme, headline-3, letter-spacing);
margin: 0 0 64px;
}
.mat-headline-4,
#{$selector} .mat-headline-4 {
font: inspection.get-theme-typography($theme, headline-4, font);
letter-spacing: inspection.get-theme-typography($theme, headline-4, letter-spacing);
margin: 0 0 64px;
}
} | {
"end_byte": 8564,
"start_byte": 5947,
"url": "https://github.com/angular/components/blob/main/src/material/core/typography/_typography.scss"
} |
components/src/material/core/typography/_typography-utils.scss_0_1291 | @use 'sass:list';
/// Outputs the shorthand `font` CSS property, based on a set of typography values. Falls back to
/// the individual properties if a value that isn't allowed in the shorthand is passed in.
/// @param {String} $font-size The font-size value.
/// @param {String | Number} $font-weight The font-weight value.
/// @param {String | Number} $line-height The line-height value.
/// @param {String} $font-family The font-family value.
/// @returns {String} The `font` shorthand value combining the given parts.
@mixin font-shorthand($font-size, $font-weight, $line-height, $font-family) {
// If any of the values are set to `inherit`, we can't use the shorthand
// so we fall back to passing in the individual properties.
@if ($font-size == inherit or
$font-weight == inherit or
$line-height == inherit or
$font-family == inherit or
$font-size == null or
$font-weight == null or
$line-height == null or
$font-family == null) {
font-size: $font-size;
font-weight: $font-weight;
line-height: $line-height;
font-family: $font-family;
}
@else {
// Otherwise use the shorthand `font`, because it's the least amount of bytes.
font: $font-weight list.slash($font-size, $line-height) $font-family;
}
}
| {
"end_byte": 1291,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/typography/_typography-utils.scss"
} |
components/src/material/core/typography/_versioning.scss_0_3844 | @use 'sass:map';
@use '../m2/typography' as m2-typography;
// Whether a config is for the Material Design 2018 typography system.
@function private-typography-is-2018-config($config) {
@return map.get($config, headline-1) != null;
}
// Whether a config is for the Material Design 2014 typography system.
@function private-typography-is-2014-config($config) {
@return map.get($config, headline) != null;
}
// Given a config for either the 2014 or 2018 Material Design typography system,
// produces a normalized typography config for the 2014 Material Design typography system.
// 2014 - https://material.io/archive/guidelines/style/typography.html#typography-styles
// 2018 - https://material.io/design/typography/the-type-system.html#type-scale
//
// Components using this function should be migrated to normalize to the 2018 style config instead.
// New components should not use this function.
@function private-typography-to-2014-config($config) {
@if $config == null {
@return null;
}
@if not private-typography-is-2014-config($config) {
$args: (
display-4: map.get($config, headline-1),
display-3: map.get($config, headline-2),
display-2: map.get($config, headline-3),
display-1: map.get($config, headline-4),
headline: map.get($config, headline-5),
title: map.get($config, headline-6),
subheading-2: map.get($config, subtitle-1),
subheading-1: map.get($config, subtitle-2),
body-2: map.get($config, body-1),
body-1: map.get($config, body-2),
button: map.get($config, button),
caption: map.get($config, caption),
font-family: map.get($config, font-family),
);
$non-null-args: ();
@each $key, $value in $args {
@if $value != null {
$non-null-args: map.merge($non-null-args, ($key: $value));
}
}
@return m2-typography.define-legacy-typography-config($non-null-args...);
}
@return $config;
}
// Given a config for either the 2014 or 2018 Material Design typography system,
// produces a normalized typography config for the 2018 Material Design typography system.
// 2014 - https://material.io/archive/guidelines/style/typography.html#typography-styles
// 2018 - https://material.io/design/typography/the-type-system.html#type-scale
//
// The $force option is used to allow components to specify that they want to re-map the keys, even
// if the 2018 keys are already present. This allows those components to preserve the (incorrect)
// behavior they had previously, when they called `private-typography-to-2014-config`. Eventually we
// should clean this up, remove the $force option, and reconcile any screen diffs.
@function private-typography-to-2018-config($config, $force: false) {
@if $config == null {
@return null;
}
@if $force or not private-typography-is-2018-config($config) {
@return (
headline-1: map.get($config, display-4),
headline-2: map.get($config, display-3),
headline-3: map.get($config, display-2),
headline-4: map.get($config, display-1),
headline-5: map.get($config, headline),
headline-6: map.get($config, title),
subtitle-1: map.get($config, subheading-2),
font-family: map.get($config, font-family),
// These mappings are odd, but body-2 in the 2014 system actually looks closer to subtitle-2
// in the 2018 system, and subeading-1 in the 2014 system looks more like body-1 in the 2018
// system.
subtitle-2: map.get($config, body-2),
body-1: map.get($config, subheading-1),
body-2: map.get($config, body-1),
button: map.get($config, button),
caption: map.get($config, caption),
overline: if(map.get($config, overline), map.get($config, overline),
m2-typography.define-typography-level(12px, 32px, 500)
)
);
}
@return $config;
}
| {
"end_byte": 3844,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/typography/_versioning.scss"
} |
components/src/material/core/typography/_typography-utils-deprecated.scss_0_172 | @use 'typography-utils';
// @deprecated Use `typography-level`.
@mixin level-to-styles($config, $level) {
@include typography-utils.typography-level($config, $level);
}
| {
"end_byte": 172,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/typography/_typography-utils-deprecated.scss"
} |
components/src/material/core/typography/_all-typography.scss_0_4458 | @use './typography';
@use '../m2/typography' as m2-typography;
@use '../../autocomplete/autocomplete-theme';
@use '../../badge/badge-theme';
@use '../../bottom-sheet/bottom-sheet-theme';
@use '../../button/button-theme';
@use '../../button/icon-button-theme';
@use '../../button/fab-theme';
@use '../../button-toggle/button-toggle-theme';
@use '../../card/card-theme';
@use '../../checkbox/checkbox-theme';
@use '../../chips/chips-theme';
@use '../../divider/divider-theme';
@use '../../table/table-theme';
@use '../../datepicker/datepicker-theme';
@use '../../dialog/dialog-theme';
@use '../../expansion/expansion-theme';
@use '../../grid-list/grid-list-theme';
@use '../../icon/icon-theme';
@use '../../input/input-theme';
@use '../../list/list-theme';
@use '../../menu/menu-theme';
@use '../../paginator/paginator-theme';
@use '../../progress-bar/progress-bar-theme';
@use '../../progress-spinner/progress-spinner-theme';
@use '../../radio/radio-theme';
@use '../../select/select-theme';
@use '../../sidenav/sidenav-theme';
@use '../../slide-toggle/slide-toggle-theme';
@use '../../slider/slider-theme';
@use '../../stepper/stepper-theme';
@use '../../sort/sort-theme';
@use '../../tabs/tabs-theme';
@use '../../toolbar/toolbar-theme';
@use '../../tooltip/tooltip-theme';
@use '../../snack-bar/snack-bar-theme';
@use '../../form-field/form-field-theme';
@use '../../timepicker/timepicker-theme';
@use '../../tree/tree-theme';
@use '../theming/inspection';
@use '../core-theme';
// Includes all of the typographic styles.
@mixin all-component-typographies($theme: null) {
// If no actual typography configuration has been specified, create a default one.
@if not inspection.theme-has($theme, typography) {
$theme: m2-typography.define-typography-config();
}
// TODO: COMP-309: Do not use individual mixins. Instead, use the all-theme mixin and only
// specify a `typography` config while setting `color` and `density` to `null`. This is currently
// not possible as it would introduce a circular dependency for typography because the `mat-core`
// mixin that is transitively loaded by the `all-theme` file, imports `all-typography` which
// would then load `all-theme` again. This ultimately results a circular dependency.
@include badge-theme.typography($theme);
// Historically the typography hierarchy styles were included as part of this. We maintain this
// behavior for M2, but from M3 forward this is not included and should be explicitly @included
// by the user if desired.
@if (inspection.get-theme-version($theme) < 1) {
@include typography.typography-hierarchy($theme);
}
@include bottom-sheet-theme.typography($theme);
@include button-toggle-theme.typography($theme);
@include divider-theme.typography($theme);
@include datepicker-theme.typography($theme);
@include expansion-theme.typography($theme);
@include grid-list-theme.typography($theme);
@include icon-theme.typography($theme);
@include progress-spinner-theme.typography($theme);
@include sidenav-theme.typography($theme);
@include stepper-theme.typography($theme);
@include sort-theme.typography($theme);
@include toolbar-theme.typography($theme);
@include tree-theme.typography($theme);
@include core-theme.typography($theme);
@include card-theme.typography($theme);
@include progress-bar-theme.typography($theme);
@include tooltip-theme.typography($theme);
@include form-field-theme.typography($theme);
@include input-theme.typography($theme);
@include select-theme.typography($theme);
@include autocomplete-theme.typography($theme);
@include dialog-theme.typography($theme);
@include chips-theme.typography($theme);
@include slide-toggle-theme.typography($theme);
@include radio-theme.typography($theme);
@include slider-theme.typography($theme);
@include menu-theme.typography($theme);
@include list-theme.typography($theme);
@include paginator-theme.typography($theme);
@include tabs-theme.typography($theme);
@include checkbox-theme.typography($theme);
@include button-theme.typography($theme);
@include icon-button-theme.typography($theme);
@include fab-theme.typography($theme);
@include snack-bar-theme.typography($theme);
@include table-theme.typography($theme);
@include timepicker-theme.typography($theme);
}
// @deprecated Use `all-component-typographies`.
@mixin angular-material-typography($theme: null) {
@include all-component-typographies($theme);
}
| {
"end_byte": 4458,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/typography/_all-typography.scss"
} |
components/src/material/core/selection/index.ts_0_313 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export * from './pseudo-checkbox/pseudo-checkbox';
export * from './pseudo-checkbox/pseudo-checkbox-module';
| {
"end_byte": 313,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/selection/index.ts"
} |
components/src/material/core/selection/pseudo-checkbox/_pseudo-checkbox-common.scss_0_3085 | @use 'sass:math';
@use '../../style/checkbox-common';
// Padding inside of a pseudo checkbox.
$padding: checkbox-common.$border-width * 2;
// Center a checkmark indicator inside the checkbox.
//
// `$box-size`: size of the checkbox
// `$mark-size`: size of the checkmark indicator
@mixin _checkbox-checked-styles-with-size($box-size, $mark-size) {
// Center a checkmark. `$checkbox-cmmon.$border-width` is the width of the line of the checkmark.
$width: $mark-size;
$height: math.div($mark-size - checkbox-common.$border-width, 2);
// The rendered length of the short-side of the checkmark graphic when rendered. Add length of
// the border-width since this element is content-box.
$short-side: $height + checkbox-common.$border-width;
width: $width;
height: $height;
// Rotate on the center of the element. This makes it easier to center the checkmark graphic.
transform-origin: center;
// Take negative one times the distance from the top corner of the checkmark graphic to the top
// of the element in its rotated position. This accounts for the top corner of the elemant being
// blank since we only use the left and bottom borders to draw the checkmark graphic.
top: -1 * math.div($short-side - checkbox-common.$border-width, math.sqrt(2));
left: 0;
bottom: 0;
right: 0;
// center the checkmark graphic with margin auto
margin: auto;
}
// Center a horizontal line placed in the vertical and horizontal center of the checkbox. It does
// not touch the border of the checkbox.
//
// `$box-size`: size of the checkbox.
// `$border-size`: size of the checkbox's border.
@mixin _checkbox-indeterminate-styles-with-size($box-size, $border-size) {
// Center the line in the checkbox. `$checkbox-common.$border-width` is the width of the line.
top: math.div($box-size - checkbox-common.$border-width, 2) - $border-size;
width: $box-size - checkbox-common.$border-width - (2 * $border-size);
}
/// Applies the styles that set the size of the pseudo checkbox
@mixin size($box-size) {
.mat-pseudo-checkbox {
width: $box-size;
height: $box-size;
}
.mat-pseudo-checkbox-minimal {
$mark-size: $box-size - $padding;
$border-size: 0; // Minimal appearance does not have a border.
&.mat-pseudo-checkbox-checked::after {
@include _checkbox-checked-styles-with-size($box-size, $mark-size);
}
&.mat-pseudo-checkbox-indeterminate::after {
@include _checkbox-indeterminate-styles-with-size($box-size, $border-size);
}
}
.mat-pseudo-checkbox-full {
$mark-size: $box-size - (2 * $padding); // Apply a smaller mark to account for the border.
$border-size: checkbox-common.$border-width;
&.mat-pseudo-checkbox-checked::after {
@include _checkbox-checked-styles-with-size($box-size, $mark-size);
}
&.mat-pseudo-checkbox-indeterminate::after {
@include _checkbox-indeterminate-styles-with-size($box-size, $border-size);
}
}
}
/// Applies the legacy size styles to the pseudo-checkbox
@mixin legacy-size() {
@include size(checkbox-common.$legacy-size);
}
| {
"end_byte": 3085,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/selection/pseudo-checkbox/_pseudo-checkbox-common.scss"
} |
components/src/material/core/selection/pseudo-checkbox/pseudo-checkbox.ts_0_2534 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {
Component,
ViewEncapsulation,
Input,
ChangeDetectionStrategy,
ANIMATION_MODULE_TYPE,
inject,
} from '@angular/core';
/**
* Possible states for a pseudo checkbox.
* @docs-private
*/
export type MatPseudoCheckboxState = 'unchecked' | 'checked' | 'indeterminate';
/**
* Component that shows a simplified checkbox without including any kind of "real" checkbox.
* Meant to be used when the checkbox is purely decorative and a large number of them will be
* included, such as for the options in a multi-select. Uses no SVGs or complex animations.
* Note that theming is meant to be handled by the parent element, e.g.
* `mat-primary .mat-pseudo-checkbox`.
*
* Note that this component will be completely invisible to screen-reader users. This is *not*
* interchangeable with `<mat-checkbox>` and should *not* be used if the user would directly
* interact with the checkbox. The pseudo-checkbox should only be used as an implementation detail
* of more complex components that appropriately handle selected / checked state.
* @docs-private
*/
@Component({
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'mat-pseudo-checkbox',
styleUrl: 'pseudo-checkbox.css',
template: '',
host: {
'class': 'mat-pseudo-checkbox',
'[class.mat-pseudo-checkbox-indeterminate]': 'state === "indeterminate"',
'[class.mat-pseudo-checkbox-checked]': 'state === "checked"',
'[class.mat-pseudo-checkbox-disabled]': 'disabled',
'[class.mat-pseudo-checkbox-minimal]': 'appearance === "minimal"',
'[class.mat-pseudo-checkbox-full]': 'appearance === "full"',
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
},
})
export class MatPseudoCheckbox {
_animationMode? = inject(ANIMATION_MODULE_TYPE, {optional: true});
/** Display state of the checkbox. */
@Input() state: MatPseudoCheckboxState = 'unchecked';
/** Whether the checkbox is disabled. */
@Input() disabled: boolean = false;
/**
* Appearance of the pseudo checkbox. Default appearance of 'full' renders a checkmark/mixedmark
* indicator inside a square box. 'minimal' appearance only renders the checkmark/mixedmark.
*/
@Input() appearance: 'minimal' | 'full' = 'full';
constructor(...args: unknown[]);
constructor() {}
}
| {
"end_byte": 2534,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/selection/pseudo-checkbox/pseudo-checkbox.ts"
} |
components/src/material/core/selection/pseudo-checkbox/_pseudo-checkbox-theme.scss_0_5240 | @use '../../theming/theming';
@use '../../theming/inspection';
@use '../../theming/validation';
@use '../../style/sass-utils';
@use '../../tokens/token-utils';
@use '../../tokens/m2/mat/full-pseudo-checkbox' as tokens-mat-full-pseudo-checkbox;
@use '../../tokens/m2/mat/minimal-pseudo-checkbox' as tokens-mat-minimal-pseudo-checkbox;
@mixin _palette-styles($theme, $palette-name) {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(
tokens-mat-full-pseudo-checkbox.$prefix,
tokens-mat-full-pseudo-checkbox.get-color-tokens($theme, $palette-name)
);
@include token-utils.create-token-values(
tokens-mat-minimal-pseudo-checkbox.$prefix,
tokens-mat-minimal-pseudo-checkbox.get-color-tokens($theme, $palette-name)
);
}
}
@mixin _theme-from-tokens($tokens, $options...) {
@include validation.selector-defined(
'Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector'
);
$mat-full-pseudo-checkbox-tokens: token-utils.get-tokens-for(
$tokens,
tokens-mat-full-pseudo-checkbox.$prefix,
$options...
);
$mat-minimal-pseudo-checkbox-tokens: token-utils.get-tokens-for(
$tokens,
tokens-mat-minimal-pseudo-checkbox.$prefix,
$options...
);
@include token-utils.create-token-values(
tokens-mat-full-pseudo-checkbox.$prefix,
$mat-full-pseudo-checkbox-tokens
);
@include token-utils.create-token-values(
tokens-mat-minimal-pseudo-checkbox.$prefix,
$mat-minimal-pseudo-checkbox-tokens
);
}
/// Outputs base theme styles (styles not dependent on the color, typography, or density settings)
/// for the mat-pseudo-checkbox.
/// @param {Map} $theme The theme to generate base styles for.
@mixin base($theme) {
}
/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
$full-pseudo-checkbox-tokens: tokens-mat-full-pseudo-checkbox.get-token-slots();
$minimal-pseudo-checkbox-tokens: tokens-mat-minimal-pseudo-checkbox.get-token-slots();
@return (
(
namespace: tokens-mat-full-pseudo-checkbox.$prefix,
tokens: $full-pseudo-checkbox-tokens,
prefix: 'full-',
),
(
namespace: tokens-mat-minimal-pseudo-checkbox.$prefix,
tokens: $minimal-pseudo-checkbox-tokens,
prefix: 'minimal-',
),
);
}
/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}
/// Outputs color theme styles for the mat-pseudo-checkbox.
/// @param {Map} $theme The theme to generate color styles for.
/// @param {ArgList} Additional optional arguments (only supported for M3 themes):
/// $color-variant: The color variant to use for the pseudo-checkbox: primary, secondary,
/// tertiary, or error (If not specified, default primary color will be used).
@mixin color($theme, $options...) {
@if inspection.get-theme-version($theme) == 1 {
@include _theme-from-tokens(inspection.get-theme-tokens($theme, color), $options...);
} @else {
// Default to the accent color. Note that the pseudo checkboxes are meant to inherit the
// theme from their parent, rather than implementing their own theming, which is why we
// don't attach to the `mat-*` classes. Also note that this needs to be below `.mat-primary`
// in order to allow for the color to be overwritten if the checkbox is inside a parent that
// has `mat-accent` and is placed inside another parent that has `mat-primary`.
@include _palette-styles($theme, accent);
.mat-primary {
@include _palette-styles($theme, primary);
}
.mat-accent {
@include _palette-styles($theme, accent);
}
.mat-warn {
@include _palette-styles($theme, warn);
}
}
}
/// Outputs typography theme styles for the mat-pseudo-checkbox.
/// @param {Map} $theme The theme to generate typography styles for.
@mixin typography($theme) {
}
/// Outputs density theme styles for the mat-pseudo-checkbox.
/// @param {Map} $theme The theme to generate density styles for.
@mixin density($theme) {
}
/// Outputs all (base, color, typography, and density) theme styles for the mat-pseudo-checkbox.
/// @param {Map} $theme The theme to generate styles for.
/// @param {ArgList} Additional optional arguments (only supported for M3 themes):
/// $color-variant: The color variant to use for the pseudo-checkbox: primary, secondary,
/// tertiary, or error (If not specified, default primary color will be used).
@mixin theme($theme, $options...) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-pseudo-checkbox') {
@if inspection.get-theme-version($theme) == 1 {
@include _theme-from-tokens(inspection.get-theme-tokens($theme), $options...);
} @else {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
@if inspection.theme-has($theme, density) {
@include density($theme);
}
@if inspection.theme-has($theme, typography) {
@include typography($theme);
}
}
}
}
| {
"end_byte": 5240,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/selection/pseudo-checkbox/_pseudo-checkbox-theme.scss"
} |
components/src/material/core/selection/pseudo-checkbox/pseudo-checkbox-module.ts_0_504 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {NgModule} from '@angular/core';
import {MatPseudoCheckbox} from './pseudo-checkbox';
import {MatCommonModule} from '../../common-behaviors/common-module';
@NgModule({
imports: [MatCommonModule, MatPseudoCheckbox],
exports: [MatPseudoCheckbox],
})
export class MatPseudoCheckboxModule {}
| {
"end_byte": 504,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/selection/pseudo-checkbox/pseudo-checkbox-module.ts"
} |
components/src/material/core/selection/pseudo-checkbox/pseudo-checkbox.scss_0_3212 | @use 'sass:math';
@use '../../style/checkbox-common';
@use '../../style/private';
@use '../../style/variables';
@use '../../tokens/token-utils';
@use '../../tokens/m2/mat/full-pseudo-checkbox' as tokens-mat-full-pseudo-checkbox;
@use '../../tokens/m2/mat/minimal-pseudo-checkbox' as tokens-mat-minimal-pseudo-checkbox;
@use './pseudo-checkbox-common';
.mat-pseudo-checkbox {
border-radius: 2px;
cursor: pointer;
display: inline-block;
vertical-align: middle;
box-sizing: border-box;
position: relative;
flex-shrink: 0;
transition: border-color checkbox-common.$transition-duration
variables.$linear-out-slow-in-timing-function, background-color
checkbox-common.$transition-duration variables.$linear-out-slow-in-timing-function;
// Used to render the checkmark/mixedmark inside of the box.
&::after {
position: absolute;
opacity: 0;
content: '';
border-bottom: checkbox-common.$border-width solid currentColor;
transition: opacity checkbox-common.$transition-duration
variables.$linear-out-slow-in-timing-function;
}
@include private.private-animation-noop {
&::after {
transition: none;
}
}
}
.mat-pseudo-checkbox-disabled {
cursor: default;
}
.mat-pseudo-checkbox-indeterminate::after {
left: math.div(checkbox-common.$border-width, 2);
opacity: 1;
border-radius: 2px;
}
.mat-pseudo-checkbox-checked::after {
left: pseudo-checkbox-common.$padding - checkbox-common.$border-width * 1.5;
border-left: checkbox-common.$border-width solid currentColor;
transform: rotate(-45deg);
opacity: 1;
box-sizing: content-box;
}
.mat-pseudo-checkbox-minimal {
@include token-utils.use-tokens(tokens-mat-minimal-pseudo-checkbox.$prefix,
tokens-mat-minimal-pseudo-checkbox.get-token-slots()) {
&.mat-pseudo-checkbox-checked, &.mat-pseudo-checkbox-indeterminate {
&::after {
@include token-utils.create-token-slot(color, selected-checkmark-color);
}
&.mat-pseudo-checkbox-disabled::after {
@include token-utils.create-token-slot(color, disabled-selected-checkmark-color);
}
}
}
}
.mat-pseudo-checkbox-full {
@include token-utils.use-tokens(tokens-mat-full-pseudo-checkbox.$prefix,
tokens-mat-full-pseudo-checkbox.get-token-slots()) {
@include token-utils.create-token-slot(border-color, unselected-icon-color);
border-width: checkbox-common.$border-width;
border-style: solid;
&.mat-pseudo-checkbox-disabled {
@include token-utils.create-token-slot(border-color, disabled-unselected-icon-color);
}
&.mat-pseudo-checkbox-checked, &.mat-pseudo-checkbox-indeterminate {
@include token-utils.create-token-slot(background-color, selected-icon-color);
border-color: transparent;
&::after {
@include token-utils.create-token-slot(color, selected-checkmark-color);
}
&.mat-pseudo-checkbox-disabled {
@include token-utils.create-token-slot(background-color, disabled-selected-icon-color);
&::after {
@include token-utils.create-token-slot(color, disabled-selected-checkmark-color);
}
}
}
}
}
@include pseudo-checkbox-common.size(checkbox-common.$size);
| {
"end_byte": 3212,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/selection/pseudo-checkbox/pseudo-checkbox.scss"
} |
components/src/material/core/error/error-options.ts_0_1048 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Injectable} from '@angular/core';
import {FormGroupDirective, NgForm, AbstractControl} from '@angular/forms';
/** Error state matcher that matches when a control is invalid and dirty. */
@Injectable()
export class ShowOnDirtyErrorStateMatcher implements ErrorStateMatcher {
isErrorState(control: AbstractControl | null, form: FormGroupDirective | NgForm | null): boolean {
return !!(control && control.invalid && (control.dirty || (form && form.submitted)));
}
}
/** Provider that defines how form controls behave with regards to displaying error messages. */
@Injectable({providedIn: 'root'})
export class ErrorStateMatcher {
isErrorState(control: AbstractControl | null, form: FormGroupDirective | NgForm | null): boolean {
return !!(control && control.invalid && (control.touched || (form && form.submitted)));
}
}
| {
"end_byte": 1048,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/error/error-options.ts"
} |
components/src/material/core/tokens/_token-utils.scss_0_7663 | @use '../style/elevation';
@use '../style/sass-utils';
@use './m3-system';
@use 'sass:list';
@use 'sass:map';
@use 'sass:string';
$_tokens: null;
$_component-prefix: null;
$_system-fallbacks: m3-system.create-system-fallbacks();
// Sets the token prefix and map to use when creating token slots.
@mixin use-tokens($prefix, $tokens) {
$_component-prefix: $prefix !global;
$_tokens: $tokens !global;
@content;
$_component-prefix: null !global;
$_tokens: null !global;
}
// Combines a prefix and a string to generate a CSS variable name for a token.
@function _create-var-name($prefix, $token) {
@if $prefix == null or $token == null {
@error 'Must specify both prefix and name when generating token';
}
$string-prefix: '';
// Prefixes are lists so we need to combine them.
@each $part in $prefix {
$string-prefix: if($string-prefix == '', $part, '#{$string-prefix}-#{$part}');
}
@return string.unquote('--#{$string-prefix}-#{$token}');
}
// Creates a CSS variable, including the fallback if provided.
@function _create-var($name, $fallback: null) {
@if ($fallback) {
@return var($name, $fallback);
} @else {
@return var($name);
}
}
// Gets the value of the token given the current global context state.
@function _get-token-value($token, $fallback) {
$var-name: _create-var-name($_component-prefix, $token);
$fallback: _get-token-fallback($token, $fallback);
@return _create-var($var-name, $fallback);
}
// Assertion mixin that throws an error if the global state has not been set up by wrapping
// calls with `use-tokens`.
@function _assert-use-tokens($token) {
@if $_component-prefix == null or $_tokens == null {
@error 'Function was not called within a wrapping call of `use-tokens`';
}
@if not map.has-key($_tokens, $token) {
@error 'Token #{$token} does not exist. Configured tokens are: #{map.keys($_tokens)}';
}
@return true;
}
// Emits a slot for the given token, provided that it has a non-null value in the token map passed
// to `use-tokens`.
// Accepts an optional fallback parameter to include in the CSS variable.
// If $fallback is `true`, then use the tokens map to get the fallback.
// TODO: Remove the use case where we accept "true" and handle any failing client screenshots
@mixin create-token-slot($property, $token, $fallback: null) {
$_assert: _assert-use-tokens($token);
@if map.get($_tokens, $token) != null {
#{$property}: #{_get-token-value($token, $fallback)};
}
}
// Returns the name of a token including the current prefix. Intended to be used in calculations
// involving tokens. `create-token-slot` should be used when outputting tokens.
@function get-token-variable-name($token) {
$_assert: _assert-use-tokens($token);
@return _create-var-name($_component-prefix, $token);
}
// Returns a `var()` reference to a specific token. Intended for declarations
// where the token has to be referenced as a part of a larger expression.
// Accepts an optional fallback parameter to include in the CSS variable.
// If $fallback is `true`, then use the tokens map to get the fallback.
// TODO: Remove the use case where we accept "true" and handle any failing client screenshots
@function get-token-variable($token, $fallback: null) {
$_assert: _assert-use-tokens($token);
@return _get-token-value($token, $fallback);
}
// Gets the token's fallback value. Prefers adding a system-level fallback if one exists, otherwise
// use the provided fallback.
@function _get-token-fallback($token, $fallback: null) {
// If the $fallback is `true`, this is the component's signal to use the current token map value
@if ($fallback == true) {
$fallback: map.get($_tokens, $token);
}
// Check whether there's a system-level fallback. If not, return the optional
// provided fallback (otherwise null).
$sys-fallback: map.get($_system-fallbacks, $_component-prefix, $token);
@if (not $sys-fallback) {
@return $fallback;
}
@if (sass-utils.is-css-var-name($sys-fallback)) {
@return _create-var($sys-fallback, $fallback);
}
@return $sys-fallback;
}
// Outputs a map of tokens under a specific prefix.
@mixin create-token-values($prefix, $tokens) {
@if $tokens != null {
// TODO: The `&` adds to the file size of theme, but it's necessary for compatibility
// with https://sass-lang.com/documentation/breaking-changes/mixed-decls/. We should
// figure out a better way to do this or move all the concrete styles out of the theme.
& {
@each $key, $value in $tokens {
@if $value != null {
#{_create-var-name($prefix, $key)}: #{$value};
}
}
}
}
}
// MDC doesn't currently handle elevation tokens properly. As a temporary workaround we can combine
// the elevation and shadow-color tokens into a full box-shadow and use it as the value for the
// elevation token.
@function resolve-elevation($tokens, $elevation-token, $shadow-color-token) {
$elevation: map.get($tokens, $elevation-token);
$shadow-color: map.get($tokens, $shadow-color-token);
@return map.merge(
$tokens,
(
$elevation-token: elevation.get-box-shadow($elevation, $shadow-color),
$shadow-color-token: null,
)
);
}
/// Checks whether a list starts wih a given prefix
/// @param {List} $list The list value to check the prefix of.
/// @param {List} $prefix The prefix to check.
/// @return {Boolean} Whether the list starts with the prefix.
@function _is-prefix($list, $prefix) {
@for $i from 1 through list.length($prefix) {
@if list.nth($list, $i) != list.nth($prefix, $i) {
@return false;
}
}
@return true;
}
/// Gets the supported color variants in the given token set for the given prefix.
/// @param {Map} $tokens The full token map.
/// @param {List} $prefix The component prefix to get color variants for.
/// @return {List} The supported color variants.
@function _supported-color-variants($tokens, $prefix) {
$result: ();
@each $namespace in map.keys($tokens) {
@if list.length($prefix) == list.length($namespace) - 1 and _is-prefix($namespace, $prefix) {
$result: list.append($result, list.nth($namespace, list.length($namespace)), comma);
}
}
@return $result;
}
/// Gets the token values for the given components prefix with the given options.
/// @param {Map} $tokens The full token map.
/// @param {List} $prefix The component prefix to get the token values for.
/// @param {ArgList} Any additional options
/// Currently the additional supported options are:
// - $color-variant - The color variant to use for the component
// - $emit-overrides-only - Whether to emit *only* the overrides for the
// specific color variant, or all color styles. Defaults to false.
/// @throws If given options are invalid
/// @return {Map} The token values for the requested component.
@function get-tokens-for($tokens, $prefix, $options...) {
$options: sass-utils.validate-keyword-args($options, (color-variant, emit-overrides-only));
@if $tokens == () {
@return ();
}
$values: map.get($tokens, $prefix);
$color-variant: map.get($options, color-variant);
$emit-overrides-only: map.get($options, emit-overrides-only);
@if $color-variant == null {
@return $values;
}
$overrides: map.get($tokens, list.append($prefix, $color-variant));
@if $overrides == null {
$variants: _supported-color-variants($tokens, $prefix);
$secondary-message: if(
$variants == (),
'Mixin does not support color variants',
'Supported color variants are: #{$variants}'
);
@error 'Invalid color variant: #{$color-variant}. #{$secondary-message}.';
} | {
"end_byte": 7663,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/_token-utils.scss"
} |
components/src/material/core/tokens/_token-utils.scss_7666_10844 | @return if($emit-overrides-only, $overrides, map.merge($values, $overrides));
}
/// Emits new token values for the given token overrides.
/// Verifies that the overrides passed in are valid tokens.
/// New token values are emitted under the current selector or root.
@mixin batch-create-token-values($overrides: (), $namespace-configs...) {
@include sass-utils.current-selector-or-root() {
$prefixed-name-data: ();
$unprefixed-name-data: ();
$all-names: ();
@each $config in $namespace-configs {
$namespace: map.get($config, namespace);
$prefix: if(map.has-key($config, prefix), map.get($config, prefix), '');
$tokens: _filter-nulls(map.get($config, tokens));
@each $name, $value in $tokens {
$prefixed-name: $prefix + $name;
$all-names: list.append($all-names, $prefixed-name, $separator: comma);
@if map.has-key($prefixed-name-data, $prefixed-name) {
@error #{
'Error overriding token: Ambiguous token name `'
}#{
$prefixed-name
}#{
'` exists in multiple namespaces: `('
}#{
list.nth(map.get($prefixed-name-data, $prefixed-name), 1)
}#{
')` and `('
}#{
$namespace
}#{
')`'
};
}
$prefixed-name-data: map.set($prefixed-name-data, $prefixed-name, ($namespace, $name));
$unprefixed-data: map.has-key($unprefixed-name-data, $name) and
map.get($unprefixed-name-data, $name) or
();
$unprefixed-data: list.append($unprefixed-data, ($namespace, $prefixed-name));
$unprefixed-name-data: map.set($unprefixed-name-data, $name, $unprefixed-data);
}
}
@each $name, $value in $overrides {
@if map.has-key($prefixed-name-data, $name) {
$data: map.get($prefixed-name-data, $name);
$namespace: list.nth($data, 1);
$name: list.nth($data, 2);
@include create-token-values(
$namespace,
(
$name: $value,
)
);
} @else if (map.has-key($unprefixed-name-data, $name)) {
$datalist: map.get($unprefixed-name-data, $name);
$prefixed-names: ();
@each $data in $datalist {
$namespace: list.nth($data, 1);
$prefixed-names: list.append($prefixed-names, list.nth($data, 2), $separator: comma);
@include create-token-values(
$namespace,
(
$name: $value,
)
);
}
@warn #{
'Token `'
}#{
$name
}#{
'` is deprecated. Please use one of the following alternatives: '
}#{
$prefixed-names
};
} @else {
@error #{'Invalid token name `'}#{$name}#{'`. '}#{'Valid tokens are: '}#{$all-names};
}
}
}
}
/// Filters keys with a null value out of the map.
/// @param {Map} $map The map to filter.
/// @return {Map} The given map with all of the null keys filtered out.
@function _filter-nulls($map) {
$result: ();
@each $key, $val in $map {
@if $val != null {
$result: map.set($result, $key, $val);
}
}
@return $result;
} | {
"end_byte": 10844,
"start_byte": 7666,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/_token-utils.scss"
} |
components/src/material/core/tokens/_m3-tokens.scss_0_6957 | @use 'sass:map';
@use '../style/sass-utils';
@use '../m2' as m2-theming;
@use './m3';
@use './m3/definitions' as m3-token-definitions;
@use '../tokens/m2' as m2-tokens;
@use './density';
@use './format-tokens';
/// Generates tokens for the given palette with the given prefix.
/// @param {Map} $palette The palette to generate tokens for
/// @param {String} $prefix The key prefix used to name the tokens
/// @return {Map} A set of tokens for the given palette
@function _generate-palette-tokens($palette, $prefix) {
$palette: map.remove($palette, neutral, neutral-variant);
$result: ();
@each $hue, $value in $palette {
$result: map.set($result, '#{$prefix}#{$hue}', $value);
}
@return $result;
}
/// Creates a set of `md-ref-palette` tokens from the given palettes. (See
/// ./m3/definitions/_md-ref-palette.scss)
/// @param {Map} $primary The primary palette
/// @param {Map} $secondary The secondary palette
/// @param {Map} $tertiary The tertiary palette
/// @param {Map} $error The error palette
/// @return {Map} A set of `md-ref-palette` tokens
@function generate-ref-palette-tokens($primary, $tertiary, $error) {
@return sass-utils.merge-all(
(black: #000, white: #fff),
_generate-palette-tokens($primary, primary),
_generate-palette-tokens(map.get($primary, secondary), secondary),
_generate-palette-tokens($tertiary, tertiary),
_generate-palette-tokens(map.get($primary, neutral), neutral),
_generate-palette-tokens(map.get($primary, neutral-variant), neutral-variant),
_generate-palette-tokens($error, error),
);
}
/// Creates a set of `md-ref-typeface` tokens from the given palettes. (See
/// ./m3/definitions/_md-ref-typeface.scss)
/// @param {List|String} $brand The font-family to use for brand text
/// @param {List|String} $plain The font-family to use for plain text
/// @param {String} $bold The font-weight to use for bold text
/// @param {String} $medium The font-weight to use for medium text
/// @param {String} $regular The font-weight to use for regular text
/// @return {Map} A set of `md-ref-typeface` tokens
@function generate-ref-typeface-tokens($brand, $plain, $bold, $medium, $regular) {
@return (
brand: $brand,
plain: $plain,
weight-bold: $bold,
weight-medium: $medium,
weight-regular: $regular,
);
}
$_cached-token-slots: null;
/// Determines the token slots for all components.
@function _get-token-slots() {
// Cache the slots since they're constant and calculating
// them appears to be expensive (see #29009).
@if ($_cached-token-slots) {
@return $_cached-token-slots;
}
// TODO(mmalerba): Refactor this to not depend on the legacy theme when moving out of
// material-experimental. This is a hack for now because there is no good way to get the token
// slots in material-experimental without exposing them all from material.
$fake-theme: m2-theming.define-light-theme((
color: (
primary: m2-theming.define-palette(m2-theming.$red-palette),
accent: m2-theming.define-palette(m2-theming.$red-palette),
warn: m2-theming.define-palette(m2-theming.$red-palette),
),
typography: m2-theming.define-typography-config(),
density: 0
));
$_cached-token-slots: m2-tokens.m2-tokens-from-theme($fake-theme) !global;
@return $_cached-token-slots;
}
/// Generates a set of namespaced tokens for all components.
/// @param {Map} $systems The MDC system tokens
/// @param {Boolean} $include-non-systemized Whether to include non-systemized tokens
/// @param {Boolean} $include-density Whether to include density tokens
/// @return {Map} A map of namespaced tokens
@function generate-tokens($systems, $include-non-systemized: false, $include-density: false) {
$systems: map.merge((
md-sys-color: (),
md-sys-elevation: (),
md-sys-motion: (),
md-sys-shape: (),
md-sys-state: (),
md-sys-typescale: ()
), $systems);
$exclude-hardcoded: not $include-non-systemized;
// DO NOT REMOVE
// This function is used internally.
$systems: format-tokens.private-format-tokens($systems);
$token-slots: _get-token-slots();
// TODO(mmalerba): Fill in remaining tokens.
$result: sass-utils.deep-merge-all(
// Add the system color & typography tokens (so we can give users access via an API).
(
(mdc, theme): map.get($systems, md-sys-color),
(mdc, typography): map.get($systems, md-sys-typescale),
),
m3.get-m3-tokens($systems, $exclude-hardcoded, $token-slots),
);
// Strip out tokens that are systemized by our made up density system.
@each $namespace, $tokens in $result {
@each $token, $value in $tokens {
@if density.is-systemized($namespace, $token) and not $include-density {
$tokens: map.remove($tokens, $token);
}
}
$result: map.set($result, $namespace, $tokens);
}
@return $result;
}
@function create-map($keys, $prefix) {
$result: ();
@each $key in $keys {
$result: map-merge($result, ($key: var(--#{$prefix}-#{$key})));
}
@return $result;
}
@function _get-sys-color($type, $ref, $prefix) {
$mdc-sys-color: if($type == dark,
m3-token-definitions.md-sys-color-values-dark($ref),
m3-token-definitions.md-sys-color-values-light($ref));
@if (sass-utils.$use-system-color-variables) {
$keys: (
'background',
'error',
'error-container',
'inverse-on-surface',
'inverse-primary',
'inverse-surface',
'on-background',
'on-error',
'on-error-container',
'on-primary',
'on-primary-container',
'on-primary-fixed',
'on-primary-fixed-variant',
'on-secondary',
'on-secondary-container',
'on-secondary-fixed',
'on-secondary-fixed-variant',
'on-surface',
'on-surface-variant',
'on-tertiary',
'on-tertiary-container',
'on-tertiary-fixed',
'on-tertiary-fixed-variant',
'outline',
'outline-variant',
'primary',
'primary-container',
'primary-fixed',
'primary-fixed-dim',
'scrim',
'secondary',
'secondary-container',
'secondary-fixed',
'secondary-fixed-dim',
'surface',
'surface-bright',
'surface-container',
'surface-container-high',
'surface-container-highest',
'surface-container-low',
'surface-container-lowest',
'surface-dim',
'surface-tint',
'surface-variant',
'tertiary',
'tertiary-container',
'tertiary-fixed',
'tertiary-fixed-dim'
);
@return map-merge(create-map($keys, $prefix), (
shadow: map.get($mdc-sys-color, shadow)
));
}
@return $mdc-sys-color;
} | {
"end_byte": 6957,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/_m3-tokens.scss"
} |
components/src/material/core/tokens/_m3-tokens.scss_6959_13281 | @function _get-sys-typeface($ref, $prefix) {
@if (sass-utils.$use-system-typography-variables) {
$keys: (
'body-large',
'body-large-font',
'body-large-line-height',
'body-large-size',
'body-large-tracking',
'body-large-weight',
'body-medium',
'body-medium-font',
'body-medium-line-height',
'body-medium-size',
'body-medium-tracking',
'body-medium-weight',
'body-small',
'body-small-font',
'body-small-line-height',
'body-small-size',
'body-small-tracking',
'body-small-weight',
'display-large',
'display-large-font',
'display-large-line-height',
'display-large-size',
'display-large-tracking',
'display-large-weight',
'display-medium',
'display-medium-font',
'display-medium-line-height',
'display-medium-size',
'display-medium-tracking',
'display-medium-weight',
'display-small',
'display-small-font',
'display-small-line-height',
'display-small-size',
'display-small-tracking',
'display-small-weight',
'headline-large',
'headline-large-font',
'headline-large-line-height',
'headline-large-size',
'headline-large-tracking',
'headline-large-weight',
'headline-medium',
'headline-medium-font',
'headline-medium-line-height',
'headline-medium-size',
'headline-medium-tracking',
'headline-medium-weight',
'headline-small',
'headline-small-font',
'headline-small-line-height',
'headline-small-size',
'headline-small-tracking',
'headline-small-weight',
'label-large',
'label-large-font',
'label-large-line-height',
'label-large-size',
'label-large-tracking',
'label-large-weight',
'label-large-weight-prominent',
'label-medium',
'label-medium-font',
'label-medium-line-height',
'label-medium-size',
'label-medium-tracking',
'label-medium-weight',
'label-medium-weight-prominent',
'label-small',
'label-small-font',
'label-small-line-height',
'label-small-size',
'label-small-tracking',
'label-small-weight',
'title-large',
'title-large-font',
'title-large-line-height',
'title-large-size',
'title-large-tracking',
'title-large-weight',
'title-medium',
'title-medium-font',
'title-medium-line-height',
'title-medium-size',
'title-medium-tracking',
'title-medium-weight',
'title-small',
'title-small-font',
'title-small-line-height',
'title-small-size',
'title-small-tracking',
'title-small-weight'
);
@return create-map($keys, $prefix);
}
@return m3-token-definitions.md-sys-typescale-values($ref);
}
/// Generates a set of namespaced color tokens for all components.
/// @param {String} $type The type of theme system (light or dark)
/// @param {Map} $primary The primary palette
/// @param {Map} $tertiary The tertiary palette
/// @param {Map} $error The error palette
/// @param {String} $system-variables-prefix The prefix of system tokens
/// @return {Map} A map of namespaced color tokens
@function generate-color-tokens($type, $primary, $tertiary, $error, $system-variables-prefix) {
$ref: (
md-ref-palette: generate-ref-palette-tokens($primary, $tertiary, $error)
);
$sys-color: _get-sys-color($type, $ref, $system-variables-prefix);
@return generate-tokens(map.merge($ref, (
md-sys-color: $sys-color,
// Because the elevation values are always combined with color values to create the box shadow,
// elevation needs to be part of the color dimension.
md-sys-elevation: m3-token-definitions.md-sys-elevation-values(),
// Because the state values are sometimes combined with color values to create rgba colors,
// state needs to be part of color dimension.
// TODO(mmalerba): If at some point we remove the need for these combined values, we can move
// state to the base dimension.
md-sys-state: m3-token-definitions.md-sys-state-values(),
)));
}
/// Generates a set of namespaced color tokens for all components.
/// @param {String|List} $brand The brand font-family
/// @param {String|List} $plain The plain fort-family
/// @param {String|Number} $bold The bold font-weight
/// @param {String|Number} $medium The medium font-weight
/// @param {String|Number} $regular The regular font-weight
/// @param {String} $system-variables-prefix The prefix of system tokens
/// @return {Map} A map of namespaced typography tokens
@function generate-typography-tokens($brand, $plain, $bold, $medium, $regular,
$system-variables-prefix) {
$ref: (
md-ref-typeface: generate-ref-typeface-tokens($brand, $plain, $bold, $medium, $regular)
);
$sys-typeface: _get-sys-typeface($ref, $system-variables-prefix);
@return generate-tokens((
md-sys-typescale: $sys-typeface
));
}
/// Generates a set of namespaced density tokens for all components.
/// @param {String|Number} $scale The regular font-weight
/// @return {Map} A map of namespaced density tokens
@function generate-density-tokens($scale) {
@return density.get-tokens-for-scale($scale);
}
/// Generates a set of namespaced tokens not related to color, typography, or density for all
/// components.
/// @return {Map} A map of namespaced tokens not related to color, typography, or density
@function generate-base-tokens() {
// TODO(mmalerba): Exclude density tokens once implemented.
@return generate-tokens((
md-sys-motion: m3-token-definitions.md-sys-motion-values(),
md-sys-shape: m3-token-definitions.md-sys-shape-values(),
), $include-non-systemized: true);
} | {
"end_byte": 13281,
"start_byte": 6959,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/_m3-tokens.scss"
} |
components/src/material/core/tokens/_format-tokens.scss_0_120 | // DO NOT REMOVE
// This function is used internally.
@function private-format-tokens($systems) {
@return $systems;
}
| {
"end_byte": 120,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/_format-tokens.scss"
} |
components/src/material/core/tokens/_density.scss_0_6183 | @use 'sass:list';
@use 'sass:map';
@use '../theming/theming';
/// Maps namespaced tokens to per-density-scale values.
/// This is used as a temporary solution for density, since Material Design currently does not have
/// systemized density.
/// Format:
/// (
/// (mdc, comp): (
/// token: (<scale 0 value>, <scale -1 value>, <scale -2 value>, ...),
/// ...
/// ),
/// ...
/// )
// TODO(mmalerba): Add density tokens for remaining components.
$_density-tokens: (
// MDC tokens
(mdc, checkbox): (
state-layer-size: (40px, 36px, 32px, 28px),
),
(mdc, chip): (
container-height: (32px, 28px, 24px),
),
(mdc, circular-progress): (),
(mdc, dialog): (),
(mdc, elevated-card): (),
(mdc, extended-fab): (),
(mdc, fab): (),
(mdc, fab-small): (),
(mdc, filled-text-field): (),
(mdc, text-button): (
container-height: (40px, 36px, 32px, 28px),
),
(mdc, protected-button): (
container-height: (40px, 36px, 32px, 28px),
),
(mdc, filled-button): (
container-height: (40px, 36px, 32px, 28px),
),
(mdc, outlined-button): (
container-height: (40px, 36px, 32px, 28px),
),
(mdc, icon-button): (
// The size caps out at 24px, because anything lower will be smaller than the icon.
state-layer-size: (40px, 36px, 32px, 28px, 24px, 24px),
),
(mdc, linear-progress): (),
(mdc, list): (
list-item-one-line-container-height: (48px, 44px, 40px, 36px, 32px, 24px),
list-item-two-line-container-height: (64px, 60px, 56px, 52px, 48px, 48px),
list-item-three-line-container-height: (88px, 84px, 80px, 76px, 72px, 56px),
),
(mdc, outlined-card): (),
(mdc, outlined-text-field): (),
(mdc, plain-tooltip): (),
(mdc, radio): (
state-layer-size: (40px, 36px, 32px, 28px),
),
(mdc, slider): (),
(mdc, snackbar): (),
(mdc, switch): (),
(mdc, secondary-navigation-tab): (
container-height: (48px, 44px, 40px, 36px, 32px)
),
(mdc, tab-indicator): (),
// Custom Angular Material tokens
(mat, autocomplete): (),
(mat, badge): (),
(mat, bottom-sheet): (),
(mat, card): (),
(mat, checkbox): (
touch-target-display: (block, block, none, none),
),
(mat, dialog): (),
(mat, datepicker): (),
(mat, divider): (),
(mat, expansion): (
header-collapsed-state-height: (48px, 44px, 40px, 36px),
header-expanded-state-height: (64px, 60px, 56px, 48px),
),
(mat, fab): (
touch-target-display: (block, block, none, none),
),
(mat, form-field): (
container-height: (56px, 52px, 48px, 44px, 40px, 36px),
filled-label-display: (block, block, none, none, none, none),
container-vertical-padding: (16px, 14px, 12px, 10px, 8px, 6px),
filled-with-label-container-padding-top: (24px, 22px, 12px, 10px, 8px, 6px),
filled-with-label-container-padding-bottom: (8px, 6px, 12px, 10px, 8px, 6px),
),
(mat, grid-list): (),
(mat, icon): (),
(mat, icon-button): (
touch-target-display: (block, block, none, none),
),
(mat, list): (
list-item-leading-icon-start-space: (16px, 12px, 8px, 4px),
list-item-leading-icon-end-space: (16px, 12px, 8px, 4px),
),
(mat, text-button): (
touch-target-display: (block, block, none, none),
),
(mat, protected-button): (
touch-target-display: (block, block, none, none),
),
(mat, filled-button): (
touch-target-display: (block, block, none, none),
),
(mat, outlined-button): (
touch-target-display: (block, block, none, none),
),
(mat, menu): (),
(mat, optgroup): (),
(mat, option): (),
(mat, full-pseudo-checkbox): (),
(mat, minimal-pseudo-checkbox): (),
(mat, paginator): (
container-size: (56px, 52px, 48px, 40px),
form-field-container-height: (40px, 40px, 40px, 40px, 40px, 36px),
form-field-container-vertical-padding: (8px, 8px, 8px, 8px, 8px, 6px),
touch-target-display: (block, block, none, none),
),
(mat, radio): (
touch-target-display: (block, block, none, none),
),
(mat, ripple): (),
(mat, select): (
arrow-transform: (
translateY(-8px),
translateY(-8px),
none,
),
),
(mat, sidenav): (),
(mat, slide-toggle): (),
(mat, slider): (),
(mat, snack-bar): (),
(mat, sort): (),
(mat, timepicker): (),
(mat, standard-button-toggle): (
height: (40px, 40px, 40px, 36px, 24px),
),
(mat, stepper): (
header-height: (72px, 68px, 64px, 60px, 42px),
),
(mat, tab-header): (),
(mat, table): (
header-container-height: (56px, 52px, 48px, 44px, 40px),
footer-container-height: (52px, 48px, 44px, 40px, 36px),
row-item-container-height: (52px, 48px, 44px, 40px, 36px),
),
(mat, toolbar): (
standard-height: (64px, 60px, 56px, 52px),
mobile-height: (56px, 52px, 48px, 44px),
),
(mat, tree): (
node-min-height: (48px, 44px, 40px, 36px, 28px),
),
);
/// Gets the value for the given density scale from the given set of density values.
/// @param {List} $density-values The list of values for each density scale.
/// @param {Number} $scale The density scale to get the value for.
/// @return {*} The value for the given scale.
@function _get-value-for-scale($density-values, $scale) {
$scale: theming.clamp-density($scale, -1 * list.length($density-values) + 1);
$index: -$scale + 1;
@return list.nth($density-values, $index);
}
/// Gets a map of all density tokens for the given scale
/// @param {Number} $scale The density scale
/// @return {Map} Map of all fully qualified density tokens for the given scale.
@function get-tokens-for-scale($scale) {
$result: ();
@each $namespace, $tokens in $_density-tokens {
@each $token, $density-values in $tokens {
$tokens: map.set($tokens, $token, _get-value-for-scale($density-values, $scale));
}
$result: map.set($result, $namespace, $tokens);
}
@return $result;
}
/// Checks whether the given token is systemized by Angular Material's made up density system.
/// @param {List} $namespace The namespace of the token
/// @param {String} $token The name of the token
/// @return {Boolean} Whether the token is systemized by the density system
@function is-systemized($namespace, $token) {
@return map.get($_density-tokens, $namespace, $token) != null;
}
| {
"end_byte": 6183,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/_density.scss"
} |
components/src/material/core/tokens/_m3-system.scss_0_7079 | @use '../style/elevation';
@use '../style/sass-utils';
@use '../theming/config-validation';
@use '../theming/definition';
@use './m3/definitions';
@use 'sass:map';
@use 'sass:meta';
@use 'sass:list';
@use './m3-tokens';
/// Emits necessary CSS variables for Material's system level values for the values defined in the
/// config map. The config map can have values color, typography, and/or density.
///
/// If the config map's color value is an Angular Material color palette, it will be used as the
/// primary and tertiary colors with a `color-scheme` theme type. Otherwise if the color value is a
/// map, it must have a `primary` value containing an Angular Material color palette, and
/// optionally a different `tertiary` palette (defaults to primary palette) and `theme-type` that
/// is either `light`, `dark`, or 'color-scheme` (defaults to `color-scheme`). Color variable
/// definitions will not be emitted if there are no color values in the config.
///
/// If the config map's typography value is a font family string, it will be used as the
/// plain and brand font family with default bold, medium, and regular weights of 700, 500, and 400,
/// respectfully. Otherwise if the typography value is a map, it must have a `plain-family` font
/// family value, and optionally a different `brand-family` font family (defaults to the plain
/// value) and weights for `bold-weight` (default: 700), `bold-weight` (default: 500), and
/// `bold-weight` (default: 400). Typography variable definitions will not be emitted if there are
/// no typography values in the config.
///
/// If the config map's density value is a number, it will be used as the density scale. Otherwise
/// if the density value is a map, it must have a `scale` value. Density variable definitions will
/// not be emitted if there are no density values in the config.
///
/// The application variables emitted use the namespace prefix "--mat-sys".
/// e.g. --mat-sys-surface: #E5E5E5
///
/// @param {Map} $config The color configuration with optional keys color, typography, or density.
@mixin theme($config, $overrides: ()) {
$color: map.get($config, color);
$color-config: null;
@if ($color) {
// validate-palette returns null if it is a valid M3 palette
$is-palette: config-validation.validate-palette($color) == null;
// Default to "color-scheme" theme type if the config's color does not provide one.
@if (not $is-palette and not map.has-key($color, theme-type)) {
$color: map.set($color, theme-type, color-scheme);
}
$color-config: if($is-palette,
definition.define-colors((primary: $color, theme-type: color-scheme)),
definition.define-colors($color));
@include system-level-colors($color-config, $overrides, definition.$system-fallback-prefix);
@include system-level-elevation($color-config, $overrides, definition.$system-fallback-prefix);
}
$typography: map.get($config, typography);
$typography-config: null;
@if ($typography) {
$typography-config: if(meta.type-of($typography) == 'map',
definition.define-typography($typography),
definition.define-typography((plain-family: $typography)));
@include system-level-typography(
$typography-config, $overrides, definition.$system-fallback-prefix);
}
$density: map.get($config, density);
$density-config: null;
@if ($density) {
$density-config: if(meta.type-of($density) == 'map',
definition.define-density($density),
definition.define-density((scale: $density)));
$scale: map.get($density-config, _mat-theming-internals-do-not-access, density-scale);
@if ($scale != 0) {
$all-tokens: m3-tokens.generate-density-tokens($scale);
@each $component-tokens in $all-tokens {
$namespace: list.nth($component-tokens, 1);
@each $tokens in list.nth($component-tokens, 2) {
--#{list.nth($namespace, 1)}-#{list.nth($namespace, 2)}-#{
list.nth($tokens, 1)}: #{list.nth($tokens, 2)};
}
}
}
}
@include system-level-shape($overrides: $overrides, $prefix: definition.$system-fallback-prefix);
@include system-level-motion($overrides:$overrides, $prefix: definition.$system-fallback-prefix);
@include system-level-state($overrides: $overrides, $prefix: definition.$system-fallback-prefix);
}
/// Emits the system-level CSS variables for each of the provided override values. E.g. to
/// change the primary color to red, use `mat.theme-overrides((primary: red));`
@mixin theme-overrides($overrides, $prefix: definition.$system-fallback-prefix) {
$sys-names: map-merge-all(
definitions.md-sys-color-values-light(),
definitions.md-sys-typescale-values(),
definitions.md-sys-elevation-values(),
definitions.md-sys-shape-values(),
definitions.md-sys-state-values());
& {
@each $name, $value in $overrides {
@if (map.has-key($sys-names, $name)) {
--#{$prefix}-#{$name}: #{map.get($overrides, $name)};
}
}
}
}
@mixin system-level-colors($theme, $overrides: (), $prefix: null) {
$palettes: map.get($theme, _mat-theming-internals-do-not-access, palettes);
$base-palettes: (
neutral: map.get($palettes, neutral),
neutral-variant: map.get($palettes, neutral-variant),
secondary: map.get($palettes, secondary),
error: map.get($palettes, error),
);
$type: map.get($theme, _mat-theming-internals-do-not-access, theme-type);
$primary: map.merge(map.get($palettes, primary), $base-palettes);
$tertiary: map.merge(map.get($palettes, tertiary), $base-palettes);
$error: map.get($palettes, error);
@if (not $prefix) {
$prefix: map.get($theme, _mat-theming-internals-do-not-access,
color-system-variables-prefix) or definition.$system-level-prefix;
}
$ref: (
md-ref-palette: m3-tokens.generate-ref-palette-tokens($primary, $tertiary, $error)
);
$sys-colors: _generate-sys-colors($ref, $type);
// Manually insert a subset of palette values that are used directly by components
// instead of system variables.
$sys-colors: map.set($sys-colors,
'neutral-variant20', map.get($ref, md-ref-palette, neutral-variant20));
$sys-colors: map.set($sys-colors,
'neutral10', map.get($ref, md-ref-palette, neutral10));
& {
@each $name, $value in $sys-colors {
--#{$prefix}-#{$name}: #{map.get($overrides, $name) or $value};
}
}
}
@function _generate-sys-colors($ref, $type) {
$light-sys-colors: definitions.md-sys-color-values-light($ref);
@if ($type == light) {
@return $light-sys-colors;
}
$dark-sys-colors: definitions.md-sys-color-values-dark($ref);
@if ($type == dark) {
@return $dark-sys-colors;
}
@if ($type == color-scheme) {
$light-dark-sys-colors: ();
@each $name, $light-value in $light-sys-colors {
$dark-value: map.get($dark-sys-colors, $name);
$light-dark-sys-colors:
map.set($light-dark-sys-colors, $name, light-dark($light-value, $dark-value));
}
@return $light-dark-sys-colors;
}
@error 'Unknown theme-type provided: #{$type}';
} | {
"end_byte": 7079,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/_m3-system.scss"
} |
components/src/material/core/tokens/_m3-system.scss_7081_10965 | @mixin system-level-typography($theme, $overrides: (), $prefix: null) {
$font-definition: map.get($theme, _mat-theming-internals-do-not-access, font-definition);
$brand: map.get($font-definition, brand);
$plain: map.get($font-definition, plain);
$bold: map.get($font-definition, bold);
$medium: map.get($font-definition, medium);
$regular: map.get($font-definition, regular);
$ref: (md-ref-typeface:
m3-tokens.generate-ref-typeface-tokens($brand, $plain, $bold, $medium, $regular)
);
@if (not $prefix) {
$prefix: map.get($theme, _mat-theming-internals-do-not-access,
typography-system-variables-prefix) or definition.$system-level-prefix;
}
& {
@each $name, $value in definitions.md-sys-typescale-values($ref) {
--#{$prefix}-#{$name}: #{map.get($overrides, $name) or $value};
}
}
}
@mixin system-level-elevation($theme, $overrides: (), $prefix: definition.$system-level-prefix) {
$shadow-color: map.get(
$theme, _mat-theming-internals-do-not-access, color-tokens, (mdc, theme), shadow);
@each $name, $value in definitions.md-sys-elevation-values() {
$level: map.get($overrides, $name) or $value;
$value: elevation.get-box-shadow($level, $shadow-color);
& {
--#{$prefix}-#{$name}: #{$value};
}
}
}
@mixin system-level-shape($theme: (), $overrides: (), $prefix: definition.$system-level-prefix) {
& {
@each $name, $value in definitions.md-sys-shape-values() {
--#{$prefix}-#{$name}: #{map.get($overrides, $name) or $value};
}
}
}
@mixin system-level-state($theme: (), $overrides: (), $prefix: definition.$system-level-prefix) {
& {
@each $name, $value in definitions.md-sys-state-values() {
--#{$prefix}-#{$name}: #{map.get($overrides, $name) or $value};
}
}
}
@mixin system-level-motion($theme: (), $overrides: (), $prefix: definition.$system-level-prefix) {
& {
@each $name, $value in definitions.md-sys-motion-values() {
--#{$prefix}-#{$name}: #{map.get($overrides, $name) or $value};
}
}
}
// Return a new map where the values are the same as the provided map's
// keys, prefixed with "--mat-sys-". For example:
// (key1: '', key2: '') --> (key1: --mat-sys-key1, key2: --mat-sys-key2)
@function _create-system-app-vars-map($map) {
$new-map: ();
@each $key, $value in $map {
$new-map: map.set($new-map, $key, --#{definition.$system-fallback-prefix}-#{$key});
}
@return $new-map;
}
// Create a components tokens map where values are based on
// system fallback variables referencing Material's system keys.
// Includes density token fallbacks where density is 0.
@function create-system-fallbacks() {
$app-vars: (
'md-sys-color':
_create-system-app-vars-map(definitions.md-sys-color-values-light()),
'md-sys-typescale':
_create-system-app-vars-map(definitions.md-sys-typescale-values()),
'md-sys-elevation':
_create-system-app-vars-map(definitions.md-sys-elevation-values()),
'md-sys-state':
_create-system-app-vars-map(definitions.md-sys-state-values()),
'md-sys-shape':
_create-system-app-vars-map(definitions.md-sys-shape-values()),
// Add a subset of palette-specific colors used by components instead of system values
'md-ref-palette':
_create-system-app-vars-map(
(
neutral10: '', // Form field native select option text color
neutral-variant20: '', // Sidenav scrim (container background shadow when opened),
)
),
);
@return sass-utils.deep-merge-all(
m3-tokens.generate-tokens($app-vars, true, true),
m3-tokens.generate-density-tokens(0)
);
}
/// Creates a single merged map from the provided variable-length map arguments
@function map-merge-all($maps...) {
$result: ();
@each $map in $maps {
$result: map.merge($result, $map);
}
@return $result;
} | {
"end_byte": 10965,
"start_byte": 7081,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/_m3-system.scss"
} |
components/src/material/core/tokens/_token-definition.scss_0_6936 | @use 'sass:color';
@use 'sass:list';
@use 'sass:map';
@use 'sass:meta';
@use 'sass:math';
@use '../m2/palette' as m2-palette;
@use '../m2/theming' as m2-theming;
@use '../m2/typography' as m2-typography;
@use '../style/sass-utils';
@use './m3/definitions' as m3-token-definitions;
// Indicates whether we're building internally. Used for backwards compatibility.
$private-is-internal-build: false;
$_placeholder-color-palette: m2-theming.define-palette(m2-palette.$red-palette);
// Placeholder color config that can be passed to token getter functions when generating token
// slots.
$placeholder-color-config: (
primary: $_placeholder-color-palette,
accent: $_placeholder-color-palette,
warn: $_placeholder-color-palette,
is-dark: false,
foreground: m2-palette.$light-theme-foreground-palette,
background: m2-palette.$light-theme-background-palette,
);
$_placeholder-typography-level-config: m2-typography.typography-config-level-from-mdc(body1);
// Placeholder typography config that can be passed to token getter functions when generating token
// slots.
$placeholder-typography-config: (
font-family: 'Roboto, sans-serif',
headline-1: $_placeholder-typography-level-config,
headline-2: $_placeholder-typography-level-config,
headline-3: $_placeholder-typography-level-config,
headline-4: $_placeholder-typography-level-config,
headline-5: $_placeholder-typography-level-config,
headline-6: $_placeholder-typography-level-config,
subtitle-1: $_placeholder-typography-level-config,
subtitle-2: $_placeholder-typography-level-config,
body-1: $_placeholder-typography-level-config,
body-2: $_placeholder-typography-level-config,
caption: $_placeholder-typography-level-config,
button: $_placeholder-typography-level-config,
overline: $_placeholder-typography-level-config,
subheading-1: $_placeholder-typography-level-config,
title: $_placeholder-typography-level-config,
);
// Placeholder density config that can be passed to token getter functions when generating token
// slots.
$placeholder-density-config: 0;
$_tokens: null;
$_component-prefix: null;
$_system-fallbacks: null;
/// Gets all the MDC token values for a specific component. This function serves as single
/// point at which we directly reference a specific version of the MDC tokens.
/// @param {String} $component Name of the component for which to get the tokens
/// @param {Map} $systems The MDC system tokens
/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values
/// @return {List} Map of token names to values
@function get-mdc-tokens($component, $systems, $exclude-hardcoded) {
$full-name: 'md-comp-' + $component + '-values';
$fn: meta.get-function($name: $full-name, $module: 'm3-token-definitions');
@return meta.call($fn, $systems, $exclude-hardcoded);
}
/// Gets the MDC tokens for the given prefix, M3 token values, and supported token slots.
/// @param {List} $prefix The token prefix for the given tokens.
/// @param {Map|(Map, Map)} $values A map of M3 token values for the given prefix.
/// This param may also be a tuple of maps, the first one representing the default M3 token values,
// and the second containing overrides for different color variants.
// Single map example:
// (token1: green, token2: 2px)
// Tuple example:
// (
// (token1: green, token2: 2px),
// (
// secondary: (token1: blue),
// error: (token1: red),
// )
// )
/// @param {Map} $slots A map of token slots, with null value indicating the token is not supported.
/// @param {String|null} $variant The name of the variant the token values are for.
/// @return {Map} A map of fully qualified token names to values, for only the supported tokens.
@function namespace-tokens($prefix, $values, $slots, $variant: null) {
$result: ();
@if $variant == null and meta.type-of($values) == 'list' and list.length($values == 2) {
$variants: list.nth($values, 2);
$values: list.nth($values, 1);
@each $variant, $overrides in $variants {
$result: map.merge($result, namespace-tokens($prefix, $overrides, $slots, $variant));
}
}
$used-token-names: map.keys(_filter-nulls(map.get($slots, $prefix)));
$used-m3-tokens: _pick(_filter-nulls($values), $used-token-names);
$prefix: if($variant == null, $prefix, list.append($prefix, $variant));
@return map.merge($result, ($prefix: $used-m3-tokens));
}
/// Hardcode the given value, or null if hardcoded values are excluded.
@function hardcode($value, $exclude-hardcoded) {
@return if($exclude-hardcoded, null, $value);
}
/// Sets all of the standard typography tokens for the given token base name to the given typography
/// level.
/// @param {Map} $systems The MDC system tokens
/// @param {String} $base-name The token base name to get the typography tokens for
/// @param {String} $typography-level The typography level to base the token values on
/// @return {Map} A map containing the typography tokens for the given base token name
@function generate-typography-tokens($systems, $base-name, $typography-level) {
$result: ();
@each $prop in (font, line-height, size, tracking, weight) {
$result: map.set($result, #{$base-name}-#{$prop},
map.get($systems, md-sys-typescale, #{$typography-level}-#{$prop}));
}
@return $result;
}
/// Maps the values in a map to new values using the given mapping function
/// @param {Map} $map The maps whose values will be mapped to new values.
/// @param {Function} $fn The value mapping function.
/// @param {Map} A new map with its values updated using the mapping function.
@function map-values($map, $fn) {
$result: ();
@each $key, $value in $map {
$result: map.set($result, $key, meta.call($fn, $value));
}
@return $result;
}
/// Renames the keys in a map
/// @param {Map} $map The map whose keys should be renamed
/// @param {Map} $rename-keys A map of original key to renamed key to apply to $map
/// @return {Map} The result of applying the given key renames to the given map.
@function rename-map-keys($map, $rename-keys) {
$result: $map;
@each $old-key-name, $new-key-name in $rename-keys {
@if map.has-key($map, $old-key-name) {
$result: map.set($result, $new-key-name, map.get($map, $old-key-name));
}
}
@return $result;
}
/// At the time of writing, some color tokens (e.g. disabled state) are defined as a solid color
/// token and a separate opacity token. This function applies the opacity to the color and drops the
/// opacity key from the map. Can be removed once b/213331407 is resolved.
/// @param {Map} $tokens The map of tokens currently being generated
/// @param {Map} $all-tokens A map of all tokens, including hardcoded values
/// @param {List} $pairs Pairs of color token names and their opacities. Should be in the shape of
/// `((color: 'color-key', opacity: 'opacity-key'))`.
/// @return {Map} The initial tokens with the combined color values. | {
"end_byte": 6936,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/_token-definition.scss"
} |
components/src/material/core/tokens/_token-definition.scss_6937_10462 | @function combine-color-tokens($tokens, $opacity-lookup, $pairs) {
$result: $tokens;
@each $pair in $pairs {
$color-key: map.get($pair, color);
$opacity-key: map.get($pair, opacity);
$color: map.get($tokens, $color-key);
@if (sass-utils.is-css-var-name($color)) {
$color: var(#{$color});
}
$opacity: map.get($opacity-lookup, $opacity-key);
@if(meta.type-of($color) == 'color') {
$result: map.remove($result, $opacity-key);
$result: map.set($result, $color-key, rgba($color, $opacity));
}
@else if($color != null) {
$result: map.remove($result, $opacity-key);
$combined-color: #{color-mix(in srgb, #{$color} #{($opacity * 100) + '%'}, transparent)};
$result: map.set($result, $color-key, $combined-color);
}
}
@return $result;
}
/// Inherited function from MDC that computes which contrast tone to use on top of a color.
/// This is used only in a narrow set of use cases when generating M2 button tokens to maintain
/// backwards compatibility.
/// @param {Color} $value Color for which we're calculating the contrast tone.
/// @param {Boolean} $is-dark Whether the current theme is dark.
/// @return {Map} Either `dark` or `light`.
@function contrast-tone($value, $is-dark) {
@if ($value == 'dark') {
@return 'light';
}
@if ($value == 'light') {
@return 'dark';
}
// Fallback if the app is using a non-color palette (e.g. CSS variable based).
@if (meta.type-of($value) != 'color') {
@return if($is-dark, 'light', 'dark');
}
$minimum-contrast: 3.1;
$light-contrast: _contrast($value, #fff);
$dark-contrast: _contrast($value, rgba(0, 0, 0, 0.87));
@if ($light-contrast < $minimum-contrast) and ($dark-contrast > $light-contrast) {
@return 'dark';
}
@return 'light';
}
@function _linear-channel-value($channel-value) {
$normalized-channel-value: math.div($channel-value, 255);
@if ($normalized-channel-value < 0.03928) {
@return math.div($normalized-channel-value, 12.92);
}
@return math.pow(math.div($normalized-channel-value + 0.055, 1.055), 2.4);
}
// Calculate the luminance for a color.
// See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
@function _luminance($color) {
$red: _linear-channel-value(color.red($color));
$green: _linear-channel-value(color.green($color));
$blue: _linear-channel-value(color.blue($color));
@return 0.2126 * $red + 0.7152 * $green + 0.0722 * $blue;
}
// Calculate the contrast ratio between two colors.
// See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
@function _contrast($back, $front) {
$back-lum: _luminance($back) + 0.05;
$fore-lum: _luminance($front) + 0.05;
@return math.div(math.max($back-lum, $fore-lum), math.min($back-lum, $fore-lum));
}
/// Picks a submap containing only the given keys out the given map.
/// @param {Map} $map The map to pick from.
/// @param {List} $keys The map keys to pick.
/// @return {Map} A submap containing only the given keys.
@function _pick($map, $keys) {
$result: ();
@each $key in $keys {
@if map.has-key($map, $key) {
$result: map.set($result, $key, map.get($map, $key));
}
}
@return $result;
}
/// Filters keys with a null value out of the map.
/// @param {Map} $map The map to filter.
/// @return {Map} The given map with all of the null keys filtered out.
@function _filter-nulls($map) {
$result: ();
@each $key, $val in $map {
@if $val != null {
$result: map.set($result, $key, $val);
}
}
@return $result;
} | {
"end_byte": 10462,
"start_byte": 6937,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/_token-definition.scss"
} |
components/src/material/core/tokens/m2/_index.scss_0_4081 | @use 'sass:map';
@use 'sass:meta';
@use '../../style/sass-utils';
@use './mat/app' as tokens-mat-app;
@use './mat/autocomplete' as tokens-mat-autocomplete;
@use './mat/badge' as tokens-mat-badge;
@use './mat/text-button' as tokens-mat-text-button;
@use './mat/protected-button' as tokens-mat-protected-button;
@use './mat/filled-button' as tokens-mat-filled-button;
@use './mat/outlined-button' as tokens-mat-outlined-button;
@use './mat/dialog' as tokens-mat-dialog;
@use './mat/bottom-sheet' as tokens-mat-bottom-sheet;
@use './mat/card' as tokens-mat-card;
@use './mat/chip' as tokens-mat-chip;
@use './mat/datepicker' as tokens-mat-datepicker;
@use './mat/divider' as tokens-mat-divider;
@use './mat/expansion' as tokens-mat-expansion;
@use './mat/fab' as tokens-mat-fab;
@use './mat/fab-small' as tokens-mat-fab-small;
@use './mat/form-field' as tokens-mat-form-field;
@use './mat/grid-list' as tokens-mat-grid-list;
@use './mat/icon' as tokens-mat-icon;
@use './mat/icon-button' as tokens-mat-icon-button;
@use './mat/list' as tokens-mat-list;
@use './mat/menu' as tokens-mat-menu;
@use './mat/option' as tokens-mat-option;
@use './mat/optgroup' as tokens-mat-optgroup;
@use './mat/paginator' as tokens-mat-paginator;
@use './mat/checkbox' as tokens-mat-checkbox;
@use './mat/full-pseudo-checkbox' as tokens-mat-full-pseudo-checkbox;
@use './mat/minimal-pseudo-checkbox' as tokens-mat-minimal-pseudo-checkbox;
@use './mat/radio' as tokens-mat-radio;
@use './mat/ripple' as tokens-mat-ripple;
@use './mat/select' as tokens-mat-select;
@use './mat/sidenav' as tokens-mat-sidenav;
@use './mat/slider' as tokens-mat-slider;
@use './mat/switch' as tokens-mat-switch;
@use './mat/snack-bar' as tokens-mat-snack-bar;
@use './mat/sort' as tokens-mat-sort;
@use './mat/standard-button-toggle' as tokens-mat-button-toggle;
@use './mat/stepper' as tokens-mat-stepper;
@use './mat/tab-header' as tokens-mat-tab-header;
@use './mat/tab-header-with-background' as tokens-mat-tab-header-with-background;
@use './mat/table' as tokens-mat-table;
@use './mat/toolbar' as tokens-mat-toolbar;
@use './mat/tree' as tokens-mat-tree;
@use './mat/timepicker' as tokens-mat-timepicker;
@use './mdc/checkbox' as tokens-mdc-checkbox;
@use './mdc/text-button' as tokens-mdc-text-button;
@use './mdc/protected-button' as tokens-mdc-protected-button;
@use './mdc/filled-button' as tokens-mdc-filled-button;
@use './mdc/outlined-button' as tokens-mdc-outlined-button;
@use './mdc/chip' as tokens-mdc-chip;
@use './mdc/circular-progress' as tokens-mdc-circular-progress;
@use './mdc/dialog' as tokens-mdc-dialog;
@use './mdc/elevated-card' as tokens-mdc-elevated-card;
@use './mdc/extended-fab' as tokens-mdc-extended-fab;
@use './mdc/fab' as tokens-mdc-fab;
@use './mdc/fab-small' as tokens-mdc-fab-small;
@use './mdc/filled-text-field' as tokens-mdc-filled-text-field;
@use './mdc/icon-button' as tokens-mdc-icon-button;
@use './mdc/linear-progress' as tokens-mdc-linear-progress;
@use './mdc/list' as tokens-mdc-list;
@use './mdc/outlined-card' as tokens-mdc-outlined-card;
@use './mdc/outlined-text-field' as tokens-mdc-outlined-text-field;
@use './mdc/plain-tooltip' as tokens-mdc-plain-tooltip;
@use './mdc/radio' as tokens-mdc-radio;
@use './mdc/slider' as tokens-mdc-slider;
@use './mdc/snack-bar' as tokens-mdc-snack-bar;
@use './mdc/switch' as tokens-mdc-switch;
@use './mdc/secondary-navigation-tab' as tokens-mdc-secondary-navigation-tab;
@use './mdc/tab-indicator' as tokens-mdc-tab-indicator;
@use '../../theming/inspection';
/// Gets the tokens for the given theme, m2 tokens module, and theming system.
/// @param {Map} $theme The Angular Material theme object to generate token values from.
/// @param {String} $module The Sass module containing the token getter functions.
/// @param {String} $system The theming system to get tokens for. Valid values are: unthemable,
/// color, typography, density.
/// @return {Map} The token map by calling the token getter for the given system in the given module
/// with the given Angular Material theme. Token names are not fully-qualified. | {
"end_byte": 4081,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/_index.scss"
} |
components/src/material/core/tokens/m2/_index.scss_4082_9761 | @function _get-tokens-for-module-and-system($theme, $module, $system) {
@if $system == unthemable {
@return meta.call(meta.get-function(get-#{$system}-tokens, $module: $module));
}
@if not inspection.theme-has($theme, $system) {
@return ();
}
@return meta.call(meta.get-function(get-#{$system}-tokens, $module: $module), $theme);
}
/// Gets the fully qualified tokens map for the given theme and m2 tokens module.
/// @param {Map} $theme The Angular Material theme object to generate token values from.
/// @param {String} $module The Sass module containing the token getter functions.
/// @return {Map} The token map by calling the token getters in the given module with the given
/// Angular Material theme. Token names are fully-qualified.
@function _get-tokens-for-module($theme, $module) {
$tokens: sass-utils.deep-merge-all(
_get-tokens-for-module-and-system($theme, $module, unthemable),
_get-tokens-for-module-and-system($theme, $module, color),
_get-tokens-for-module-and-system($theme, $module, typography),
_get-tokens-for-module-and-system($theme, $module, density)
);
@return map.set((), map.get(meta.module-variables($module), prefix), $tokens);
}
/// Gets the full set of M2 tokens for the given theme object.
/// @param {Map} $theme The Angular Material theme object to generate token values from.
/// @return {Map} The token map for the given Angular Material theme. Returned format:
/// (
/// (fully, qualified, namespace): (
/// token: value
/// )
/// )
@function m2-tokens-from-theme($theme) {
@return sass-utils.deep-merge-all(
_get-tokens-for-module($theme, tokens-mat-app),
_get-tokens-for-module($theme, tokens-mat-autocomplete),
_get-tokens-for-module($theme, tokens-mat-badge),
_get-tokens-for-module($theme, tokens-mat-bottom-sheet),
_get-tokens-for-module($theme, tokens-mat-button-toggle),
_get-tokens-for-module($theme, tokens-mat-card),
_get-tokens-for-module($theme, tokens-mat-chip),
_get-tokens-for-module($theme, tokens-mat-datepicker),
_get-tokens-for-module($theme, tokens-mat-dialog),
_get-tokens-for-module($theme, tokens-mat-divider),
_get-tokens-for-module($theme, tokens-mat-expansion),
_get-tokens-for-module($theme, tokens-mat-fab),
_get-tokens-for-module($theme, tokens-mat-fab-small),
_get-tokens-for-module($theme, tokens-mat-filled-button),
_get-tokens-for-module($theme, tokens-mat-form-field),
_get-tokens-for-module($theme, tokens-mat-grid-list),
_get-tokens-for-module($theme, tokens-mat-icon-button),
_get-tokens-for-module($theme, tokens-mat-icon),
_get-tokens-for-module($theme, tokens-mat-menu),
_get-tokens-for-module($theme, tokens-mat-optgroup),
_get-tokens-for-module($theme, tokens-mat-option),
_get-tokens-for-module($theme, tokens-mat-outlined-button),
_get-tokens-for-module($theme, tokens-mat-paginator),
_get-tokens-for-module($theme, tokens-mat-checkbox),
_get-tokens-for-module($theme, tokens-mat-full-pseudo-checkbox),
_get-tokens-for-module($theme, tokens-mat-list),
_get-tokens-for-module($theme, tokens-mat-minimal-pseudo-checkbox),
_get-tokens-for-module($theme, tokens-mat-protected-button),
_get-tokens-for-module($theme, tokens-mat-radio),
_get-tokens-for-module($theme, tokens-mat-ripple),
_get-tokens-for-module($theme, tokens-mat-select),
_get-tokens-for-module($theme, tokens-mat-sidenav),
_get-tokens-for-module($theme, tokens-mat-slider),
_get-tokens-for-module($theme, tokens-mat-switch),
_get-tokens-for-module($theme, tokens-mat-snack-bar),
_get-tokens-for-module($theme, tokens-mat-sort),
_get-tokens-for-module($theme, tokens-mat-stepper),
_get-tokens-for-module($theme, tokens-mat-tab-header-with-background),
_get-tokens-for-module($theme, tokens-mat-tab-header),
_get-tokens-for-module($theme, tokens-mat-table),
_get-tokens-for-module($theme, tokens-mat-text-button),
_get-tokens-for-module($theme, tokens-mat-toolbar),
_get-tokens-for-module($theme, tokens-mat-tree),
_get-tokens-for-module($theme, tokens-mat-timepicker),
_get-tokens-for-module($theme, tokens-mdc-checkbox),
_get-tokens-for-module($theme, tokens-mdc-chip),
_get-tokens-for-module($theme, tokens-mdc-circular-progress),
_get-tokens-for-module($theme, tokens-mdc-dialog),
_get-tokens-for-module($theme, tokens-mdc-elevated-card),
_get-tokens-for-module($theme, tokens-mdc-extended-fab),
_get-tokens-for-module($theme, tokens-mdc-fab),
_get-tokens-for-module($theme, tokens-mdc-fab-small),
_get-tokens-for-module($theme, tokens-mdc-filled-button),
_get-tokens-for-module($theme, tokens-mdc-filled-text-field),
_get-tokens-for-module($theme, tokens-mdc-icon-button),
_get-tokens-for-module($theme, tokens-mdc-linear-progress),
_get-tokens-for-module($theme, tokens-mdc-list),
_get-tokens-for-module($theme, tokens-mdc-outlined-button),
_get-tokens-for-module($theme, tokens-mdc-outlined-card),
_get-tokens-for-module($theme, tokens-mdc-outlined-text-field),
_get-tokens-for-module($theme, tokens-mdc-plain-tooltip),
_get-tokens-for-module($theme, tokens-mdc-protected-button),
_get-tokens-for-module($theme, tokens-mdc-radio),
_get-tokens-for-module($theme, tokens-mdc-slider),
_get-tokens-for-module($theme, tokens-mdc-snack-bar),
_get-tokens-for-module($theme, tokens-mdc-switch),
_get-tokens-for-module($theme, tokens-mdc-tab-indicator),
_get-tokens-for-module($theme, tokens-mdc-secondary-navigation-tab),
_get-tokens-for-module($theme, tokens-mdc-text-button)
);
} | {
"end_byte": 9761,
"start_byte": 4082,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/_index.scss"
} |
components/src/material/core/tokens/m2/mdc/_checkbox.scss_0_6583 | @use 'sass:map';
@use '../../../m2/palette' as m2-palette;
@use '../../../m2/theming' as m2-theming;
@use '../../../theming/theming';
@use '../../../theming/inspection';
@use '../../../style/sass-utils';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, checkbox);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
// The color of the checkmark when the checkbox is selected and disabled.
disabled-selected-checkmark-color: #fff,
// The opacity of the ripple when the checkbox is selected and focused.
selected-focus-state-layer-opacity: 0.16,
// The opacity of the ripple when the checkbox is selected and hovered.
selected-hover-state-layer-opacity: 0.04,
// The opacity of the ripple when the checkbox is selected and pressed.
selected-pressed-state-layer-opacity: 0.16,
// The opacity of the ripple when the checkbox is unselected and focused.
unselected-focus-state-layer-opacity: 0.16,
// The opacity of the ripple when the checkbox is unselected and hovered.
unselected-hover-state-layer-opacity: 0.04,
// The opacity of the ripple when the checkbox is unselected and pressed.
unselected-pressed-state-layer-opacity: 0.16,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
selected-pressed-icon-color: null,
unselected-pressed-icon-color: null,
// MDC currently doesn't output a slot for these tokens.
disabled-selected-icon-opacity: null,
disabled-unselected-icon-opacity: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme, $palette-name: accent) {
$is-dark: inspection.get-theme-type($theme) == dark;
$foreground-base: inspection.get-theme-color($theme, foreground, base);
$palette-default: inspection.get-theme-color($theme, $palette-name, default);
$disabled-color: sass-utils.safe-color-change(
inspection.get-theme-color($theme, foreground, base), $alpha: 0.38);
$palette-selected: inspection.get-theme-color($theme, $palette-name);
$border-color: sass-utils.safe-color-change(
inspection.get-theme-color($theme, foreground, base), $alpha: 0.54);
$active-border-color:
m2-theming.get-color-from-palette(m2-palette.$gray-palette, if($is-dark, 200, 900));
$selected-checkmark-color: null;
// Ideally we would derive all values directly from the theme, but it causes a lot of regressions
// internally. For now we fall back to the old hardcoded behavior only for internal apps.
@if (token-definition.$private-is-internal-build) {
$contrast-tone: token-definition.contrast-tone($palette-selected, $is-dark);
$selected-checkmark-color: if($contrast-tone == 'dark', #000, #fff);
}
@else {
$selected-checkmark-color:
inspection.get-theme-color($theme, $palette-name, default-contrast, 1);
}
@return (
// The color of the checkbox fill when the checkbox is selected and disabled.
disabled-selected-icon-color: $disabled-color,
// The color of the checkbox border when the checkbox is unselected and disabled.
disabled-unselected-icon-color: $disabled-color,
// The color of the checkmark when the checkbox is selected.
selected-checkmark-color: $selected-checkmark-color,
// The color of the checkbox fill when the checkbox is selected and focused.
selected-focus-icon-color: $palette-selected,
// The color of the checkbox fill when the checkbox is selected and hovered.
selected-hover-icon-color: $palette-selected,
// The color of the checkbox fill when the checkbox is selected.
selected-icon-color: $palette-selected,
// The color of the checkbox fill when the checkbox is selected and pressed.
selected-pressed-icon-color: $palette-selected,
// The color of the checkbox border when the checkbox is unselected and focused.
unselected-focus-icon-color: $active-border-color,
// The color of the checkbox border when the checkbox is unselected and hovered.
unselected-hover-icon-color: $active-border-color,
// The color of the checkbox border when the checkbox is unselected.
unselected-icon-color: $border-color,
// The color of the ripple when the checkbox is selected and focused.
selected-focus-state-layer-color: $palette-default,
// The color of the ripple when the checkbox is selected and hovered.
selected-hover-state-layer-color: $palette-default,
// The color of the ripple when the checkbox is selected and pressed.
selected-pressed-state-layer-color: $palette-default,
// The color of the ripple when the checkbox is unselected and focused.
unselected-focus-state-layer-color: $foreground-base,
// The color of the ripple when the checkbox is unselected and hovered.
unselected-hover-state-layer-color: $foreground-base,
// The color of the ripple when the checkbox is unselected and pressed.
unselected-pressed-state-layer-color: $foreground-base,
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return ();
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
$scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
@return (
// The diameter of the checkbox's ripple.
state-layer-size: map.get((
0: 40px,
-1: 36px,
-2: 32px,
-3: 28px,
), $scale)
);
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 6583,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_checkbox.scss"
} |
components/src/material/core/tokens/m2/mdc/_extended-fab.scss_0_3192 | @use 'sass:map';
@use '../../token-definition';
@use '../../../style/elevation';
@use '../../../theming/inspection';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, extended-fab);
@function get-unthemable-tokens() {
@return (
container-height: 48px,
container-shape: 24px,
container-elevation-shadow: elevation.get-box-shadow(6),
focus-container-elevation-shadow: elevation.get-box-shadow(8),
hover-container-elevation-shadow: elevation.get-box-shadow(8),
pressed-container-elevation-shadow: elevation.get-box-shadow(12),
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
container-color: null,
container-surface-tint-layer-color: null,
focus-icon-color: null,
focus-label-text-color: null,
focus-outline-color: null,
focus-outline-width: null,
focus-state-layer-color: null,
focus-state-layer-opacity: null,
hover-icon-color: null,
hover-label-text-color: null,
hover-state-layer-color: null,
hover-state-layer-opacity: null,
icon-color: null,
icon-size: null,
label-text-color: null,
lowered-container-elevation: null,
lowered-focus-container-elevation: null,
lowered-hover-container-elevation: null,
lowered-pressed-container-elevation: null,
pressed-icon-color: null,
pressed-label-text-color: null,
pressed-ripple-color: null,
pressed-ripple-opacity: null,
pressed-state-layer-color: null,
pressed-state-layer-opacity: null,
container-elevation: null,
focus-container-elevation: null,
hover-container-elevation: null,
pressed-container-elevation: null,
container-shadow-color: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
@return ();
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
label-text-font: inspection.get-theme-typography($theme, button, font-family),
label-text-size: inspection.get-theme-typography($theme, button, font-size),
label-text-tracking: inspection.get-theme-typography($theme, button, letter-spacing),
label-text-weight: inspection.get-theme-typography($theme, button, font-weight)
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return map.merge(
get-unthemable-tokens(),
map.merge(
get-color-tokens(token-definition.$placeholder-color-config),
map.merge(
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
)
)
);
}
| {
"end_byte": 3192,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_extended-fab.scss"
} |
components/src/material/core/tokens/m2/mdc/_filled-text-field.scss_0_7659 | @use 'sass:color';
@use 'sass:map';
@use 'sass:meta';
@use '../../../theming/inspection';
@use '../../../style/sass-utils';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, filled-text-field);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
active-indicator-height: 1px,
focus-active-indicator-height: 2px,
container-shape: 4px,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
disabled-active-indicator-height: null,
hover-active-indicator-height: null,
disabled-active-indicator-opacity: null,
error-focus-caret-color: null,
error-hover-caret-color: null,
focus-caret-color: null,
hover-caret-color: null,
label-text-populated-line-height: null,
label-text-populated-size: null,
label-text-type: null,
disabled-label-text-opacity: null,
supporting-text-color: null,
supporting-text-font: null,
supporting-text-line-height: null,
supporting-text-size: null,
supporting-text-tracking: null,
supporting-text-weight: null,
disabled-supporting-text-color: null,
disabled-supporting-text-opacity: null,
error-focus-supporting-text-color: null,
error-hover-supporting-text-color: null,
error-supporting-text-color: null,
focus-supporting-text-color: null,
hover-supporting-text-color: null,
input-text-prefix-color: null,
input-text-suffix-color: null,
container-height: null,
trailing-icon-size: null,
leading-icon-size: null,
trailing-icon-color: null,
disabled-trailing-icon-color: null,
disabled-trailing-icon-opacity: null,
error-focus-trailing-icon-color: null,
error-hover-trailing-icon-color: null,
error-trailing-icon-color: null,
focus-trailing-icon-color: null,
hover-trailing-icon-color: null,
leading-icon-color: null,
disabled-leading-icon-opacity: null,
disabled-leading-icon-color: null,
error-focus-leading-icon-color: null,
error-hover-leading-icon-color: null,
error-leading-icon-color: null,
focus-leading-icon-color: null,
hover-leading-icon-color: null,
input-text-type: null,
input-text-font: null,
input-text-line-height: null,
input-text-size: null,
input-text-tracking: null,
input-text-weight: null,
error-input-text-color: null,
focus-input-text-color: null,
hover-input-text-color: null,
disabled-input-text-opacity: null,
error-focus-input-text-color: null,
error-hover-input-text-color: null,
disabled-container-opacity: null,
error-hover-state-layer-color: null,
error-hover-state-layer-opacity: null,
hover-state-layer-color: null,
hover-state-layer-opacity: null,
label-text-line-height: null, // We override the line height to `normal` so don't emit a slot.
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$is-dark: inspection.get-theme-type($theme) == dark;
$surface: inspection.get-theme-color($theme, background, card);
$warn-color: inspection.get-theme-color($theme, warn);
$color-tokens: private-get-color-palette-color-tokens($theme, primary);
$on-surface: if($is-dark, #fff, #000);
// Ideally we would derive all values directly from the theme, but it causes a lot of regressions
// internally. For now we fall back to the old hardcoded behavior only for internal apps.
$text-color-base: if(token-definition.$private-is-internal-build, $on-surface,
inspection.get-theme-color($theme, foreground, text, 1));
$disabled-text-color-base: if(token-definition.$private-is-internal-build, $on-surface,
inspection.get-theme-color($theme, foreground, disabled-text, 1));
$divider-base: if(token-definition.$private-is-internal-build, $on-surface,
inspection.get-theme-color($theme, foreground, divider, 1));
@return map.merge($color-tokens, (
container-color: _variable-safe-mix($on-surface, $surface, 4%),
disabled-container-color: _variable-safe-mix($on-surface, $surface, 2%),
label-text-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.6),
hover-label-text-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.6),
disabled-label-text-color:
sass-utils.safe-color-change($disabled-text-color-base, $alpha: 0.38),
input-text-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.87),
disabled-input-text-color:
sass-utils.safe-color-change($disabled-text-color-base, $alpha: 0.38),
input-text-placeholder-color:
sass-utils.safe-color-change($text-color-base, $alpha: 0.6),
error-hover-label-text-color: $warn-color,
error-focus-label-text-color: $warn-color,
error-label-text-color: $warn-color,
error-caret-color: $warn-color,
active-indicator-color: sass-utils.safe-color-change($divider-base, $alpha: 0.42),
disabled-active-indicator-color: sass-utils.safe-color-change($divider-base, $alpha: 0.06),
hover-active-indicator-color: sass-utils.safe-color-change($divider-base, $alpha: 0.87),
error-active-indicator-color: $warn-color,
error-focus-active-indicator-color: $warn-color,
error-hover-active-indicator-color: $warn-color,
));
}
@function _variable-safe-mix($first-color, $second-color, $amount) {
@if (meta.type-of($first-color) == color and meta.type-of($second-color) == color) {
@return color.mix($first-color, $second-color, $amount);
}
@return $first-color;
}
// Generates the mapping for the properties that change based on the text field color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
$palette: map.get($theme, $palette-name);
$palette-color: inspection.get-theme-color($theme, $palette-name);
@return (
caret-color: $palette-color,
focus-active-indicator-color: $palette-color,
focus-label-text-color: sass-utils.safe-color-change($palette-color, $alpha: 0.87),
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
label-text-font: inspection.get-theme-typography($theme, body-1, font-family),
label-text-size: inspection.get-theme-typography($theme, body-1, font-size),
label-text-tracking: inspection.get-theme-typography($theme, body-1, letter-spacing),
label-text-weight: inspection.get-theme-typography($theme, body-1, font-weight),
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 7659,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_filled-text-field.scss"
} |
components/src/material/core/tokens/m2/mdc/_tab-indicator.scss_0_1763 | @use '../../../theming/inspection';
@use '../../../style/sass-utils';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, tab-indicator);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
active-indicator-height: 2px,
// Currently set to zero, but used by the gmat styles to make the indicator rounded.
active-indicator-shape: 0,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme, $palette-name: primary) {
@return (
active-indicator-color: inspection.get-theme-color($theme, $palette-name, default),
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return ();
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 1763,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_tab-indicator.scss"
} |
components/src/material/core/tokens/m2/mdc/_outlined-card.scss_0_3351 | @use '../../../style/elevation';
@use '../../../theming/inspection';
@use '../../../style/sass-utils';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, outlined-card);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
// The border-radius of the card.
container-shape: 4px,
// The thickness of the card's border.
outline-width: 1px,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
// Angular Material's card is not an interactive element, and therefore does not support states.
disabled-container-elevation: null,
disabled-outline-color: null,
disabled-outline-opacity: null,
dragged-container-elevation: null,
dragged-outline-color: null,
dragged-state-layer-color: null,
dragged-state-layer-opacity: null,
focus-container-elevation: null,
focus-outline-color: null,
focus-state-layer-color: null,
focus-state-layer-opacity: null,
hover-container-elevation: null,
hover-outline-color: null,
hover-state-layer-color: null,
hover-state-layer-opacity: null,
pressed-container-elevation: null,
pressed-outline-color: null,
pressed-state-layer-color: null,
pressed-state-layer-opacity: null,
container-shadow-color: null,
// Angular Material does not currently support surface tint.
container-surface-tint-layer-color: null,
// MDC does not seem to use these tokens.
icon-color: null,
icon-size: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$elevation: inspection.get-theme-color($theme, foreground, elevation);
@return (
// The background color of the card.
container-color: inspection.get-theme-color($theme, background, card),
// The border color of the card.
outline-color: rgba(inspection.get-theme-color($theme, foreground, base), 0.12),
container-elevation: elevation.get-box-shadow(0),
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return ();
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 3351,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_outlined-card.scss"
} |
components/src/material/core/tokens/m2/mdc/_protected-button.scss_0_5078 | @use 'sass:map';
@use '../../token-definition';
@use '../../../style/sass-utils';
@use '../../../style/elevation';
@use '../../../theming/inspection';
@use '../../../theming/theming';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, protected-button);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
container-shape: 4px,
container-elevation-shadow: elevation.get-box-shadow(2),
disabled-container-elevation-shadow: elevation.get-box-shadow(0),
focus-container-elevation-shadow: elevation.get-box-shadow(4),
hover-container-elevation-shadow: elevation.get-box-shadow(4),
pressed-container-elevation-shadow: elevation.get-box-shadow(8),
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
focus-ring-color: null,
focus-ring-offset: null,
focus-state-layer-opacity: null,
hover-state-layer-opacity: null,
pressed-state-layer-opacity: null,
with-icon-icon-size: null,
focus-label-text-color: null,
hover-label-text-color: null,
pressed-label-text-color: null,
with-icon-disabled-icon-color: null,
with-icon-focus-icon-color: null,
with-icon-hover-icon-color: null,
with-icon-icon-color: null,
with-icon-pressed-icon-color: null,
focus-state-layer-color: null,
hover-state-layer-color: null,
pressed-state-layer-color: null,
keep-touch-target: null,
container-elevation: null,
disabled-container-elevation: null,
focus-container-elevation: null,
hover-container-elevation: null,
pressed-container-elevation: null,
container-shadow-color: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$is-dark: inspection.get-theme-type($theme) == dark;
@return (
container-color: inspection.get-theme-color($theme, background, card),
label-text-color: inspection.get-theme-color($theme, foreground, text, 1),
disabled-container-color: inspection.get-theme-color($theme, foreground, disabled-button,
0.12),
disabled-label-text-color: inspection.get-theme-color($theme, foreground, disabled-button,
if($is-dark, 0.5, 0.38)),
);
}
// Generates the mapping for the properties that change based on the button palette color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
$container-color: inspection.get-theme-color($theme, $palette-name, default);
$label-text-color: null;
// Ideally we would derive all values directly from the theme, but it causes a lot of regressions
// internally. For now we fall back to the old hardcoded behavior only for internal apps.
@if (token-definition.$private-is-internal-build) {
$is-dark: inspection.get-theme-type($theme) == dark;
$contrast-tone: token-definition.contrast-tone($container-color, $is-dark);
$label-text-color: if($contrast-tone == 'dark', #000, #fff);
}
@else {
$label-text-color: inspection.get-theme-color($theme, $palette-name, default-contrast, 1);
}
@return (
container-color: $container-color,
label-text-color: $label-text-color,
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
label-text-font: inspection.get-theme-typography($theme, button, font-family),
label-text-size: inspection.get-theme-typography($theme, button, font-size),
label-text-tracking: inspection.get-theme-typography($theme, button, letter-spacing),
label-text-weight: inspection.get-theme-typography($theme, button, font-weight),
label-text-transform: none,
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
$scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
@return (
container-height:
map.get(
(
0: 36px,
-1: 32px,
-2: 28px,
-3: 24px,
),
$scale
)
);
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 5078,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_protected-button.scss"
} |
components/src/material/core/tokens/m2/mdc/_radio.scss_0_3935 | @use 'sass:map';
@use '../../../m2/palette' as m2-palette;
@use '../../../m2/theming' as m2-theming;
@use '../../../theming/theming';
@use '../../../theming/inspection';
@use '../../../style/sass-utils';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, radio);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
disabled-selected-icon-opacity: 0.38,
disabled-unselected-icon-opacity: 0.38,
// This is specified both here and in the density tokens, because it
// determines the size of the radio button itself and there are internal
// tests who don't configure the theme correctly.
state-layer-size: 40px,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
selected-focus-state-layer-color: null,
selected-focus-state-layer-opacity: null,
selected-hover-state-layer-color: null,
selected-hover-state-layer-opacity: null,
selected-pressed-state-layer-color: null,
selected-pressed-state-layer-opacity: null,
unselected-focus-state-layer-color: null,
unselected-focus-state-layer-opacity: null,
unselected-hover-state-layer-color: null,
unselected-hover-state-layer-opacity: null,
unselected-pressed-state-layer-color: null,
unselected-pressed-state-layer-opacity: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme, $palette-name: accent) {
$is-dark: inspection.get-theme-type($theme) == dark;
$palette-color: inspection.get-theme-color($theme, $palette-name, default);
$icon-color: m2-theming.get-color-from-palette(m2-palette.$gray-palette, if($is-dark, 200, 900));
@return (
disabled-selected-icon-color: inspection.get-theme-color($theme, foreground, icon, 1),
disabled-unselected-icon-color: inspection.get-theme-color($theme, foreground, icon, 1),
unselected-hover-icon-color: $icon-color,
unselected-focus-icon-color: $icon-color,
unselected-icon-color: inspection.get-theme-color($theme, foreground, icon, 0.54),
unselected-pressed-icon-color: inspection.get-theme-color($theme, foreground, icon, 0.54),
selected-focus-icon-color: $palette-color,
selected-hover-icon-color: $palette-color,
selected-icon-color: $palette-color,
selected-pressed-icon-color: $palette-color,
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return ();
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
$scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
@return (
// The diameter of the radio's ripple.
state-layer-size: map.get((
0: 40px,
-1: 36px,
-2: 32px,
-3: 28px,
), $scale)
);
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 3935,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_radio.scss"
} |
components/src/material/core/tokens/m2/mdc/_chip.scss_0_7149 | @use 'sass:color';
@use 'sass:map';
@use 'sass:meta';
@use '../../token-definition';
@use '../../../style/sass-utils';
@use '../../../theming/theming';
@use '../../../theming/inspection';
@use '../../../m2/palette' as m2-palette;
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, chip);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
// The shape & radius of the chip.
container-shape-radius: 16px,
// The shape & radius of the avatar.
with-avatar-avatar-shape-radius: 14px,
// The width & height of the chip avatar.
with-avatar-avatar-size: 28px,
// The width & height of the chip icon.
with-icon-icon-size: 18px,
// The chip's border width.
outline-width: 0,
// The chip's border color.
outline-color: transparent,
// The chip's border color when disabled.
disabled-outline-color: transparent,
// The chip's border color when focused.
focus-outline-color: transparent,
// The opacity of the chip's state overlay when hovered.
hover-state-layer-opacity: 0.04,
// The opacity of the chip's avatar when disabled.
with-avatar-disabled-avatar-opacity: 1,
// The chip's border width when selected.
flat-selected-outline-width: 0,
// The opacity of the chip's state overlay when selected and hovered.
selected-hover-state-layer-opacity: 0.04,
// The opacity of the chip's trailing icon when it is disabled.
with-trailing-icon-disabled-trailing-icon-opacity: 1,
// The opacity of the chip's leading icon when it is disabled.
with-icon-disabled-icon-opacity: 1,
// Not used by MDC.
disabled-label-text-opacity: null,
// Not used by MDC.
disabled-outline-opacity: null,
// Not used by MDC.
elevated-disabled-container-opacity: null,
// Not used by MDC.
flat-disabled-outline-opacity: null,
// Not used by MDC.
flat-disabled-unselected-outline-opacity: null,
// Our chips do not have a border.
flat-outline-width: null,
// Our chips do not have a border.
flat-unselected-outline-width: null,
// Not used by MDC.
with-leading-icon-disabled-leading-icon-opacity: null,
// Not used by MDC.
with-leading-icon-leading-icon-size: null,
// Not used by MDC.
with-trailing-icon-trailing-icon-size: null,
// Elevated chips not implemented.
container-elevation: null,
// Elevated chips not implemented.
container-shadow-color: null,
// Elevated chips not implemented.
elevated-container-elevation: null,
// Elevated chips not implemented.
elevated-container-shadow-color: null,
// Elevated chips not implemented.
container-surface-tint-layer-color: null,
// Elevated chips not implemented.
elevated-disabled-container-elevation: null,
// Elevated chips not implemented.
elevated-focus-container-elevation: null,
// Elevated chips not implemented.
elevated-hover-container-elevation: null,
// Elevated chips not implemented.
elevated-pressed-container-elevation: null,
// Elevated chips not implemented.
elevated-selected-container-elevation: null,
// Elevated chips not implemented.
elevated-unselected-container-color: null,
// Elevated chips not implemented.
flat-container-elevation: null,
// Our chips do not have a border.
flat-disabled-outline-color: null,
// Not used by MDC.
flat-disabled-selected-container-opacity: null,
// Unused.
flat-disabled-selected-outline-color: null,
// Unused.
flat-disabled-selected-outline-opacity: null,
// Unused.
flat-disabled-unselected-outline-color: null,
// Unused.
flat-focus-outline-color: null,
// Unused.
flat-outline-color: null,
// Unused.
flat-selected-container-color: null,
// Unused.
flat-selected-focus-container-elevation: null,
// Unused.
flat-selected-hover-container-elevation: null,
// Unused.
flat-selected-outline-color: null,
// Unused.
flat-selected-pressed-container-elevation: null,
// Unused.
flat-unselected-focus-container-elevation: null,
// Unused.
flat-unselected-focus-outline-color: null,
// Unused.
flat-unselected-hover-container-elevation: null,
// Unused.
flat-unselected-outline-color: null,
// Unused.
flat-unselected-pressed-container-elevation: null,
// Unused.
focus-label-text-color: null,
// Unused.
hover-label-text-color: null,
// Unused.
pressed-label-text-color: null,
// Unused.
pressed-state-layer-color: null,
// Unused.
pressed-state-layer-opacity: null,
// Unused.
selected-focus-label-text-color: null,
// Unused.
selected-hover-label-text-color: null,
// Unused.
selected-pressed-label-text-color: null,
// Unused.
selected-pressed-state-layer-color: null,
// Unused.
selected-pressed-state-layer-opacity: null,
// Unused.
unselected-focus-label-text-color: null,
// Unused.
unselected-focus-state-layer-color: null,
// Unused.
unselected-focus-state-layer-opacity: null,
// Unused.
unselected-hover-label-text-color: null,
// Unused.
unselected-hover-state-layer-color: null,
// Unused.
unselected-hover-state-layer-opacity: null,
// Unused.
unselected-label-text-color: null,
// Unused.
unselected-pressed-label-text-color: null,
// Unused.
unselected-pressed-state-layer-color: null,
// Unused.
unselected-pressed-state-layer-opacity: null,
// Unused.
with-icon-focus-icon-color: null,
// Unused.
with-icon-hover-icon-color: null,
// Unused.
with-icon-pressed-icon-color: null,
// Unused.
with-icon-selected-focus-icon-color: null,
// Unused.
with-icon-selected-hover-icon-color: null,
// Unused.
with-icon-selected-pressed-icon-color: null,
// Unused.
with-icon-unselected-focus-icon-color: null,
// Unused.
with-icon-unselected-hover-icon-color: null,
// Unused.
with-icon-unselected-icon-color: null,
// Unused.
with-icon-unselected-pressed-icon-color: null,
// Unused.
with-leading-icon-disabled-leading-icon-color: null,
// Unused.
with-leading-icon-focus-leading-icon-color: null,
// Unused.
with-leading-icon-hover-leading-icon-color: null,
// Unused.
with-leading-icon-leading-icon-color: null,
// Unused.
with-leading-icon-pressed-leading-icon-color: null,
// Unused.
with-trailing-icon-focus-trailing-icon-color: null,
// Unused.
with-trailing-icon-hover-trailing-icon-color: null,
// Unused.
with-trailing-icon-pressed-trailing-icon-color: null
);
}
// Tokens that can be configured through Angular Material's color theming API. | {
"end_byte": 7149,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_chip.scss"
} |
components/src/material/core/tokens/m2/mdc/_chip.scss_7150_11568 | @function get-color-tokens($theme, $palette-name: null) {
$foreground: null;
$background: null;
$state-layer-color: inspection.get-theme-color($theme, foreground, base);
$state-layer-opacity: 0.12; // 0.12 is a common value in Material Design for opacity.
@if $palette-name == null {
$is-dark: inspection.get-theme-type($theme) == dark;
$grey-50: map.get(m2-palette.$grey-palette, 50);
$grey-900: map.get(m2-palette.$grey-palette, 900);
$foreground: if($is-dark, $grey-50, $grey-900);
$surface: inspection.get-theme-color($theme, background, card);
$background: if(
meta.type-of($state-layer-color) == color and meta.type-of($surface) == color,
color.mix($state-layer-color, $surface, 12%),
$state-layer-color
);
}
@else {
$background: inspection.get-theme-color($theme, $palette-name);
$foreground: inspection.get-theme-color($theme, $palette-name, default-contrast);
}
@return (
// The text color of a disabled chip.
disabled-label-text-color: $foreground,
// The background-color of the chip.
elevated-container-color: $background,
// The background-color of the chip when selected.
elevated-selected-container-color: $background,
// The background-color of a disabled chip.
elevated-disabled-container-color: $background,
// The background color of the chip when disabled and selected.
flat-disabled-selected-container-color: $background,
// The color of the focus state layer.
focus-state-layer-color: $state-layer-color,
// The color of the hover state layer.
hover-state-layer-color: $state-layer-color,
// The color of the chip's state overlay when selected and hovered.
selected-hover-state-layer-color: $state-layer-color,
// The opacity of the focus state layer.
focus-state-layer-opacity: $state-layer-opacity,
// The color of the chip's state overlay when selected and focused.
selected-focus-state-layer-color: $state-layer-color,
// The opacity of the chip's state overlay when selected and focused.
selected-focus-state-layer-opacity: $state-layer-opacity,
// The chip text color.
label-text-color: $foreground,
// The chip text color when selected.
selected-label-text-color: $foreground,
// The icon color of a chip.
with-icon-icon-color: $foreground,
// The color of the icon of a disabled chip.
with-icon-disabled-icon-color: $foreground,
// The color of the icon of a selected chip.
with-icon-selected-icon-color: $foreground,
// The color of the icon at the end of a disabled chip.
with-trailing-icon-disabled-trailing-icon-color: $foreground,
// The color of the icon at the end of the chip.
with-trailing-icon-trailing-icon-color: $foreground
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
// The font family of the chip text.
label-text-font: inspection.get-theme-typography($theme, body-2, font-family),
// The line height of the chip text.
label-text-line-height: inspection.get-theme-typography($theme, body-2, line-height),
// The font size of the chip text.
label-text-size: inspection.get-theme-typography($theme, body-2, font-size),
// The letter spacing of the chip label.
label-text-tracking: inspection.get-theme-typography($theme, body-2, letter-spacing),
// The font weight of the chip text.
label-text-weight: inspection.get-theme-typography($theme, body-2, font-weight)
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
$scale: theming.clamp-density(inspection.get-theme-density($theme), -2);
@return (
// The height of the chip.
container-height:
map.get(
(
0: 32px,
-1: 28px,
-2: 24px,
),
$scale
)
);
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
} | {
"end_byte": 11568,
"start_byte": 7150,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_chip.scss"
} |
components/src/material/core/tokens/m2/mdc/_text-button.scss_0_3626 | @use 'sass:map';
@use '../../token-definition';
@use '../../../style/sass-utils';
@use '../../../theming/inspection';
@use '../../../theming/theming';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, text-button);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
container-shape: 4px,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
hover-label-text-color: null,
focus-label-text-color: null,
pressed-label-text-color: null,
focus-state-layer-color: null,
focus-state-layer-opacity: null,
hover-state-layer-color: null,
hover-state-layer-opacity: null,
pressed-state-layer-color: null,
pressed-state-layer-opacity: null,
with-icon-disabled-icon-color: null,
with-icon-focus-icon-color: null,
with-icon-hover-icon-color: null,
with-icon-icon-color: null,
with-icon-icon-size: null,
with-icon-pressed-icon-color: null,
focus-ring-color: null,
focus-ring-offset: null,
keep-touch-target: false,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$is-dark: inspection.get-theme-type($theme) == dark;
@return (
label-text-color: inspection.get-theme-color($theme, foreground, text, 1),
disabled-label-text-color: inspection.get-theme-color($theme, foreground, disabled-button,
if($is-dark, 0.5, 0.38)),
);
}
// Generates the mapping for the properties that change based on the button palette color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
$palette: map.get($theme, $palette-name);
@return (
label-text-color: inspection.get-theme-color($theme, $palette-name)
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
label-text-font: inspection.get-theme-typography($theme, button, font-family),
label-text-size: inspection.get-theme-typography($theme, button, font-size),
label-text-tracking: inspection.get-theme-typography($theme, button, letter-spacing),
label-text-weight: inspection.get-theme-typography($theme, button, font-weight),
label-text-transform: none,
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
$scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
@return (
container-height: map.get((
0: 36px,
-1: 32px,
-2: 28px,
-3: 24px,
), $scale),
);
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 3626,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_text-button.scss"
} |
components/src/material/core/tokens/m2/mdc/_outlined-button.scss_0_4499 | @use 'sass:map';
@use '../../token-definition';
@use '../../../style/sass-utils';
@use '../../../theming/inspection';
@use '../../../theming/theming';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, outlined-button);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
keep-touch-target: false,
outline-width: 1px,
container-shape: 4px,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
hover-state-layer-opacity: null,
focus-state-layer-opacity: null,
pressed-state-layer-opacity: null,
focus-state-layer-color: null,
hover-state-layer-color: null,
pressed-state-layer-color: null,
hover-label-text-color: null,
focus-label-text-color: null,
pressed-label-text-color: null,
hover-outline-color: null,
focus-outline-color: null,
pressed-outline-color: null,
focus-ring-color: null,
focus-ring-offset: null,
with-icon-icon-size: null,
with-icon-icon-color: null,
with-icon-hover-icon-color: null,
with-icon-focus-icon-color: null,
with-icon-pressed-icon-color: null,
with-icon-disabled-icon-color: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$is-dark: inspection.get-theme-type($theme) == dark;
// Ideally we would derive all values directly from the theme, but it causes a lot of regressions
// internally. For now we fall back to the old hardcoded behavior only for internal apps.
$outline: if(token-definition.$private-is-internal-build,
rgba(if($is-dark, #fff, #000), 0.12),
inspection.get-theme-color($theme, foreground, divider)
);
@return (
disabled-outline-color: $outline,
disabled-label-text-color: inspection.get-theme-color($theme, foreground, disabled-button,
if($is-dark, 0.5, 0.38)),
label-text-color: inspection.get-theme-color($theme, foreground, text, 1),
outline-color: $outline,
);
}
// Generates the mapping for the properties that change based on the button palette color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
@return (
label-text-color: inspection.get-theme-color($theme, $palette-name, default),
// TODO: we shouldn't have to set this since it's the same as the non-palette version, however
// there are a bunch of tests internally that depend on it. We should remove this and clean
// up the screenshots separately.
outline-color: map.get(get-color-tokens($theme), outline-color),
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
label-text-font: inspection.get-theme-typography($theme, button, font-family),
label-text-size: inspection.get-theme-typography($theme, button, font-size),
label-text-tracking: inspection.get-theme-typography($theme, button, letter-spacing),
label-text-weight: inspection.get-theme-typography($theme, button, font-weight),
label-text-transform: none,
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
$scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
@return (
container-height:
map.get(
(
0: 36px,
-1: 32px,
-2: 28px,
-3: 24px,
),
$scale
)
);
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 4499,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_outlined-button.scss"
} |
components/src/material/core/tokens/m2/mdc/_elevated-card.scss_0_3037 | @use '../../../theming/inspection';
@use '../../../style/elevation';
@use '../../../style/sass-utils';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, elevated-card);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
// The border-radius of the card.
container-shape: 4px,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
// Angular Material's card is not an interactive element, and therefore does not support states.
disabled-container-color: null,
disabled-container-elevation: null,
disabled-container-opacity: null,
dragged-container-elevation: null,
dragged-state-layer-color: null,
dragged-state-layer-opacity: null,
focus-container-elevation: null,
focus-state-layer-color:null,
focus-state-layer-opacity: null,
hover-container-elevation: null,
hover-state-layer-color: null,
hover-state-layer-opacity: null,
pressed-container-elevation: null,
pressed-state-layer-color: null,
pressed-state-layer-opacity: null,
container-shadow-color: null,
// Angular Material does not currently support surface tint.
container-surface-tint-layer-color: null,
// MDC does not seem to use these tokens.
icon-color: null,
icon-size: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$elevation: inspection.get-theme-color($theme, foreground, elevation);
@return (
// The background color of the card.
container-color: inspection.get-theme-color($theme, background, card),
container-elevation: elevation.get-box-shadow(1),
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return ();
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 3037,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_elevated-card.scss"
} |
components/src/material/core/tokens/m2/mdc/_dialog.scss_0_4626 | @use '../../../theming/inspection';
@use '../../../style/sass-utils';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, dialog);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
// Border radius of the container.
container-shape: 4px,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
container-elevation: null,
container-shadow-color: null,
with-divider-divider-height: null,
with-divider-divider-color: null,
with-icon-icon-size: null,
with-icon-icon-color: null,
action-label-text-font: null,
action-label-text-line-height: null,
action-label-text-size: null,
action-label-text-weight: null,
action-label-text-tracking: null,
action-label-text-color: null,
action-hover-state-layer-color: null,
action-hover-state-layer-opacity: null,
action-hover-label-text-color: null,
action-focus-state-layer-color: null,
action-focus-state-layer-opacity: null,
action-focus-label-text-color: null,
action-pressed-state-layer-color: null,
action-pressed-state-layer-opacity: null,
action-pressed-label-text-color: null,
headline-color: null,
headline-font: null,
headline-line-height: null,
headline-size: null,
headline-tracking: null,
headline-weight: null,
z-index: null,
container-surface-tint-layer-color: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$is-dark: inspection.get-theme-type($theme) == dark;
// Ideally we would derive all values directly from the theme, but it causes a lot of regressions
// internally. For now we fall back to the old hardcoded behavior only for internal apps.
$text-base: if(token-definition.$private-is-internal-build,
if($is-dark, #fff, #000),
inspection.get-theme-color($theme, foreground, text, 1)
);
@return (
// Background color of the container.
container-color: inspection.get-theme-color($theme, background, dialog),
// Color of the dialog header.
subhead-color: sass-utils.safe-color-change($text-base, $alpha: 0.87),
// Color of the dialog body text.
supporting-text-color: sass-utils.safe-color-change($text-base, $alpha: 0.6),
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
// Typography of the dialog header.
subhead-font: inspection.get-theme-typography($theme, headline-6, font-family),
subhead-line-height: inspection.get-theme-typography($theme, headline-6, line-height),
subhead-size: inspection.get-theme-typography($theme, headline-6, font-size),
subhead-weight: inspection.get-theme-typography($theme, headline-6, font-weight),
subhead-tracking: inspection.get-theme-typography($theme, headline-6, letter-spacing),
// Typography of the dialog body text.
supporting-text-font: inspection.get-theme-typography($theme, body-1, font-family),
supporting-text-line-height: inspection.get-theme-typography($theme, body-1, line-height),
supporting-text-size: inspection.get-theme-typography($theme, body-1, font-size),
supporting-text-weight: inspection.get-theme-typography($theme, body-1, font-weight),
supporting-text-tracking: inspection.get-theme-typography($theme, body-1, letter-spacing),
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 4626,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_dialog.scss"
} |
components/src/material/core/tokens/m2/mdc/_linear-progress.scss_0_2112 | @use '../../../theming/inspection';
@use '../../../style/sass-utils';
@use '../../token-definition';
@use 'sass:color';
@use 'sass:meta';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, linear-progress);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
$height: 4px;
@return (
// The height of the progress bar. `active-indicator-height` applies to the
// bar and `track-height` applies to the track.
active-indicator-height: $height,
track-height: $height,
track-shape: 0,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme, $palette-name: primary) {
$palette-color: inspection.get-theme-color($theme, $palette-name);
@return (
// The color of the progress bar's active section.
active-indicator-color: $palette-color,
track-color: if(
meta.type-of($palette-color) == color,
color.adjust($palette-color, $alpha: -0.75),
$palette-color
)
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return ();
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 2112,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_linear-progress.scss"
} |
components/src/material/core/tokens/m2/mdc/_outlined-text-field.scss_0_6862 | @use 'sass:map';
@use '../../../theming/inspection';
@use '../../../style/sass-utils';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, outlined-text-field);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
outline-width: 1px,
focus-outline-width: 2px,
container-shape: 4px,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
error-focus-caret-color: null,
error-hover-caret-color: null,
focus-caret-color: null,
hover-caret-color: null,
disabled-outline-opacity: null,
hover-outline-width: null,
disabled-outline-width: null,
label-text-type: null,
label-text-populated-line-height: null,
label-text-populated-size: null,
disabled-label-text-opacity: null,
disabled-supporting-text-color: null,
disabled-supporting-text-opacity: null,
error-focus-supporting-text-color: null,
error-hover-supporting-text-color: null,
error-supporting-text-color: null,
focus-supporting-text-color: null,
hover-supporting-text-color: null,
supporting-text-color: null,
supporting-text-font: null,
supporting-text-line-height: null,
supporting-text-size: null,
supporting-text-tracking: null,
supporting-text-type: null,
supporting-text-weight: null,
leading-icon-size: null,
trailing-icon-size: null,
leading-icon-color: null,
disabled-leading-icon-color: null,
disabled-leading-icon-opacity: null,
error-focus-leading-icon-color: null,
error-hover-leading-icon-color: null,
error-leading-icon-color: null,
focus-leading-icon-color: null,
hover-leading-icon-color: null,
trailing-icon-color: null,
disabled-trailing-icon-color: null,
disabled-trailing-icon-opacity: null,
error-focus-trailing-icon-color: null,
error-hover-trailing-icon-color: null,
error-trailing-icon-color: null,
focus-trailing-icon-color: null,
hover-trailing-icon-color: null,
input-text-prefix-color: null,
input-text-type: null,
container-height: null,
input-text-suffix-color: null,
input-text-font: null,
input-text-line-height: null,
input-text-size: null,
input-text-tracking: null,
input-text-weight: null,
disabled-input-text-opacity: null,
error-focus-input-text-color: null,
error-hover-input-text-color: null,
error-input-text-color: null,
focus-input-text-color: null,
hover-input-text-color: null,
label-text-line-height: null, // We override the line height to `normal` so don't emit a slot.
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$is-dark: inspection.get-theme-type($theme) == dark;
$warn-color: inspection.get-theme-color($theme, warn);
$color-tokens: private-get-color-palette-color-tokens($theme, primary);
// Ideally we would derive all values directly from the theme, but it causes a lot of regressions
// internally. For now we fall back to the old hardcoded behavior only for internal apps.
$on-surface: if($is-dark, #fff, #000);
$text-color-base: if(token-definition.$private-is-internal-build, $on-surface,
inspection.get-theme-color($theme, foreground, text, 1));
$disabled-text-color-base: if(token-definition.$private-is-internal-build, $on-surface,
inspection.get-theme-color($theme, foreground, disabled-text, 1));
$divider-base: if(token-definition.$private-is-internal-build, $on-surface,
inspection.get-theme-color($theme, foreground, divider, 1));
@return map.merge($color-tokens, (
label-text-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.6),
hover-label-text-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.6),
disabled-label-text-color:
sass-utils.safe-color-change($disabled-text-color-base, $alpha: 0.38),
input-text-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.87),
disabled-input-text-color:
sass-utils.safe-color-change($disabled-text-color-base, $alpha: 0.38),
input-text-placeholder-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.6),
error-caret-color: $warn-color,
error-focus-label-text-color: $warn-color,
error-label-text-color: $warn-color,
error-hover-label-text-color: $warn-color,
// Outline tokens
outline-color: sass-utils.safe-color-change($divider-base, $alpha: 0.38),
disabled-outline-color: sass-utils.safe-color-change($divider-base, $alpha: 0.06),
hover-outline-color: sass-utils.safe-color-change($divider-base, $alpha: 0.87),
error-focus-outline-color: $warn-color,
error-hover-outline-color: $warn-color,
error-outline-color: $warn-color,
));
}
// Generates the mapping for the properties that change based on the text field color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
$palette-color: inspection.get-theme-color($theme, $palette-name);
@return (
caret-color: $palette-color,
focus-outline-color: $palette-color,
focus-label-text-color: sass-utils.safe-color-change($palette-color, $alpha: 0.87),
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
label-text-font: inspection.get-theme-typography($theme, body-1, font-family),
label-text-size: inspection.get-theme-typography($theme, body-1, font-size),
label-text-tracking: inspection.get-theme-typography($theme, body-1, letter-spacing),
label-text-weight: inspection.get-theme-typography($theme, body-1, font-weight),
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 6862,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_outlined-text-field.scss"
} |
components/src/material/core/tokens/m2/mdc/_filled-button.scss_0_4710 | @use 'sass:map';
@use '../../token-definition';
@use '../../../style/sass-utils';
@use '../../../theming/inspection';
@use '../../../theming/theming';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, filled-button);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
container-shape: 4px,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
focus-ring-color: null,
focus-ring-offset: null,
focus-state-layer-opacity: null,
hover-state-layer-opacity: null,
pressed-state-layer-opacity: null,
container-shadow-color: null,
container-elevation: null,
disabled-container-elevation: null,
focus-container-elevation: null,
hover-container-elevation: null,
keep-touch-target: false,
pressed-container-elevation: null,
focus-label-text-color: null,
hover-label-text-color: null,
pressed-label-text-color: null,
with-icon-disabled-icon-color: null,
with-icon-focus-icon-color: null,
with-icon-hover-icon-color: null,
with-icon-icon-color: null,
with-icon-icon-size: null,
with-icon-pressed-icon-color: null,
focus-state-layer-color: null,
hover-state-layer-color: null,
pressed-state-layer-color: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$is-dark: inspection.get-theme-type($theme) == dark;
@return (
container-color: inspection.get-theme-color($theme, background, card),
label-text-color: inspection.get-theme-color($theme, foreground, text, 1),
disabled-container-color: inspection.get-theme-color($theme, foreground, disabled-button,
0.12),
disabled-label-text-color: inspection.get-theme-color($theme, foreground, disabled-button,
if($is-dark, 0.5, 0.38)),
);
}
// Generates the mapping for the properties that change based on the button palette color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
$container-color: inspection.get-theme-color($theme, $palette-name, default);
$label-text-color: null;
// Ideally we would derive all values directly from the theme, but it causes a lot of regressions
// internally. For now we fall back to the old hardcoded behavior only for internal apps.
@if (token-definition.$private-is-internal-build) {
$is-dark: inspection.get-theme-type($theme) == dark;
$contrast-tone: token-definition.contrast-tone($container-color, $is-dark);
$label-text-color: if($contrast-tone == 'dark', #000, #fff);
}
@else {
$label-text-color: inspection.get-theme-color($theme, $palette-name, default-contrast, 1);
}
@return (
container-color: $container-color,
label-text-color: $label-text-color,
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
label-text-font: inspection.get-theme-typography($theme, button, font-family),
label-text-size: inspection.get-theme-typography($theme, button, font-size),
label-text-tracking: inspection.get-theme-typography($theme, button, letter-spacing),
label-text-weight: inspection.get-theme-typography($theme, button, font-weight),
label-text-transform: none,
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
$scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
@return (
container-height:
map.get(
(
0: 36px,
-1: 32px,
-2: 28px,
-3: 24px,
),
$scale
)
);
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 4710,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_filled-button.scss"
} |
components/src/material/core/tokens/m2/mdc/_list.scss_0_6897 | @use 'sass:map';
@use '../../../theming/inspection';
@use '../../../style/sass-utils';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, list);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
// Border radius of list items.
list-item-container-shape: 0,
// Border radius of the list item's leading avatar.
list-item-leading-avatar-shape: 50%,
// Background color of list items.
list-item-container-color: transparent,
// Background color of list items when selected.
list-item-selected-container-color: transparent,
// Background color of the list item's leading avatar.
list-item-leading-avatar-color: transparent,
// Height & width of the list item's leading icon.
list-item-leading-icon-size: 24px,
// Height & width of the list item's leading avatar.
list-item-leading-avatar-size: 40px,
// Height & width of the list item's trailing icon.
list-item-trailing-icon-size: 24px,
// Color of the list item's overlay when the item is disabled.
list-item-disabled-state-layer-color: transparent,
// Opacity of the list item's overlay when the item is disabled.
list-item-disabled-state-layer-opacity: 0,
// Opacity of the list item's primary & supporting text when the item is disabled.
list-item-disabled-label-text-opacity: 0.38,
// Opacity of the list item's leading icon when the item is disabled.
list-item-disabled-leading-icon-opacity: 0.38,
// Opacity of the list item's trailing icon when the item is disabled.
list-item-disabled-trailing-icon-opacity: 0.38,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
// Overline not implemented in Angular Material.
// TODO(mmalerba): Consider implementing in the future.
list-item-overline-color: null,
list-item-overline-font: null,
list-item-overline-line-height: null,
list-item-overline-size: null,
list-item-overline-tracking: null,
list-item-overline-weight: null,
// Leading video not implemented in Angular Material.
// TODO(mmalerba): Consider implementing in the future.
list-item-leading-video-shape: null,
list-item-leading-video-width: null,
list-item-leading-video-height: null,
// Leading image not implemented in Angular Material.
// TODO(mmalerba): Consider implementing in the future.
list-item-leading-image-width: null,
list-item-leading-image-height: null,
list-item-leading-image-shape: null,
// List divider is not implemented in Angular Material.
// TODO(mmalerba): Maybe mat-divider should be based on these tokens?
divider-color: null,
divider-height: null,
// Redundant since it is always overridden by one- two- or three- line tokens, omitted to save
// bytes.
list-item-container-height: null,
// MDC does not seem to emit any CSS variables for these tokens, may be use in the future.
// TODO(mmalerba): Discuss with MDC if these should be added.
list-item-container-elevation: null,
list-item-leading-avatar-label-color: null,
list-item-leading-avatar-label-font: null,
list-item-leading-avatar-label-line-height: null,
list-item-leading-avatar-label-size: null,
list-item-leading-avatar-label-tracking: null,
list-item-leading-avatar-label-weight: null,
list-item-unselected-trailing-icon-color: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$is-dark: inspection.get-theme-type($theme) == dark;
$foreground-base: inspection.get-theme-color($theme, foreground, base);
$foreground-text: inspection.get-theme-color($theme, foreground, text);
$foreground-secondary-text: inspection.get-theme-color($theme, foreground, secondary-text);
$foreground-hint-text: inspection.get-theme-color($theme, foreground, hint-text);
$text-icon-on-background: sass-utils.safe-color-change(
$foreground-base, $alpha: if($is-dark, 0.5, 0.38));
@return (
// Text color of the list item primary text.
list-item-label-text-color: $foreground-text,
// Text color of the list item supporting text.
list-item-supporting-text-color: $foreground-secondary-text,
// Color of the list item's leading icon.
list-item-leading-icon-color: $text-icon-on-background,
// Text color of the list item's trailing text.
list-item-trailing-supporting-text-color: $foreground-hint-text,
// Color of the list item's trailing icon.
list-item-trailing-icon-color: $text-icon-on-background,
// Color of the list item's trailing icon when the item is selected.
list-item-selected-trailing-icon-color: $text-icon-on-background,
// Text color of the list item's primary text when the item is disabled.
list-item-disabled-label-text-color: $foreground-base,
// Color of the list item's leading icon when the item is disabled.
list-item-disabled-leading-icon-color: $foreground-base,
// Color of the list item's trailing icon when the item is disabled.
list-item-disabled-trailing-icon-color: $foreground-base,
// Color of the list item's primary text when the item is being hovered.
list-item-hover-label-text-color: $foreground-text,
// Color of the list item's leading icon when the item is being hovered.
list-item-hover-leading-icon-color: $text-icon-on-background,
// Color of the list item's trailing icon when the item is being hovered.
list-item-hover-trailing-icon-color: $text-icon-on-background,
// Color of the list item's primary text when the item is focused.
list-item-focus-label-text-color: $foreground-text,
// Color of the list item's overlay when the item is hovered.
list-item-hover-state-layer-color: $foreground-base,
// Opacity of the list item's overlay when the item is hovered.
list-item-hover-state-layer-opacity: if($is-dark, 0.08, 0.04),
// Color of the list item's overlay when the item is focused.
list-item-focus-state-layer-color: $foreground-base,
// Opacity of the list item's overlay when the item is focused.
list-item-focus-state-layer-opacity: if($is-dark, 0.24, 0.12),
);
}
// Tokens that can be configured through Angular Material's typography theming API. | {
"end_byte": 6897,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_list.scss"
} |
components/src/material/core/tokens/m2/mdc/_list.scss_6898_10600 | @function get-typography-tokens($theme) {
@return (
// Font family of the list item primary text.
list-item-label-text-font: inspection.get-theme-typography($theme, body-1, font-family),
// Line height of the list item primary text.
list-item-label-text-line-height: inspection.get-theme-typography($theme, body-1, line-height),
// Font size of the list item primary text.
list-item-label-text-size: inspection.get-theme-typography($theme, body-1, font-size),
// Letter spacing of the list item primary text.
list-item-label-text-tracking: inspection.get-theme-typography($theme, body-1, letter-spacing),
// Font weight of the list item primary text.
list-item-label-text-weight: inspection.get-theme-typography($theme, body-1, font-weight),
// Font family of the list item supporting text.
list-item-supporting-text-font: inspection.get-theme-typography($theme, body-2, font-family),
// Line height of the list item supporting text.
list-item-supporting-text-line-height:inspection.get-theme-typography(
$theme, body-2, line-height),
// Font size of the list item supporting text.
list-item-supporting-text-size: inspection.get-theme-typography($theme, body-2, font-size),
// Letter spacing of the list item supporting text.
list-item-supporting-text-tracking: inspection.get-theme-typography(
$theme, body-2, letter-spacing),
// Font weight of the list item supporting text.
list-item-supporting-text-weight: inspection.get-theme-typography($theme, body-2, font-weight),
// Font family of the list item's trailing text.
list-item-trailing-supporting-text-font: inspection.get-theme-typography(
$theme, caption, font-family),
// Line height of the list item's trailing text.
list-item-trailing-supporting-text-line-height: inspection.get-theme-typography(
$theme, caption, line-height),
// Font size of the list item's trailing text.
list-item-trailing-supporting-text-size: inspection.get-theme-typography(
$theme, caption, font-size),
// Letter spacing color of the list item's trailing text.
list-item-trailing-supporting-text-tracking: inspection.get-theme-typography(
$theme, caption, letter-spacing),
// Font weight of the list item's trailing text.
list-item-trailing-supporting-text-weight: inspection.get-theme-typography(
$theme, caption, font-weight),
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
$scale: inspection.get-theme-density($theme);
@return (
// Height of one line list items.
list-item-one-line-container-height: map.get((
0: 48px,
-1: 44px,
-2: 40px,
-3: 36px,
-4: 32px,
-5: 24px,
), $scale),
// Height of two line list items.
list-item-two-line-container-height: map.get((
0: 64px,
-1: 60px,
-2: 56px,
-3: 52px,
-4: 48px,
-5: 48px,
), $scale),
// Height of three line list items.
list-item-three-line-container-height: map.get((
0: 88px,
-1: 84px,
-2: 80px,
-3: 76px,
-4: 72px,
-5: 56px,
), $scale),
);
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
} | {
"end_byte": 10600,
"start_byte": 6898,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_list.scss"
} |
components/src/material/core/tokens/m2/mdc/_snack-bar.scss_0_3844 | @use 'sass:meta';
@use 'sass:color';
@use '../../../theming/inspection';
@use '../../token-definition';
@use '../../../style/sass-utils';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, snackbar);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
// Sets the snack bar border radius.
container-shape: 4px,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
// Removed to match the previous appearance.
supporting-text-tracking: null,
// Excluded because they target the wrong DOM node. See the
// comments on the elevation of `.mat-mdc-snack-bar-container`.
container-elevation: null,
container-shadow-color: null,
action-focus-label-text-color: null,
action-focus-state-layer-color: null,
action-focus-state-layer-opacity: null,
action-hover-label-text-color: null,
action-hover-state-layer-color: null,
action-hover-state-layer-opacity: null,
action-label-text-color: null,
action-label-text-font: null,
action-label-text-size: null,
action-label-text-tracking: null,
action-label-text-weight: null,
action-pressed-label-text-color: null,
action-pressed-state-layer-color: null,
action-pressed-state-layer-opacity: null,
icon-color: null,
icon-focus-icon-color: null,
icon-focus-state-layer-color: null,
icon-focus-state-layer-opacity: null,
icon-hover-icon-color: null,
icon-hover-state-layer-color: null,
icon-hover-state-layer-opacity: null,
icon-pressed-icon-color: null,
icon-pressed-state-layer-color: null,
icon-pressed-state-layer-opacity: null,
icon-size: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$is-dark: inspection.get-theme-type($theme) == dark;
$surface: inspection.get-theme-color($theme, background, card);
@return (
container-color: if(meta.type-of($surface) == color,
color.mix(if($is-dark, #fff, #000), $surface, 80%), $surface),
supporting-text-color: if(meta.type-of($surface) == color, rgba($surface, 0.87), $surface)
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
supporting-text-font: inspection.get-theme-typography($theme, body-2, font-family),
supporting-text-line-height: inspection.get-theme-typography($theme, body-2, line-height),
supporting-text-size: inspection.get-theme-typography($theme, body-2, font-size),
supporting-text-weight: inspection.get-theme-typography($theme, body-2, font-weight),
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 3844,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_snack-bar.scss"
} |
components/src/material/core/tokens/m2/mdc/_secondary-navigation-tab.scss_0_3200 | @use 'sass:map';
@use '../../../theming/theming';
@use '../../../theming/inspection';
@use '../../../style/sass-utils';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, secondary-navigation-tab);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
// This is specified both here and in the density tokens, because it determines the size of the
// tab itself and there are internal tests who don't configure the theme correctly.
container-height: 48px,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
inactive-label-text-color: null,
active-label-text-color: null,
container-color: null,
container-elevation: null,
container-shadow-color: null,
container-shape: null,
focus-label-text-color: null,
focus-state-layer-color: null,
focus-state-layer-opacity: null,
hover-label-text-color: null,
hover-state-layer-color: null,
hover-state-layer-opacity: null,
pressed-label-text-color: null,
pressed-state-layer-color: null,
pressed-state-layer-opacity: null,
with-icon-active-icon-color: null,
with-icon-focus-icon-color: null,
with-icon-hover-icon-color: null,
with-icon-inactive-icon-color: null,
with-icon-pressed-icon-color: null,
with-icon-icon-size: null,
label-text-font: null,
label-text-size: null,
label-text-letter-spacing: null,
label-text-line-height: null,
label-text-weight: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme, $palette-name: primary) {
@return ();
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return ();
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
$scale: theming.clamp-density(inspection.get-theme-density($theme), -4);
@return (
container-height: map.get((
0: 48px,
-1: 44px,
-2: 40px,
-3: 36px,
-4: 32px,
), $scale),
);
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 3200,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_secondary-navigation-tab.scss"
} |
components/src/material/core/tokens/m2/mdc/_slider.scss_0_5811 | @use 'sass:map';
@use '../../../theming/inspection';
@use '../../token-definition';
@use '../../../style/elevation';
@use '../../../style/sass-utils';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, slider);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
// Height of active track.
active-track-height: 6px,
// Border radius of active track.
active-track-shape: 9999px,
// Height of handle.
handle-height: 20px,
// Border radius of handle.
handle-shape: 50%,
// Width of handle.
handle-width: 20px,
// Height of inactive track.
inactive-track-height: 4px,
// Border radius of inactive track.
inactive-track-shape: 9999px,
// Width of handle when overlapping with another handle below it.
with-overlap-handle-outline-width: 1px,
// Opacity of active container with tick marks.
with-tick-marks-active-container-opacity: 0.6,
// Border radius of container with tick marks.
with-tick-marks-container-shape: 50%,
// Size of container with tick marks.
with-tick-marks-container-size: 2px,
// Opacity of inactive container with tick marks.
with-tick-marks-inactive-container-opacity: 0.6,
// Elevation for the handle.
handle-elevation: elevation.get-box-shadow(1),
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
disabled-handle-elevation: null,
label-container-elevation: null,
label-container-height: null,
track-elevation: null,
focus-state-layer-opacity: null,
hover-state-layer-opacity: null,
pressed-state-layer-opacity: null,
handle-shadow-color: null,
// MDC does not seem to use these tokens.
hover-state-layer-color: null,
pressed-handle-color: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$elevation: inspection.get-theme-color($theme, foreground, elevation);
$is-dark: inspection.get-theme-type($theme) == dark;
$on-surface: if($is-dark, #fff, #000);
// The default for tokens that rely on the theme will use the primary palette
$theme-color-tokens: private-get-color-palette-color-tokens($theme, primary);
@return map.merge(
$theme-color-tokens,
(
// Color of active track when disabled.
disabled-active-track-color: $on-surface,
// Color of handle when disabled.
disabled-handle-color: $on-surface,
// Color of inactive track when disabled.
disabled-inactive-track-color: $on-surface,
// Color of container label.
label-container-color: $on-surface,
// Color of label text.
label-label-text-color: if($is-dark, #000, #fff),
// Color of handle outline when overlapping with another handle below it.
with-overlap-handle-outline-color: #fff,
// Color of container with tick marks when disabled.
with-tick-marks-disabled-container-color: $on-surface,
)
);
}
// Generates tokens for the slider properties that change based on the theme.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
$color: inspection.get-theme-color($theme, $palette-name);
$on-color: inspection.get-theme-color($theme, $palette-name, default-contrast);
@return (
// Color of handle.
handle-color: $color,
// Color of handle when focused.
focus-handle-color: $color,
// Color of handle on hover.
hover-handle-color: $color,
// Color of handle when active.
active-track-color: $color,
// Color of inactive track.
inactive-track-color: $color,
// Color of inactive container with tick marks.
with-tick-marks-inactive-container-color: $color,
// Color of active container with tick marks.
with-tick-marks-active-container-color: $on-color,
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
// Font for label text.
label-label-text-font: inspection.get-theme-typography($theme, subtitle-2, font-family),
// Font size of label text.
label-label-text-size: inspection.get-theme-typography($theme, subtitle-2, font-size),
// Line height of label text.
label-label-text-line-height: inspection.get-theme-typography($theme, subtitle-2, line-height),
// Letter spacing of label text.
label-label-text-tracking: inspection.get-theme-typography($theme, subtitle-2, letter-spacing),
// Font weight of label text.
label-label-text-weight: inspection.get-theme-typography($theme, subtitle-2, font-weight),
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 5811,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_slider.scss"
} |
components/src/material/core/tokens/m2/mdc/_fab-small.scss_0_3051 | @use 'sass:map';
@use '../../../theming/inspection';
@use '../../../style/elevation';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, fab-small);
@function get-unthemable-tokens() {
@return (
container-shape: 50%,
container-elevation-shadow: elevation.get-box-shadow(6),
focus-container-elevation-shadow: elevation.get-box-shadow(8),
hover-container-elevation-shadow: elevation.get-box-shadow(8),
pressed-container-elevation-shadow: elevation.get-box-shadow(12),
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
container-height: null,
container-width: null,
icon-size: null,
icon-color: null,
focus-icon-color: null,
focus-outline-color: null,
focus-outline-width: null,
focus-state-layer-color: null,
focus-state-layer-opacity: null,
hover-icon-color: null,
hover-state-layer-color: null,
hover-state-layer-opacity: null,
lowered-container-elevation: null,
lowered-focus-container-elevation: null,
lowered-hover-container-elevation: null,
lowered-pressed-container-elevation: null,
pressed-icon-color: null,
pressed-ripple-color: null,
pressed-ripple-opacity: null,
pressed-state-layer-color: null,
pressed-state-layer-opacity: null,
container-elevation: null,
focus-container-elevation: null,
hover-container-elevation: null,
pressed-container-elevation: null,
container-shadow-color: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
@return (
// Background color of the FAB.
container-color: inspection.get-theme-color($theme, background, card),
);
}
// Generates the mapping for the properties that change based on the FAB palette color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
@return (
container-color: inspection.get-theme-color($theme, $palette-name, default),
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return ();
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return map.merge(
get-unthemable-tokens(),
map.merge(
get-color-tokens(token-definition.$placeholder-color-config),
map.merge(
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
)
)
);
}
| {
"end_byte": 3051,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_fab-small.scss"
} |
components/src/material/core/tokens/m2/mdc/_circular-progress.scss_0_2558 | @use '../../../theming/inspection';
@use '../../../style/sass-utils';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, circular-progress);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
// The thickness of the progress spinner's active indicator.
active-indicator-width: 4px,
// The diameter of the spinner
size: 48px,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
// Angular Material does not support four color spinners
four-color-active-indicator-one-color: null,
// Angular Material does not support four color spinners
four-color-active-indicator-two-color: null,
// Angular Material does not support four color spinners
four-color-active-indicator-three-color: null,
// Angular Material does not support four color spinners
four-color-active-indicator-four-color: null
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme, $palette-name: primary) {
@return (
// The color of the progress spinner's active indicator.
active-indicator-color: inspection.get-theme-color($theme, $palette-name)
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return ();
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 2558,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_circular-progress.scss"
} |
components/src/material/core/tokens/m2/mdc/_icon-button.scss_0_3163 | @use 'sass:map';
@use '../../../style/sass-utils';
@use '../../../theming/theming';
@use '../../../theming/inspection';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, icon-button);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
// MDC's icon size applied to svg and img elements inside the component
icon-size: 24px,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
// State layer is unused
focus-icon-color: null,
focus-state-layer-color: null,
focus-state-layer-opacity: null,
hover-icon-color: null,
hover-state-layer-color: null,
hover-state-layer-opacity: null,
pressed-icon-color: null,
pressed-state-layer-color: null,
pressed-state-layer-opacity: null,
focus-ring-color: null,
focus-ring-offset: null,
// We use a color with an opacity to show the disabled state,
// instead of applying it to the entire button.
disabled-icon-opacity: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$is-dark: inspection.get-theme-type($theme) == dark;
@return (
icon-color: inherit,
disabled-icon-color: if($is-dark, rgba(#fff, 0.5), rgba(#000, 0.38)),
);
}
// Generates the mapping for the properties that change based on the button palette color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
@return (
icon-color: inspection.get-theme-color($theme, $palette-name)
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return ();
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
$scale: theming.clamp-density(inspection.get-theme-density($theme), -5);
@return (
// The diameter of the checkbox's ripple.
state-layer-size: map.get((
0: 48px,
-1: 44px,
-2: 40px,
-3: 36px,
-4: 32px,
-5: 28px,
), $scale)
);
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 3163,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_icon-button.scss"
} |
components/src/material/core/tokens/m2/mdc/_plain-tooltip.scss_0_2452 | @use '../../../theming/inspection';
@use '../../../style/sass-utils';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, plain-tooltip);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
// Border radius for the tooltip container.
container-shape: 4px,
// Line height of the tooltip text.
supporting-text-line-height: 16px,
// MDC does not seem to use these token.
supporting-text-type: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
@return (
// Color of the tooltip container.
container-color: inspection.get-theme-color($theme, background, tooltip),
// Color of the tooltip text.
supporting-text-color: #fff,
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
// Font for the tooltip text.
supporting-text-font: inspection.get-theme-typography($theme, caption, font-family),
// Font size for the tooltip text.
supporting-text-size: inspection.get-theme-typography($theme, caption, font-size),
// Font weight of the tooltip text.
supporting-text-weight: inspection.get-theme-typography($theme, caption, font-weight),
// Tracking (space between letters) of the tooltip text.
supporting-text-tracking: inspection.get-theme-typography($theme, caption, letter-spacing),
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 2452,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_plain-tooltip.scss"
} |
components/src/material/core/tokens/m2/mdc/_fab.scss_0_3091 | @use 'sass:map';
@use '../../../theming/inspection';
@use '../../../style/elevation';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, fab);
@function get-unthemable-tokens() {
@return (
container-shape: 50%,
container-elevation-shadow: elevation.get-box-shadow(6),
focus-container-elevation-shadow: elevation.get-box-shadow(8),
hover-container-elevation-shadow: elevation.get-box-shadow(8),
pressed-container-elevation-shadow: elevation.get-box-shadow(12),
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
container-height: null,
container-surface-tint-layer-color: null,
container-width: null,
icon-size: null,
icon-color: null,
focus-icon-color: null,
focus-outline-color: null,
focus-outline-width: null,
focus-state-layer-color: null,
focus-state-layer-opacity: null,
hover-icon-color: null,
hover-state-layer-color: null,
hover-state-layer-opacity: null,
lowered-container-elevation: null,
lowered-focus-container-elevation: null,
lowered-hover-container-elevation: null,
lowered-pressed-container-elevation: null,
pressed-icon-color: null,
pressed-ripple-color: null,
pressed-ripple-opacity: null,
pressed-state-layer-color: null,
pressed-state-layer-opacity: null,
container-elevation: null,
focus-container-elevation: null,
hover-container-elevation: null,
pressed-container-elevation: null,
container-shadow-color: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
@return (
// Background color of the FAB.
container-color: inspection.get-theme-color($theme, background, card),
);
}
// Generates the mapping for the properties that change based on the FAB palette color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
@return (
container-color: inspection.get-theme-color($theme, $palette-name, default),
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return ();
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return map.merge(
get-unthemable-tokens(),
map.merge(
get-color-tokens(token-definition.$placeholder-color-config),
map.merge(
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
)
)
);
}
| {
"end_byte": 3091,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_fab.scss"
} |
components/src/material/core/tokens/m2/mdc/_switch.scss_0_7938 | @use 'sass:map';
@use '../../../style/elevation';
@use '../../../style/sass-utils';
@use '../../../theming/inspection';
@use '../../../theming/theming';
@use '../../token-definition';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, switch);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
// Opacity of handle when disabled.
disabled-handle-opacity: null,
// Opacity of icon when disabled and selected.
disabled-selected-icon-opacity: 0.38,
// Opacity of track when disabled.
disabled-track-opacity: 0.12,
// Opacity of icon when disabled and unselected.
disabled-unselected-icon-opacity: 0.38,
// Height of handle.
handle-height: 20px,
// Border radius of handle.
handle-shape: 10px,
// Width of handle.
handle-width: 20px,
// Width and height of icon when selected.
selected-icon-size: 18px,
// Height of track.
track-height: 14px,
// Border radius of track.
track-shape: 7px,
// Width of track.
track-width: 36px,
// Width and height of icon when unselected.
unselected-icon-size: 18px,
// Opacity of ripple when selected and focused.
selected-focus-state-layer-opacity: 0.12,
// Opacity of ripple when selected and on hover.
selected-hover-state-layer-opacity: 0.04,
// Opacity of ripple when selected and pressed.
selected-pressed-state-layer-opacity: 0.1,
// Opacity of ripple when unselected and focused.
unselected-focus-state-layer-opacity: 0.12,
// Opacity of ripple when unselected and on hover.
unselected-hover-state-layer-opacity: 0.04,
// Opacity of ripple when unselected and pressed.
unselected-pressed-state-layer-opacity: 0.1,
// Unused tokens
handle-elevation: null,
handle-shadow-color: null,
disabled-handle-elevation: null,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$is-dark: inspection.get-theme-type($theme) == dark;
$on-surface: if($is-dark, #f5f5f5, #424242);
$hairline: if($is-dark, #616161, #e0e0e0);
$on-surface-variant: if($is-dark, #9e9e9e, #616161);
$on-surface-state-content: if($is-dark, #fafafa, #212121);
$disabled-handle-color: if($is-dark, #000, #424242);
$icon-color: if($is-dark, #212121, #fff);
// The default for tokens that rely on the theme will use the primary palette
$theme-color-tokens: private-get-color-palette-color-tokens($theme, primary);
@return map.merge(
$theme-color-tokens,
(
// Color of handle when selected while disabled.
disabled-selected-handle-color: $disabled-handle-color,
// Color of handle when selected while disabled.
disabled-selected-icon-color: $icon-color,
// Color of track when selected while disabled.
disabled-selected-track-color: $on-surface,
// Color of handle when unselected while disabled.
disabled-unselected-handle-color: $disabled-handle-color,
// Color of icon when unselected while disabled.
disabled-unselected-icon-color: $icon-color,
// Color of track when disabled.
disabled-unselected-track-color: $on-surface,
// TODO(crisbeto): `handle-surface-color` was hardcoded to `var(--mdc-surface-color, #fff)`
// which made it basically hardcoded to #fff. Should it be based on the theme?
// Color of slide-toggle handle's surface.
handle-surface-color: #fff,
// Color of icon (ex. checkmark) when selected
selected-icon-color: $icon-color,
// Color of handle when unselected and focused.
unselected-focus-handle-color: $on-surface-state-content,
// Color of ripple when unselected and focused.
unselected-focus-state-layer-color: $on-surface,
// Color of track when unselected and focused.
unselected-focus-track-color: $hairline,
// Color of handle when unselected.
unselected-handle-color: $on-surface-variant,
// Color of handle when unselected and on hover.
unselected-hover-handle-color: $on-surface-state-content,
// Color of ripple when unselected and on hover.
unselected-hover-state-layer-color: $on-surface,
// Color of track when unselected and on hover.
unselected-hover-track-color: $hairline,
// Color of icon color when unselected.
unselected-icon-color: $icon-color,
// Color of handle when unselected and pressed.
unselected-pressed-handle-color: $on-surface-state-content,
// Color of ripple when unselected and pressed.
unselected-pressed-state-layer-color: $on-surface,
// Color of track when unselected and pressed.
unselected-pressed-track-color: $hairline,
// Color of track when selected.
unselected-track-color: $hairline,
// Elevation level for handle.
handle-elevation-shadow: elevation.get-box-shadow(1),
// Elevation level for handle when disabled.
disabled-handle-elevation-shadow: elevation.get-box-shadow(0),
)
);
}
// Generates the mapping for the properties that change based on the slide toggle color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
$is-dark: inspection.get-theme-type($theme) == dark;
$palette-color: inspection.get-theme-color($theme, $palette-name, if($is-dark, 300, 600));
$state-content: inspection.get-theme-color($theme, $palette-name, if($is-dark, 200, 900));
$inverse: inspection.get-theme-color($theme, $palette-name, if($is-dark, 600, 300));
@return (
// Color of ripple when selected and focused.
selected-focus-state-layer-color: $palette-color,
// Color of handle when selected
selected-handle-color: $palette-color,
// Color of ripple when selected and on hover.
selected-hover-state-layer-color: $palette-color,
// Color of ripple when selected and pressed.
selected-pressed-state-layer-color: $palette-color,
// Color of handle when selected and focused.
selected-focus-handle-color: $state-content,
// Color of handle when selected and on hover.
selected-hover-handle-color: $state-content,
// Color of handle when selected and pressed.
selected-pressed-handle-color: $state-content,
// Color of track when selected and focused.
selected-focus-track-color: $inverse,
// Color of track when selected and on hover.
selected-hover-track-color: $inverse,
/// Color of track when selected and pressed.
selected-pressed-track-color: $inverse,
// Color of track when selected.
selected-track-color: $inverse,
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return ();
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
$scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
@return (
// The diameter of the handle ripple.
state-layer-size: map.get((
0: 40px,
-1: 36px,
-2: 32px,
-3: 28px,
), $scale)
);
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 7938,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mdc/_switch.scss"
} |
components/src/material/core/tokens/m2/mat/_tab-header.scss_0_3268 | @use '../../token-definition';
@use '../../../theming/inspection';
@use '../../../style/sass-utils';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mat, tab-header);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
@function get-unthemable-tokens() {
@return (
// For some period of time, the MDC tabs removed the divider. This has been added back in
// and will be present in M3.
divider-color: transparent,
divider-height: 0,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme, $palette-name: primary) {
$is-dark: inspection.get-theme-type($theme) == dark;
$inactive-label-text-color: inspection.get-theme-color($theme, foreground, text, 0.6);
$active-label-text-color: inspection.get-theme-color($theme, $palette-name, default);
$ripple-color: inspection.get-theme-color($theme, $palette-name, default);
@return (
disabled-ripple-color: inspection.get-theme-color($theme, foreground, disabled),
pagination-icon-color: inspection.get-theme-color($theme, foreground, icon, 1),
// Note: MDC has equivalents of these tokens, but they lead to much higher selector specificity.
inactive-label-text-color: $inactive-label-text-color,
active-label-text-color: $active-label-text-color,
// Tokens needed to implement the gmat styles. Externally they don't change.
active-ripple-color: $ripple-color,
inactive-ripple-color: $ripple-color,
inactive-focus-label-text-color: $inactive-label-text-color,
inactive-hover-label-text-color: $inactive-label-text-color,
active-focus-label-text-color: $active-label-text-color,
active-hover-label-text-color: $active-label-text-color,
active-focus-indicator-color: $active-label-text-color,
active-hover-indicator-color: $active-label-text-color,
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
// Note: MDC has equivalents of these tokens, but they lead to much higher selector specificity.
label-text-font: inspection.get-theme-typography($theme, button, font-family),
label-text-size: inspection.get-theme-typography($theme, button, font-size),
label-text-tracking: inspection.get-theme-typography($theme, button, letter-spacing),
label-text-line-height: inspection.get-theme-typography($theme, button, line-height),
label-text-weight: inspection.get-theme-typography($theme, button, font-weight),
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 3268,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mat/_tab-header.scss"
} |
components/src/material/core/tokens/m2/mat/_optgroup.scss_0_1783 | @use '../../token-definition';
@use '../../../theming/inspection';
@use '../../../style/sass-utils';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mat, optgroup);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
@function get-unthemable-tokens() {
@return ();
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
@return (
label-text-color: inspection.get-theme-color($theme, foreground, text),
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
label-text-font: inspection.get-theme-typography($theme, body-1, font-family),
label-text-line-height: inspection.get-theme-typography($theme, body-1, line-height),
label-text-size: inspection.get-theme-typography($theme, body-1, font-size),
label-text-tracking: inspection.get-theme-typography($theme, body-1, letter-spacing),
label-text-weight: inspection.get-theme-typography($theme, body-1, font-weight)
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 1783,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mat/_optgroup.scss"
} |
components/src/material/core/tokens/m2/mat/_select.scss_0_3652 | @use 'sass:map';
@use '../../token-definition';
@use '../../../theming/inspection';
@use '../../../theming/theming';
@use '../../../style/elevation';
@use '../../../style/sass-utils';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mat, select);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
@function get-unthemable-tokens() {
@return (
container-elevation-shadow: elevation.get-box-shadow(8),
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme, $palette-name: primary) {
$is-dark: inspection.get-theme-type($theme) == dark;
// Ideally we would derive all values directly from the theme, but it causes a lot of regressions
// internally. For now we fall back to the old hardcoded behavior only for internal apps.
$on-surface: if($is-dark, #fff, #000);
$text-color-base: if(token-definition.$private-is-internal-build, $on-surface,
inspection.get-theme-color($theme, foreground, text, 1));
$disabled-text-color-base: if(token-definition.$private-is-internal-build, $on-surface,
inspection.get-theme-color($theme, foreground, disabled-text, 1));
$icon-color-base: if(token-definition.$private-is-internal-build, $on-surface,
inspection.get-theme-color($theme, foreground, divider, 1));
@return (
panel-background-color: inspection.get-theme-color($theme, background, card),
enabled-trigger-text-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.87),
disabled-trigger-text-color:
sass-utils.safe-color-change($disabled-text-color-base, $alpha: 0.38),
placeholder-text-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.6),
enabled-arrow-color: sass-utils.safe-color-change($icon-color-base, $alpha: 0.54),
disabled-arrow-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.38),
focused-arrow-color: sass-utils.safe-color-change(
inspection.get-theme-color($theme, $palette-name, default), $alpha: 0.87),
invalid-arrow-color: sass-utils.safe-color-change(
inspection.get-theme-color($theme, warn, default), $alpha: 0.87),
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
trigger-text-font: inspection.get-theme-typography($theme, body-1, font-family),
trigger-text-line-height: inspection.get-theme-typography($theme, body-1, line-height),
trigger-text-size: inspection.get-theme-typography($theme, body-1, font-size),
trigger-text-tracking: inspection.get-theme-typography($theme, body-1, letter-spacing),
trigger-text-weight: inspection.get-theme-typography($theme, body-1, font-weight)
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
$density-scale: theming.clamp-density(inspection.get-theme-density($theme), -2);
@return (
arrow-transform: map.get((
0: translateY(-8px),
-1: translateY(-8px),
-2: none,
), $density-scale),
);
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-definition.$placeholder-color-config),
get-typography-tokens(token-definition.$placeholder-typography-config),
get-density-tokens(token-definition.$placeholder-density-config)
);
}
| {
"end_byte": 3652,
"start_byte": 0,
"url": "https://github.com/angular/components/blob/main/src/material/core/tokens/m2/mat/_select.scss"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.