Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 01917b3

Browse files
committedJul 1, 2020
fix(theme, colors): md-colors demo was broken. improve JSDoc and fix lint issues
- fix lint warning of unnecessary escape in regex and missing colon - resolve test failures after merge - `md-colors` demos general cleanup and fix URLs and icons - clarify how to map the old foreground expressions in theming docs - update links to opacity requirements for icons - clean up Theming implementation guide
1 parent 68c1d02 commit 01917b3

File tree

11 files changed

+98
-78
lines changed

11 files changed

+98
-78
lines changed
 

‎docs/guides/THEMES_IMPL_NOTES.md

+18-17
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
1-
# Notes on ng-material's theme implementation
1+
# Notes on AngularJS Material's theme implementation
22

33
#### 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>`.
66

7-
## Actual explanation
7+
## Explanation
88

99
### 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
1111
`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
1515
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`.
1921

2022
### At run time
2123
* The user defines some themes with `$mdThemingProvider` during the module config phase.
2224
* At module run time, the theming service takes `$MD_THEME_CSS` and, for each theme, evaluates the
2325
mini-DSL, applies the colors for the theme, and appends the resulting CSS into the document head.
2426

25-
2627
### 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`,
2829
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`.
3132
* 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`.
3334
* The `opacity` value can be a decimal between 0 and 1 or one of the following values based on the
3435
hue's contrast type (dark, light, or strongLight):
3536
* `icon`: icon (0.54 / 0.87 / 1.0)
@@ -41,4 +42,4 @@ hue's contrast type (dark, light, or strongLight):
4142
For example, `accent-contrast` will be a contrast color for the accent color, for use as a text
4243
color on an accent-colored background. Adding an `opacity` value as in `accent-contrast-icon` will
4344
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.
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<div layout="column" ng-cloak class="md-padding">
22
<p style="margin-bottom: 10px;">
3-
Custom component implementations using Material elements often want to easily apply Theme colors
3+
Custom component implementations using Material elements often want to easily apply theme colors
44
to their custom components. Consider the custom <code>&lt;user-card&gt;</code> component below
55
where the <code>md-colors</code> attribute is used to color the background and text colors
6-
using either the current or specified Theme palette colors.
6+
using either the current or specified theme palette colors.
77
</p>
88
<!-- Example 1 -->
9-
<span class="card-title"> <code>&lt;user-card&gt;</code> without md-color features</span>
9+
<h4 class="card-title"> <code>&lt;user-card&gt;</code> without md-color features</h4>
1010
<regular-card name="User name" md-theme="default"></regular-card>
1111
<!-- Example 2 -->
12-
<span class="card-title"> <code>&lt;user-card&gt;</code> coloring using the 'default' Theme</span>
12+
<h4 class="card-title"> <code>&lt;user-card&gt;</code> coloring using the 'default' theme</h4>
1313
<user-card name="User name"></user-card>
1414
<!-- Example 3 -->
15-
<span class="card-title"> <code>&lt;user-card&gt;</code> coloring using the 'forest' Theme</span>
15+
<h4 class="card-title"> <code>&lt;user-card&gt;</code> coloring using the 'forest' theme</h4>
1616
<user-card name="User name" theme="forest"></user-card>
1717
<!-- Footnote -->
1818
<p class="footnote">
19-
Note: The <code>md-colors</code> directive allows pre-defined theme colors to be easily applied
20-
as CSS style properties. <code>md-colors</code> uses the Palettes defined at
21-
<a class="md-accent" href="https://material.io/archive/guidelines/style/color.html#">Material Design Colors</a>
22-
and the Themes defined using <code>$mdThemingProvider</code>. This feature is simply an
23-
extension of the <code>$mdTheming</code> features.
19+
Note: The <code>md-colors</code> directive allows pre-defined theme colors to be applied
20+
as CSS style properties. <code>md-colors</code> uses the palettes defined in the
21+
<a class="md-accent" href="https://material.io/archive/guidelines/style/color.html#color-color-palette">
22+
Material Design Colors</a> and the themes defined using <code>$mdThemingProvider</code>.
23+
This directive is an extension of the <code>$mdTheming</code> features.
2424
</p>
2525
</div>

‎src/components/colors/demoBasicUsage/regularCard.tmpl.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<md-card-title>
33
<md-card-title-media>
44
<div class="md-media-sm card-media" layout>
5-
<md-icon md-svg-icon="person" style="color:grey"></md-icon>
5+
<md-icon md-svg-icon="social:person" style="color: grey"></md-icon>
66
</div>
77
</md-card-title-media>
88
<md-card-title-text>

‎src/components/colors/demoBasicUsage/script.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ angular.module('colorsDemo', ['ngMaterial'])
55
.accentPalette('green');
66

77
$mdIconProvider
8-
.defaultIconSet('img/icons/sets/social-icons.svg', 24);
8+
.iconSet('social', 'img/icons/sets/social-icons.svg', 24);
99
})
1010
.directive('regularCard', function () {
1111
return {

‎src/components/colors/demoBasicUsage/style.css

+7-8
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,21 @@
1414
color: rgba(255, 255, 255, 0.87);
1515
}
1616

17-
span.card-title {
18-
padding-left: 15px;
19-
margin-top: 20px;
17+
h4.card-title {
18+
margin: 24px 8px 0;
2019
}
2120

2221
code.css {
2322
background-color: #fffcc2;
2423
}
2524

2625
p.footnote code {
27-
font-size:0.85em;
26+
font-size: 0.85em;
2827
}
2928

3029
p.footnote {
31-
font-size:0.85em;
32-
margin: 30px;
33-
padding:5px;
34-
background-color: rgba(205,205,205,0.45);
30+
font-size: 0.85em;
31+
margin: 30px 8px;
32+
padding: 16px;
33+
background-color: rgba(205, 205, 205, 0.45);
3534
}

‎src/components/colors/demoBasicUsage/userCard.tmpl.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<md-card-title>
33
<md-card-title-media>
44
<div class="md-media-sm card-media" layout md-colors="::{background: '{{theme}}-accent'}">
5-
<md-icon md-svg-icon="person"></md-icon>
5+
<md-icon md-svg-icon="social:person"></md-icon>
66
</div>
77
</md-card-title-media>
88
<md-card-title-text>

‎src/components/colors/demoThemePicker/index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div layout="column" ng-cloak ng-controller="ThemeDemoCtrl" class="md-padding">
22
<p>
3-
Select a color from the <a class="md-accent" href="{{mdURL}}">Theme Color Palettes</a>
3+
Select two of the <a class="md-accent" href="{{mdURL}}">Material Palettes</a>
44
below:
55
</p>
66
<!-- Theme Options -->
@@ -26,8 +26,8 @@
2626
<!-- Footnote -->
2727
<p class="footnote">
2828
Notice that the foreground colors are automatically determined (from the theme configurations)
29-
based on the specified background palette selection. Of course, you could easily override the
30-
foreground color also...
29+
based on the specified background palette selection. You can also override the foreground color,
30+
if desired.
3131
</p>
3232

3333
</div>

‎src/components/colors/demoThemePicker/script.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ angular
33
.controller('ThemeDemoCtrl', function ($scope, $mdColorPalette) {
44
$scope.colors = Object.keys($mdColorPalette);
55

6-
$scope.mdURL = 'https://material.google.com/style/color.html#color-color-palette';
6+
$scope.mdURL = 'https://material.io/archive/guidelines/style/color.html#color-color-palette';
77
$scope.primary = 'purple';
88
$scope.accent = 'green';
99

‎src/components/colors/demoThemePicker/style.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
}
1919

2020
p.footnote {
21-
font-size:0.85em;
22-
margin: 30px;
23-
padding:5px;
24-
background-color: rgba(205,205,205,0.45);
21+
font-size: 0.85em;
22+
margin: 30px 8px;
23+
padding: 16px;
24+
background-color: rgba(205, 205, 205, 0.45);
2525
}
2626

2727
.componentTag {
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.