Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit a99ce40

Browse files
authored
chore(theme): Remove tonal variants, since they dont match MD guidelines (#2473)
BREAKING CHANGE: Removes styles for `mdc-theme--primary/secondary-light/dark` CSS classes and the `mdc-theme-light/dark-variant` Sass functions
1 parent 54c3861 commit a99ce40

File tree

9 files changed

+4
-194
lines changed

9 files changed

+4
-194
lines changed

demos/elevation.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
@import "../packages/mdc-elevation/mdc-elevation";
2020

2121
.demo-elevation--custom-color {
22-
@include mdc-elevation(16, secondary-dark, $opacity-boost: .1);
22+
@include mdc-elevation(16, secondary, $opacity-boost: .1);
2323
}

demos/theme/_theme-shared.scss

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,26 +198,10 @@ figure {
198198
background-color: $demo-color-low-luminance;
199199
}
200200

201-
.demo-theme-bg--low-luminance-light {
202-
background-color: mdc-theme-light-variant($demo-color-low-luminance);
203-
}
204-
205-
.demo-theme-bg--low-luminance-dark {
206-
background-color: mdc-theme-dark-variant($demo-color-low-luminance);
207-
}
208-
209201
.demo-theme-bg--high-luminance {
210202
background-color: $demo-color-high-luminance;
211203
}
212204

213-
.demo-theme-bg--high-luminance-light {
214-
background-color: mdc-theme-light-variant($demo-color-high-luminance);
215-
}
216-
217-
.demo-theme-bg--high-luminance-dark {
218-
background-color: mdc-theme-dark-variant($demo-color-high-luminance);
219-
}
220-
221205
.demo-theme-bg--custom-light {
222206
background-color: #dddddd;
223207
}

demos/theme/index.html

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,9 @@ <h3 class="mdc-typography--headline demo-component-section__heading">
170170
<div class="demo-theme-color-group">
171171
<div class="demo-theme-color-swatches">
172172
<div class="demo-theme-color-swatch demo-theme-color-swatch--elevated mdc-theme--primary mdc-typography--body2">Primary</div>
173-
<div class="demo-theme-color-swatch demo-theme-color-swatch--elevated mdc-theme--primary-light mdc-typography--body2">Primary Light</div>
174-
<div class="demo-theme-color-swatch demo-theme-color-swatch--elevated mdc-theme--primary-dark mdc-typography--body2">Primary Dark</div>
175173
</div>
176174
<div class="demo-theme-color-swatches">
177175
<div class="demo-theme-color-swatch demo-theme-color-swatch--elevated mdc-theme--secondary mdc-typography--body2">Secondary</div>
178-
<div class="demo-theme-color-swatch demo-theme-color-swatch--elevated mdc-theme--secondary-light mdc-typography--body2">Secondary Light</div>
179-
<div class="demo-theme-color-swatch demo-theme-color-swatch--elevated mdc-theme--secondary-dark mdc-typography--body2">Secondary Dark</div>
180176
</div>
181177
</div>
182178
</fieldset>
@@ -187,39 +183,16 @@ <h3 class="mdc-typography--headline demo-component-section__heading">
187183
<div class="demo-theme-color-group">
188184
<div class="demo-theme-color-swatches">
189185
<div class="demo-theme-color-swatch mdc-theme--primary-bg mdc-theme--text-primary-on-primary">Primary</div>
190-
<div class="demo-theme-color-swatch mdc-theme--primary-light-bg mdc-theme--text-primary-on-primary-light">Primary Light</div>
191-
<div class="demo-theme-color-swatch mdc-theme--primary-dark-bg mdc-theme--text-primary-on-primary-dark">Primary Dark</div>
192186
</div>
193187
<div class="demo-theme-color-swatches">
194188
<div class="demo-theme-color-swatch mdc-theme--secondary-bg mdc-theme--text-primary-on-secondary">Secondary</div>
195-
<div class="demo-theme-color-swatch mdc-theme--secondary-light-bg mdc-theme--text-primary-on-secondary-light">Secondary Light</div>
196-
<div class="demo-theme-color-swatch mdc-theme--secondary-dark-bg mdc-theme--text-primary-on-secondary-dark">Secondary Dark</div>
197189
</div>
198190
<div class="demo-theme-color-swatches">
199191
<div class="demo-theme-color-swatch demo-theme-color-swatch--elevated mdc-theme--background mdc-theme--text-primary-on-background">Background</div>
200192
</div>
201193
</div>
202194
</fieldset>
203195
</div>
204-
205-
<div class="demo-theme-color-section__row">
206-
<fieldset class="demo-fieldset--color">
207-
<legend class="mdc-typography--subheading2">Light and dark tonal variants for extreme input luminance</legend>
208-
209-
<div class="demo-theme-color-group">
210-
<div class="demo-theme-color-swatches">
211-
<div class="demo-theme-color-swatch demo-theme-bg--low-luminance mdc-theme--text-primary-on-dark">Low Luminance</div>
212-
<div class="demo-theme-color-swatch demo-theme-bg--low-luminance-light mdc-theme--text-primary-on-dark">Light Variant</div>
213-
<div class="demo-theme-color-swatch demo-theme-bg--low-luminance-dark mdc-theme--text-primary-on-dark">Dark Variant</div>
214-
</div>
215-
<div class="demo-theme-color-swatches">
216-
<div class="demo-theme-color-swatch demo-theme-bg--high-luminance mdc-theme--text-primary-on-light">High Luminance</div>
217-
<div class="demo-theme-color-swatch demo-theme-bg--high-luminance-light mdc-theme--text-primary-on-light">Light Variant</div>
218-
<div class="demo-theme-color-swatch demo-theme-bg--high-luminance-dark mdc-theme--text-primary-on-light">Dark Variant</div>
219-
</div>
220-
</div>
221-
</fieldset>
222-
</div>
223196
</div>
224197

225198
<div class="demo-theme-color-section">

demos/theme/theme-baseline.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
@import "../../packages/mdc-theme/color-palette";
1818

1919
// TODO: Use theme mixin(s) instead
20-
$demo-toolbar-progress-bar-color: secondary-light;
20+
$demo-toolbar-progress-bar-color: secondary;
2121

2222
@import "./theme-shared";

packages/mdc-card/mdc-card.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,8 @@
3030
}
3131

3232
.mdc-card--stroked {
33-
$fill-color: mdc-theme-prop-value(background);
34-
$stroke-color: mdc-theme-dark-variant($fill-color, 1);
35-
3633
@include mdc-elevation(0);
37-
@include mdc-card-stroke($stroke-color);
34+
@include mdc-card-stroke(#dbdbdb);
3835
}
3936

4037
//

packages/mdc-theme/README.md

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,6 @@ $mdc-theme-background: #fff; // White
7272
> Apps that previously customized `$mdc-theme-accent` will continue to work, but new apps should use
7373
> `$mdc-theme-secondary` instead.
7474
75-
MDC Theme also exposes _light_ and _dark_ variants of the primary and secondary colors. By default, these values are
76-
computed by lightening and darkening the main primary/secondary colors in Sass, but you can override them if desired:
77-
78-
```scss
79-
$mdc-theme-primary-light: #ce93d8; // Purple 200
80-
$mdc-theme-primary-dark: #6a1b9a; // Purple 800
81-
$mdc-theme-secondary-light: #ffd180; // Orange A100
82-
$mdc-theme-secondary-dark: #ff6d00; // Orange A700
83-
84-
@import "@material/theme/mdc-theme";
85-
```
86-
8775
The text color, for text placed on top of these selected theme colors, is programmatically computed based on color contrast. We follow the Web Content Accessibility Guidelines 2.0.
8876

8977
https://www.w3.org/TR/WCAG20
@@ -95,11 +83,7 @@ https://www.w3.org/TR/WCAG20
9583
CSS Custom property | Description
9684
--- | ---
9785
`--mdc-theme-primary` | The theme primary color
98-
`--mdc-theme-primary-light` | The theme primary color (light variant)
99-
`--mdc-theme-primary-dark` | The theme primary color (dark variant)
10086
`--mdc-theme-secondary` | The theme secondary color
101-
`--mdc-theme-secondary-light` | The theme secondary color (light variant)
102-
`--mdc-theme-secondary-dark` | The theme secondary color (dark variant)
10387
`--mdc-theme-background` | The theme background color
10488
`--mdc-theme-text-<TEXT_STYLE>-on-<THEME_COLOR>` | Text color for TEXT_STYLE on top of THEME_COLOR background
10589
`--mdc-theme-text-<TEXT_STYLE>-on-light` | Text color for TEXT_STYLE on top of light background
@@ -116,18 +100,10 @@ If you want to modify an element, which is not a Material Design component, you
116100
CSS Class | Description
117101
--- | ---
118102
`mdc-theme--primary` | Sets the text color to the theme primary color
119-
`mdc-theme--primary-light` | Sets the text color to the theme primary color (light variant)
120-
`mdc-theme--primary-dark` | Sets the text color to the theme primary color (dark variant)
121103
`mdc-theme--secondary` | Sets the text color to the theme secondary color
122-
`mdc-theme--secondary-light` | Sets the text color to the theme secondary color (light variant)
123-
`mdc-theme--secondary-dark` | Sets the text color to the theme secondary color (dark variant)
124104
`mdc-theme--background` | Sets the background color to the theme background color
125105
`mdc-theme--primary-bg` | Sets the background color to the theme primary color
126-
`mdc-theme--primary-light-bg` | Sets the background color to the theme primary color (light variant)
127-
`mdc-theme--primary-dark-bg` | Sets the background color to the theme primary color (dark variant)
128106
`mdc-theme--secondary-bg` | Sets the background color to the theme secondary color
129-
`mdc-theme--secondary-light-bg` | Sets the background color to the theme secondary color (light variant)
130-
`mdc-theme--secondary-dark-bg` | Sets the background color to the theme secondary color (dark variant)
131107
`mdc-theme--text-<TEXT_STYLE>-on-<THEME_COLOR>` | Sets text to a suitable color for TEXT_STYLE on top of THEME_COLOR background
132108
`mdc-theme--text-<TEXT_STYLE>-on-light` | Sets text to a suitable color for TEXT_STYLE on top of light background
133109
`mdc-theme--text-<TEXT_STYLE>-on-dark` | Sets text to a suitable color for TEXT_STYLE on top of dark background
@@ -147,11 +123,7 @@ The properties below can be used as the `$style` argument for the `mdc-theme-pro
147123
Property Name | Description
148124
--- | ---
149125
`primary` | The theme primary color
150-
`primary-light` | The theme primary color (light variant)
151-
`primary-dark` | The theme primary color (dark variant)
152126
`secondary` | The theme secondary color
153-
`secondary-light` | The theme secondary color (light variant)
154-
`secondary-dark` | The theme secondary color (dark variant)
155127
`background` | The theme background color
156128
`text-<TEXT_STYLE>-on-<THEME_COLOR>` | TEXT_STYLE on top of THEME_COLOR background
157129
`text-<TEXT_STYLE>-on-light` | TEXT_STYLE on top of a light background
@@ -192,27 +164,6 @@ Determines whether to use light or dark text on top of a given color.
192164
@debug mdc-theme-contrast-tone(#9c27b0); // light
193165
```
194166

195-
#### `mdc-theme-light-variant($color)` and `mdc-theme-dark-variant($color)`
196-
197-
Function | Description
198-
--- | ---
199-
`mdc-theme-dark-variant($color, $num-indexes)` | Darken a color by a certain number of indexes within its tonal palette
200-
`mdc-theme-light-variant($color, $num-indexes)` | Lighten a color by a certain number of indexes within its tonal palette
201-
202-
Both functions are luminance-aware, and will always return a color that is visually distinct from both the input color
203-
_and_ the other function.
204-
205-
That is, if the color passed to `mdc-theme-dark-variant()` is already so dark that darkening it by the requested amount
206-
would return `#000000`, the function will _lighten_ the color instead.
207-
208-
Similarly, if the color passed to `mdc-theme-light-variant()` is already so light that lightening it by the requested
209-
amount would return `#ffffff`, the function will _darken_ the color instead.
210-
211-
To avoid having both functions return the same color in cases of extremely high or low input luminance,
212-
`mdc-theme-dark-variant()` will return a color that is _twice_ (×2) as dark as requested when the input is already very
213-
light. Likewise, `mdc-theme-light-variant()` will return a color that is _twice_ (×2) as light as requested when the
214-
input is already very dark. This ensures that the _light_ variant will always be lighter than the _dark_ variant.
215-
216167
#### `mdc-theme-prop-value($property)`
217168

218169
If `$property` is a literal color value (e.g., `blue`, `#fff`), it is returned verbatim. Otherwise, the value of the

packages/mdc-theme/_functions.scss

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616

1717
@import "./constants";
1818

19-
// Used by the functions below to shift a color's luminance by approximately
20-
// one index within its tonal palette.
21-
// E.g., shift from Red 500 to Red 400 or Red 600.
22-
$_mdc-theme-tonal-offset: 7%;
23-
2419
// Calculate the luminance for a color.
2520
// See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
2621
@function mdc-theme-luminance($color) {
@@ -63,61 +58,3 @@ $_mdc-theme-tonal-offset: 7%;
6358
@function mdc-theme-contrast-tone($color) {
6459
@return if(mdc-theme-tone($color) == "dark", "light", "dark");
6560
}
66-
67-
// lighten() and darken() require values to be between 0% and 100%.
68-
@function mdc-theme-clamp-percentage_($percentage) {
69-
@return max(0%, min(100%, $percentage));
70-
}
71-
72-
// Generate light and dark variants of the given color, offset by approximately
73-
// the specified number of indexes within the color's tonal palette.
74-
@function mdc-theme-tonal-variants_($color, $num-indexes: 2) {
75-
$luminance: mdc-theme-luminance($color) * 100%;
76-
$amount-1x: mdc-theme-clamp-percentage_($_mdc-theme-tonal-offset * $num-indexes);
77-
$amount-2x: mdc-theme-clamp-percentage_($_mdc-theme-tonal-offset * $num-indexes * 2);
78-
$lower-bound: $amount-1x;
79-
$upper-bound: 100% - $lower-bound;
80-
81-
@if $luminance <= $lower-bound {
82-
@return (
83-
dark: lighten($color, $amount-1x),
84-
light: lighten($color, $amount-2x)
85-
);
86-
} @else if $luminance >= $upper-bound {
87-
@return (
88-
dark: darken($color, $amount-2x),
89-
light: darken($color, $amount-1x)
90-
);
91-
} @else {
92-
@return (
93-
dark: darken($color, $amount-1x),
94-
light: lighten($color, $amount-1x)
95-
);
96-
}
97-
}
98-
99-
// Darken the given color by approximately the specified number of indexes
100-
// within its tonal palette.
101-
//
102-
// If the color is already very dark, it will be lightened instead of darkened
103-
// to ensure that the returned value is visually distinct from the input color.
104-
//
105-
// If the color is very light, it will be darkened twice as much as usual to
106-
// ensure that the returned value is visually distinct from the light variant
107-
// (which will actually end up being a dark shade).
108-
@function mdc-theme-dark-variant($color, $num-indexes: 2) {
109-
@return map-get(mdc-theme-tonal-variants_($color, $num-indexes), dark);
110-
}
111-
112-
// Lighten the given color by approximately the specified number of indexes
113-
// within its tonal palette.
114-
//
115-
// If the color is already very light, it will be darkened instead of lightened
116-
// to ensure that the returned value is visually distinct from the input color.
117-
//
118-
// If the color is very dark, it will be lightened twice as much as usual to
119-
// ensure that the returned value is visually distinct from the dark variant
120-
// (which will actually end up being a light tint).
121-
@function mdc-theme-light-variant($color, $num-indexes: 2) {
122-
@return map-get(mdc-theme-tonal-variants_($color, $num-indexes), light);
123-
}

packages/mdc-theme/_variables.scss

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@
2323
//
2424

2525
$mdc-theme-primary: #6200ee !default; // baseline purple, 500 tone
26-
$mdc-theme-primary-light: mdc-theme-light-variant($mdc-theme-primary) !default;
27-
$mdc-theme-primary-dark: mdc-theme-dark-variant($mdc-theme-primary) !default;
2826

2927
// The $mdc-theme-accent variable is DEPRECATED - it exists purely for backward compatibility.
3028
// The $mdc-theme-secondary* variables should be used for all new projects.
3129
$mdc-theme-accent: #018786 !default; // baseline teal, 600 tone
3230
$mdc-theme-secondary: $mdc-theme-accent !default;
33-
$mdc-theme-secondary-light: mdc-theme-light-variant($mdc-theme-secondary) !default;
34-
$mdc-theme-secondary-dark: mdc-theme-dark-variant($mdc-theme-secondary) !default;
3531

3632
$mdc-theme-background: #fff !default; // White
3733

@@ -69,12 +65,8 @@ $mdc-theme-text-colors: (
6965
$mdc-theme-property-values: (
7066
/* Primary */
7167
primary: $mdc-theme-primary,
72-
primary-light: $mdc-theme-primary-light,
73-
primary-dark: $mdc-theme-primary-dark,
7468
/* Secondary */
7569
secondary: $mdc-theme-secondary,
76-
secondary-light: $mdc-theme-secondary-light,
77-
secondary-dark: $mdc-theme-secondary-dark,
7870
/* Background */
7971
background: $mdc-theme-background,
8072
// Text-primary on "primary" background
@@ -83,36 +75,12 @@ $mdc-theme-property-values: (
8375
text-hint-on-primary: mdc-theme-ink-color-for-fill_(hint, $mdc-theme-primary),
8476
text-disabled-on-primary: mdc-theme-ink-color-for-fill_(disabled, $mdc-theme-primary),
8577
text-icon-on-primary: mdc-theme-ink-color-for-fill_(icon, $mdc-theme-primary),
86-
// Text-primary on "primary-light" background
87-
text-primary-on-primary-light: mdc-theme-ink-color-for-fill_(primary, $mdc-theme-primary-light),
88-
text-secondary-on-primary-light: mdc-theme-ink-color-for-fill_(secondary, $mdc-theme-primary-light),
89-
text-hint-on-primary-light: mdc-theme-ink-color-for-fill_(hint, $mdc-theme-primary-light),
90-
text-disabled-on-primary-light: mdc-theme-ink-color-for-fill_(disabled, $mdc-theme-primary-light),
91-
text-icon-on-primary-light: mdc-theme-ink-color-for-fill_(icon, $mdc-theme-primary-light),
92-
// Text-primary on "primary-dark" background
93-
text-primary-on-primary-dark: mdc-theme-ink-color-for-fill_(primary, $mdc-theme-primary-dark),
94-
text-secondary-on-primary-dark: mdc-theme-ink-color-for-fill_(secondary, $mdc-theme-primary-dark),
95-
text-hint-on-primary-dark: mdc-theme-ink-color-for-fill_(hint, $mdc-theme-primary-dark),
96-
text-disabled-on-primary-dark: mdc-theme-ink-color-for-fill_(disabled, $mdc-theme-primary-dark),
97-
text-icon-on-primary-dark: mdc-theme-ink-color-for-fill_(icon, $mdc-theme-primary-dark),
9878
// Text-primary on "secondary" background
9979
text-primary-on-secondary: mdc-theme-ink-color-for-fill_(primary, $mdc-theme-secondary),
10080
text-secondary-on-secondary: mdc-theme-ink-color-for-fill_(secondary, $mdc-theme-secondary),
10181
text-hint-on-secondary: mdc-theme-ink-color-for-fill_(hint, $mdc-theme-secondary),
10282
text-disabled-on-secondary: mdc-theme-ink-color-for-fill_(disabled, $mdc-theme-secondary),
10383
text-icon-on-secondary: mdc-theme-ink-color-for-fill_(icon, $mdc-theme-secondary),
104-
// Text-primary on "secondary-light" background
105-
text-primary-on-secondary-light: mdc-theme-ink-color-for-fill_(primary, $mdc-theme-secondary-light),
106-
text-secondary-on-secondary-light: mdc-theme-ink-color-for-fill_(secondary, $mdc-theme-secondary-light),
107-
text-hint-on-secondary-light: mdc-theme-ink-color-for-fill_(hint, $mdc-theme-secondary-light),
108-
text-disabled-on-secondary-light: mdc-theme-ink-color-for-fill_(disabled, $mdc-theme-secondary-light),
109-
text-icon-on-secondary-light: mdc-theme-ink-color-for-fill_(icon, $mdc-theme-secondary-light),
110-
// Text-primary on "secondary-dark" background
111-
text-primary-on-secondary-dark: mdc-theme-ink-color-for-fill_(primary, $mdc-theme-secondary-dark),
112-
text-secondary-on-secondary-dark: mdc-theme-ink-color-for-fill_(secondary, $mdc-theme-secondary-dark),
113-
text-hint-on-secondary-dark: mdc-theme-ink-color-for-fill_(hint, $mdc-theme-secondary-dark),
114-
text-disabled-on-secondary-dark: mdc-theme-ink-color-for-fill_(disabled, $mdc-theme-secondary-dark),
115-
text-icon-on-secondary-dark: mdc-theme-ink-color-for-fill_(icon, $mdc-theme-secondary-dark),
11684
// Text-primary on "background" background
11785
text-primary-on-background: mdc-theme-ink-color-for-fill_(primary, $mdc-theme-background),
11886
text-secondary-on-background: mdc-theme-ink-color-for-fill_(secondary, $mdc-theme-background),

packages/mdc-theme/mdc-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
}
3737

3838
// CSS rules for using primary and secondary (plus light/dark variants) as background colors.
39-
@each $style in ("primary", "primary-light", "primary-dark", "secondary", "secondary-light", "secondary-dark") {
39+
@each $style in ("primary", "secondary") {
4040
.mdc-theme--#{$style}-bg {
4141
@include mdc-theme-prop(background-color, $style, true);
4242
}

0 commit comments

Comments
 (0)