Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 1c0676d

Browse files
committed
feat(theming): add contrast opacity values for all color types and hues
Add opacity keyword support (`secondary`, `icon`, `disabled`, `hint`, `divider`) Deprecate documentation of `foreground-*` in favor of `background-default-contrast-*` Allow `foregroundPallete` to override colors on default background and hues of equal contrast type
1 parent 7f01138 commit 1c0676d

File tree

4 files changed

+236
-96
lines changed

4 files changed

+236
-96
lines changed

docs/guides/THEMES_IMPL_NOTES.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ the `$mdTheming` service and tacked into the document head.
1212
* Instead of using hard-coded color or a SCSS variable, the colors are defined with a mini-DSL
1313
(described deblow).
1414
* The build process takes all of those `-theme.scss` files and globs them up into one enourmous
15-
string.
15+
string.
1616
* The build process wraps that string with code to set it an angular module constant:
1717
``` angular.module('material.core').constant('$MD_THEME_CSS', 'HUGE_THEME_STRING'); ```
1818
* That code gets dumped at the end of `angular-material.js`
@@ -24,15 +24,20 @@ mini-DSL, applies the colors for the theme, and appends the resulting CSS into t
2424

2525

2626
### The mini-DSL
27-
* Each color is written in the form `'{{palette-hue-opacity}}'`, where opacity is optional.
27+
* Each color is written in the form `'{{palette-hue-contrast-opacity}}'`, where `hue`, `contrast`,
28+
and opacity are optional.
2829
* For example, `'{{primary-500}}'`
29-
* Palettes are `primary`, `accent`, `warn`, `background`, `foreground`
30-
* The hues for each type except `foreground` use the Material Design hues.
31-
* The `forground` palette is a number from one to four:
32-
* `foreground-1`: text
33-
* `foreground-2`: secondary text, icons
34-
* `foreground-3`: disabled text, hint text
35-
* `foreground-4`: dividers
36-
* There is also a special hue called `contrast` that will give a contrast color (for text).
37-
For example, `accent-contrast` will be a contrast color for the accent color, for use as a text
38-
color on an accent-colored background.
30+
* Palettes are `primary`, `accent`, `warn`, `background`
31+
* The hues for each type use the Material Design hues. When not specified, each palette defaults
32+
`hue` to `500` with the exception of `background`
33+
* The `opacity` value can be a decimal between 0 and 1 or one the following values:
34+
* `icon`: icon
35+
* `secondary`: secondary text,
36+
* `disabled`: disabled text or icons
37+
* `hint`: hint text,
38+
* `divider`: dividers
39+
* Default values for `opacity` differ based on light and dark theme
40+
* `contrast` will give a contrast color (for text) and can be mixed with `opacity`.
41+
For example, `accent-contrast` will be a contrast color for the accent color, for use as a text
42+
color on an accent-colored background. Adding an `opacity` value as in `accent-contrast-icon` will
43+
apply the Material Design icon opacity.

src/core/services/theming/theme.palette.js

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ angular.module('material.core.theming.palette', [])
1616
'A400': '#ff1744',
1717
'A700': '#d50000',
1818
'contrastDefaultColor': 'light',
19-
'contrastDarkColors': '50 100 200 300 A100',
20-
'contrastStrongLightColors': '400 500 600 700 A200 A400 A700'
19+
'contrastDarkColors': '50 100 200 300 A100'
2120
},
2221
'pink': {
2322
'50': '#fce4ec',
@@ -35,8 +34,7 @@ angular.module('material.core.theming.palette', [])
3534
'A400': '#f50057',
3635
'A700': '#c51162',
3736
'contrastDefaultColor': 'light',
38-
'contrastDarkColors': '50 100 200 A100',
39-
'contrastStrongLightColors': '500 600 A200 A400 A700'
37+
'contrastDarkColors': '50 100 200 A100'
4038
},
4139
'purple': {
4240
'50': '#f3e5f5',
@@ -54,8 +52,7 @@ angular.module('material.core.theming.palette', [])
5452
'A400': '#d500f9',
5553
'A700': '#aa00ff',
5654
'contrastDefaultColor': 'light',
57-
'contrastDarkColors': '50 100 200 A100',
58-
'contrastStrongLightColors': '300 400 A200 A400 A700'
55+
'contrastDarkColors': '50 100 200 A100'
5956
},
6057
'deep-purple': {
6158
'50': '#ede7f6',
@@ -73,8 +70,7 @@ angular.module('material.core.theming.palette', [])
7370
'A400': '#651fff',
7471
'A700': '#6200ea',
7572
'contrastDefaultColor': 'light',
76-
'contrastDarkColors': '50 100 200 A100',
77-
'contrastStrongLightColors': '300 400 A200'
73+
'contrastDarkColors': '50 100 200 A100'
7874
},
7975
'indigo': {
8076
'50': '#e8eaf6',
@@ -92,8 +88,7 @@ angular.module('material.core.theming.palette', [])
9288
'A400': '#3d5afe',
9389
'A700': '#304ffe',
9490
'contrastDefaultColor': 'light',
95-
'contrastDarkColors': '50 100 200 A100',
96-
'contrastStrongLightColors': '300 400 A200 A400'
91+
'contrastDarkColors': '50 100 200 A100'
9792
},
9893
'blue': {
9994
'50': '#e3f2fd',
@@ -111,8 +106,7 @@ angular.module('material.core.theming.palette', [])
111106
'A400': '#2979ff',
112107
'A700': '#2962ff',
113108
'contrastDefaultColor': 'light',
114-
'contrastDarkColors': '50 100 200 300 400 A100',
115-
'contrastStrongLightColors': '500 600 700 A200 A400 A700'
109+
'contrastDarkColors': '50 100 200 300 400 A100'
116110
},
117111
'light-blue': {
118112
'50': '#e1f5fe',
@@ -130,8 +124,7 @@ angular.module('material.core.theming.palette', [])
130124
'A400': '#00b0ff',
131125
'A700': '#0091ea',
132126
'contrastDefaultColor': 'dark',
133-
'contrastLightColors': '600 700 800 900 A700',
134-
'contrastStrongLightColors': '600 700 800 A700'
127+
'contrastLightColors': '600 700 800 900 A700'
135128
},
136129
'cyan': {
137130
'50': '#e0f7fa',
@@ -149,8 +142,7 @@ angular.module('material.core.theming.palette', [])
149142
'A400': '#00e5ff',
150143
'A700': '#00b8d4',
151144
'contrastDefaultColor': 'dark',
152-
'contrastLightColors': '700 800 900',
153-
'contrastStrongLightColors': '700 800 900'
145+
'contrastLightColors': '700 800 900'
154146
},
155147
'teal': {
156148
'50': '#e0f2f1',
@@ -168,8 +160,7 @@ angular.module('material.core.theming.palette', [])
168160
'A400': '#1de9b6',
169161
'A700': '#00bfa5',
170162
'contrastDefaultColor': 'dark',
171-
'contrastLightColors': '500 600 700 800 900',
172-
'contrastStrongLightColors': '500 600 700'
163+
'contrastLightColors': '500 600 700 800 900'
173164
},
174165
'green': {
175166
'50': '#e8f5e9',
@@ -187,8 +178,7 @@ angular.module('material.core.theming.palette', [])
187178
'A400': '#00e676',
188179
'A700': '#00c853',
189180
'contrastDefaultColor': 'dark',
190-
'contrastLightColors': '500 600 700 800 900',
191-
'contrastStrongLightColors': '500 600 700'
181+
'contrastLightColors': '600 700 800 900'
192182
},
193183
'light-green': {
194184
'50': '#f1f8e9',
@@ -206,8 +196,7 @@ angular.module('material.core.theming.palette', [])
206196
'A400': '#76ff03',
207197
'A700': '#64dd17',
208198
'contrastDefaultColor': 'dark',
209-
'contrastLightColors': '700 800 900',
210-
'contrastStrongLightColors': '700 800 900'
199+
'contrastLightColors': '700 800 900'
211200
},
212201
'lime': {
213202
'50': '#f9fbe7',
@@ -225,8 +214,7 @@ angular.module('material.core.theming.palette', [])
225214
'A400': '#c6ff00',
226215
'A700': '#aeea00',
227216
'contrastDefaultColor': 'dark',
228-
'contrastLightColors': '900',
229-
'contrastStrongLightColors': '900'
217+
'contrastLightColors': '900'
230218
},
231219
'yellow': {
232220
'50': '#fffde7',
@@ -278,8 +266,7 @@ angular.module('material.core.theming.palette', [])
278266
'A400': '#ff9100',
279267
'A700': '#ff6d00',
280268
'contrastDefaultColor': 'dark',
281-
'contrastLightColors': '800 900',
282-
'contrastStrongLightColors': '800 900'
269+
'contrastLightColors': '800 900'
283270
},
284271
'deep-orange': {
285272
'50': '#fbe9e7',
@@ -297,8 +284,7 @@ angular.module('material.core.theming.palette', [])
297284
'A400': '#ff3d00',
298285
'A700': '#dd2c00',
299286
'contrastDefaultColor': 'light',
300-
'contrastDarkColors': '50 100 200 300 400 A100 A200',
301-
'contrastStrongLightColors': '500 600 700 800 900 A400 A700'
287+
'contrastDarkColors': '50 100 200 300 400 A100 A200'
302288
},
303289
'brown': {
304290
'50': '#efebe9',
@@ -316,8 +302,7 @@ angular.module('material.core.theming.palette', [])
316302
'A400': '#8d6e63',
317303
'A700': '#5d4037',
318304
'contrastDefaultColor': 'light',
319-
'contrastDarkColors': '50 100 200 A100 A200',
320-
'contrastStrongLightColors': '300 400'
305+
'contrastDarkColors': '50 100 200 A100 A200'
321306
},
322307
'grey': {
323308
'50': '#fafafa',
@@ -353,7 +338,6 @@ angular.module('material.core.theming.palette', [])
353338
'A400': '#78909c',
354339
'A700': '#455a64',
355340
'contrastDefaultColor': 'light',
356-
'contrastDarkColors': '50 100 200 300 A100 A200',
357-
'contrastStrongLightColors': '400 500 700'
341+
'contrastDarkColors': '50 100 200 300 A100 A200'
358342
}
359343
});

0 commit comments

Comments
 (0)