1
- # Notes on ng-material 's theme implementation
1
+ # Notes on AngularJS Material 's theme implementation
2
2
3
3
#### TL;DR
4
- Themes are configured by users with ` $mdThemingProvider ` . The CSS is then generated at run-time by
5
- the ` $mdTheming ` service and tacked into the document head.
4
+ You configure themes with ` $mdThemingProvider ` . The CSS is then generated at run-time by
5
+ the ` $mdTheming ` service and appended to the document's ` < head> ` .
6
6
7
- ## Actual explanation
7
+ ## Explanation
8
8
9
9
### At build time
10
- * All of the styles associated with ** color** are defined in a separate scss file of the form
10
+ * All the styles associated with ** color** are defined in a separate SCSS file of the form
11
11
` xxx-theme.scss ` .
12
- * Instead of using hard-coded color or a SCSS variable, the colors are defined with a mini-DSL
13
- (described deblow ).
14
- * The build process takes all of those ` -theme.scss ` files and globs them up into one enourmous
12
+ * Instead of using a hard-coded color or a SCSS variable, you define the colors with a mini-DSL
13
+ (described below ).
14
+ * The build process takes all of those ` -theme.scss ` files and globs them up into one enormous
15
15
string.
16
- * The build process wraps that string with code to set it an angular module constant:
17
- ``` angular.module('material.core').constant('$MD_THEME_CSS', 'HUGE_THEME_STRING'); ```
18
- * That code gets dumped at the end of ` angular-material.js `
16
+ * The build process wraps that string with code to set it as an AngularJS module constant:
17
+ ```
18
+ angular.module('material.core').constant('$MD_THEME_CSS', 'HUGE_THEME_STRING');
19
+ ```
20
+ * That code gets dumped at the end of ` angular-material.js ` .
19
21
20
22
### At run time
21
23
* The user defines some themes with ` $mdThemingProvider ` during the module config phase.
22
24
* At module run time, the theming service takes ` $MD_THEME_CSS ` and, for each theme, evaluates the
23
25
mini-DSL, applies the colors for the theme, and appends the resulting CSS into the document head.
24
26
25
-
26
27
### The mini-DSL
27
- * Each color is written in the form ` '{{palette-hue-contrast-opacity}}' ` , where ` hue ` , ` contrast ` ,
28
+ * You write each color in the form ` '{{palette-hue-contrast-opacity}}' ` , where ` hue ` , ` contrast ` ,
28
29
and opacity are optional.
29
- * For example, ` '{{primary-500}}' `
30
- * Palettes are ` primary ` , ` accent ` , ` warn ` , ` background `
30
+ * For example, ` '{{primary-500}}' ` .
31
+ * Palettes are ` primary ` , ` accent ` , ` warn ` , ` background ` .
31
32
* 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
+ ` hue ` to ` 500 ` except for ` background ` .
33
34
* The ` opacity ` value can be a decimal between 0 and 1 or one of the following values based on the
34
35
hue's contrast type (dark, light, or strongLight):
35
36
* ` icon ` : icon (0.54 / 0.87 / 1.0)
@@ -41,4 +42,4 @@ hue's contrast type (dark, light, or strongLight):
41
42
For example, ` accent-contrast ` will be a contrast color for the accent color, for use as a text
42
43
color on an accent-colored background. Adding an ` opacity ` value as in ` accent-contrast-icon ` will
43
44
apply the Material Design icon opacity. Using a decimal opacity value as in ` accent-contrast-0.25 `
44
- will apply the contrast color for the accent color at 25% opacity.
45
+ will apply the contrast color for the accent color at 25% opacity.
0 commit comments