UNPKG

3.45 kBSCSSView Raw
1@use 'sass:map';
2@use 'theming/theming';
3@use './style/private';
4@use './ripple/ripple-theme';
5@use './option/option-theme';
6@use './option/optgroup-theme';
7@use './selection/pseudo-checkbox/pseudo-checkbox-theme';
8@use './style/elevation';
9@use './typography/typography';
10
11@mixin color($config-or-theme) {
12 $config: theming.get-color-config($config-or-theme);
13
14 @include ripple-theme.color($config);
15 @include option-theme.color($config);
16 @include optgroup-theme.color($config);
17 @include pseudo-checkbox-theme.color($config);
18
19 // Wrapper element that provides the theme background when the user's content isn't
20 // inside of a `mat-sidenav-container`. Note that we need to exclude the ampersand
21 // selector in case the mixin is included at the top level.
22 .mat-app-background#{if(&, ', &.mat-app-background', '')} {
23 $background: map.get($config, background);
24 $foreground: map.get($config, foreground);
25
26 background-color: theming.get-color-from-palette($background, background);
27 color: theming.get-color-from-palette($foreground, text);
28 }
29
30 // Provides external CSS classes for each elevation value. Each CSS class is formatted as
31 // `mat-elevation-z$zValue` where `$zValue` corresponds to the z-space to which the element is
32 // elevated.
33 @for $zValue from 0 through 24 {
34 $selector: elevation.$prefix + $zValue;
35 // We need the `mat-mdc-elevation-specific`, because some MDC mixins
36 // come with elevation baked in and we don't have a way of removing it.
37 .#{$selector}, .mat-mdc-elevation-specific.#{$selector} {
38 @include private.private-theme-elevation($zValue, $config);
39 }
40 }
41
42 // Marker that is used to determine whether the user has added a theme to their page.
43 @at-root {
44 .mat-theme-loaded-marker {
45 display: none;
46 }
47 }
48}
49
50@mixin typography($config-or-theme) {
51 $config: typography.private-typography-to-2018-config(
52 theming.get-typography-config($config-or-theme));
53
54 @include option-theme.typography($config);
55 @include optgroup-theme.typography($config);
56 @include pseudo-checkbox-theme.typography($config);
57 // TODO(mmalerba): add typography mixin for this.
58 // @include ripple-theme.typography($config);
59}
60
61@mixin density($config-or-theme) {
62 $density-scale: theming.get-density-config($config-or-theme);
63
64 @include option-theme.density($density-scale);
65 @include optgroup-theme.density($density-scale);
66 // TODO(mmalerba): add density mixins for these.
67 // @include ripple-theme.density($density-scale);
68 // @include pseudo-checkbox-theme.density($density-scale);
69}
70
71// Mixin that renders all of the core styles that depend on the theme.
72@mixin theme($theme-or-color-config) {
73 $theme: theming.private-legacy-get-theme($theme-or-color-config);
74 // Wrap the sub-theme includes in the duplicate theme styles mixin. This ensures that
75 // there won't be multiple warnings. e.g. if `mat-core-theme` reports a warning, then
76 // the imported themes (such as `mat-ripple-theme`) should not report again.
77 @include theming.private-check-duplicate-theme-styles($theme, 'mat-core') {
78 $color: theming.get-color-config($theme);
79 $density: theming.get-density-config($theme);
80 $typography: theming.get-typography-config($theme);
81
82 @if $color != null {
83 @include color($color);
84 }
85 @if $density != null {
86 @include density($density);
87 }
88 @if $typography != null {
89 @include typography($typography);
90 }
91 }
92}