Skip to content

Commit 723b77a

Browse files
authoredDec 9, 2021
feat(material-experimental/mdc-core): add missing color, density, typography mixins (#24063)
1 parent 0d3a730 commit 723b77a

File tree

2 files changed

+49
-15
lines changed

2 files changed

+49
-15
lines changed
 

‎src/material-experimental/_index.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
popover-edit-typography, popover-edit-density, popover-edit-theme;
1717

1818
// MDC-related themes
19-
@forward './mdc-core/core-theme' as mdc-core-* show mdc-core-theme;
19+
@forward './mdc-core/core-theme' as mdc-core-* show mdc-core-theme, mdc-core-color,
20+
mdc-core-density, mdc-core-typography;
2021
@forward './mdc-helpers/focus-indicators-theme' as mdc-strong-focus-indicators-* show
2122
mdc-strong-focus-indicators-color, mdc-strong-focus-indicators-theme;
2223
@forward './mdc-core/option/option-theme' as mdc-option-* show mdc-option-color,
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,46 @@
11
@use '../../material/core/theming/theming';
2+
@use '../../material/core/typography/typography';
23
@use './option/option-theme';
34
@use './option/optgroup-theme';
45
@use './elevation';
56

7+
8+
@mixin color($config-or-theme) {
9+
$config: theming.get-color-config($config-or-theme);
10+
11+
@include option-theme.color($config);
12+
@include optgroup-theme.color($config);
13+
14+
@if $config != null {
15+
// Provides external CSS classes for each elevation value. Each CSS class is formatted as
16+
// `mat-mdc-elevation-z$zValue` where `$zValue` corresponds to the z-space to which the
17+
// element is elevated.
18+
@for $zValue from 0 through 24 {
19+
$selector: elevation.$prefix + $zValue;
20+
// We need the `mat-mdc-elevation-specific`, because some MDC mixins
21+
// come with elevation baked in and we don't have a way of removing it.
22+
.#{$selector}, .mat-mdc-elevation-specific.#{$selector} {
23+
@include elevation.private-theme-elevation($zValue, $config);
24+
}
25+
}
26+
}
27+
}
28+
29+
@mixin typography($config-or-theme) {
30+
$config: typography.private-typography-to-2018-config(
31+
theming.get-typography-config($config-or-theme));
32+
33+
@include option-theme.typography($config-or-theme);
34+
@include optgroup-theme.typography($config-or-theme);
35+
}
36+
37+
@mixin density($config-or-theme) {
38+
$density-scale: theming.get-density-config($config-or-theme);
39+
40+
@include option-theme.density($density-scale);
41+
@include optgroup-theme.density($density-scale);
42+
}
43+
644
// Mixin that renders all of the core styles that depend on the theme.
745
@mixin theme($theme-or-color-config) {
846
$theme: theming.private-legacy-get-theme($theme-or-color-config);
@@ -12,22 +50,17 @@
1250
// the imported themes (such as `mat-ripple-theme`) should not report again.
1351
@include theming.private-check-duplicate-theme-styles($theme, 'mat-mdc-core') {
1452
$color: theming.get-color-config($theme);
15-
16-
@include option-theme.theme($theme);
17-
@include optgroup-theme.theme($theme);
53+
$density: theming.get-density-config($theme);
54+
$typography: theming.get-typography-config($theme);
1855

1956
@if $color != null {
20-
// Provides external CSS classes for each elevation value. Each CSS class is formatted as
21-
// `mat-mdc-elevation-z$zValue` where `$zValue` corresponds to the z-space to which the
22-
// element is elevated.
23-
@for $zValue from 0 through 24 {
24-
$selector: elevation.$prefix + $zValue;
25-
// We need the `mat-mdc-elevation-specific`, because some MDC mixins
26-
// come with elevation baked in and we don't have a way of removing it.
27-
.#{$selector}, .mat-mdc-elevation-specific.#{$selector} {
28-
@include elevation.private-theme-elevation($zValue, $color);
29-
}
30-
}
57+
@include color($color);
58+
}
59+
@if $density != null {
60+
@include density($density);
61+
}
62+
@if $typography != null {
63+
@include typography($typography);
3164
}
3265
}
3366
}

0 commit comments

Comments
 (0)
Please sign in to comment.