@@ -20,21 +20,23 @@ $_emitted-color: () !default;
20
20
$_emitted-typography : () !default ;
21
21
$_emitted-density : () !default ;
22
22
23
- // For a given hue in a palette, return the contrast color from the map of contrast palettes.
24
- // @param $palette
25
- // @param $hue
23
+ /// For a given hue in a palette, return the contrast color from the map of contrast palettes.
24
+ /// @param {Map} $palette The palette from which to extract a color.
25
+ /// @param {String | Number} $hue The hue for which to get a contrast color.
26
+ /// @returns {Color} The contrast color for the given palette and hue.
26
27
@function get-contrast-color-from-palette ($palette , $hue ) {
27
28
@return map .get (map .get ($palette , contrast ), $hue );
28
29
}
29
30
30
31
31
- // Creates a map of hues to colors for a theme. This is used to define a theme palette in terms
32
- // of the Material Design hues.
33
- // @param $base-palette
34
- // @param $default
35
- // @param $lighter
36
- // @param $darker
37
- // @param $text
32
+ /// Creates a map of hues to colors for a theme. This is used to define a theme palette in terms
33
+ /// of the Material Design hues.
34
+ /// @param {Map} $base-palette Map of hue keys to color values for the basis for this palette.
35
+ /// @param {String | Number} $default Default hue for this palette.
36
+ /// @param {String | Number} $lighter "lighter" hue for this palette.
37
+ /// @param {String | Number} $darker "darker" hue for this palette.
38
+ /// @param {String | Number} $text "text" hue for this palette.
39
+ /// @returns {Map} A complete Angular Material theming palette.
38
40
@function define-palette ($base-palette , $default : 500 , $lighter : 100 , $darker : 700 ,
39
41
$text : $default ) {
40
42
$result : map .merge ($base-palette , (
@@ -59,14 +61,15 @@ $_emitted-density: () !default;
59
61
}
60
62
61
63
62
- // Gets a color from a theme palette (the output of mat-palette).
63
- // The hue can be one of the standard values (500, A400, etc.), one of the three preconfigured
64
- // hues (default, lighter, darker), or any of the aforementioned prefixed with "-contrast".
65
- //
66
- // @param $palette The theme palette (output of mat-palette).
67
- // @param $hue The hue from the palette to use. If this is a value between 0 and 1, it will
68
- // be treated as opacity.
69
- // @param $opacity The alpha channel value for the color.
64
+ /// Gets a color from a theme palette (the output of mat-palette).
65
+ /// The hue can be one of the standard values (500, A400, etc.), one of the three preconfigured
66
+ /// hues (default, lighter, darker), or any of the aforementioned prefixed with "-contrast".
67
+ ///
68
+ /// @param {Map} $palette The palette from which to extract a color.
69
+ /// @param {String | Number} $hue The hue from the palette to use. If this is a value between 0
70
+ // and 1, it will be treated as opacity.
71
+ /// @param {Number} $opacity The alpha channel value for the color.
72
+ /// @returns {Color} The color for the given palette, hue, and opacity.
70
73
@function get-color-from-palette ($palette , $hue : default , $opacity : null ) {
71
74
// If hueKey is a number between zero and one, then it actually contains an
72
75
// opacity value, so recall this function with the default hue and that given opacity.
@@ -130,9 +133,12 @@ $_emitted-density: () !default;
130
133
);
131
134
}
132
135
133
- // Creates a container object for a light theme to be given to individual component theme mixins.
134
- // TODO: Remove legacy API and rename `$primary` to `$config`. Currently it cannot be renamed
136
+ // TODO: Remove legacy API and rename `$primary` below to `$config`. Currently it cannot be renamed
135
137
// as it would break existing apps that set the parameter by name.
138
+
139
+ /// Creates a container object for a light theme to be given to individual component theme mixins.
140
+ /// @param {Map} $primary The theme configuration object.
141
+ /// @returns {Map} A complete Angular Material theme map.
136
142
@function define-light-theme ($primary , $accent : null , $warn : define-palette (palette .$red-palette )) {
137
143
// This function creates a container object for the individual component theme mixins. Consumers
138
144
// can construct such an object by calling this function, or by building the object manually.
@@ -167,9 +173,12 @@ $_emitted-density: () !default;
167
173
@return private-create-backwards-compatibility-theme (_mat-validate-theme ($result ));
168
174
}
169
175
170
- // Creates a container object for a dark theme to be given to individual component theme mixins.
171
- // TODO: Remove legacy API and rename `$primary` to `$config`. Currently it cannot be renamed
176
+ // TODO: Remove legacy API and rename below `$primary` to `$config`. Currently it cannot be renamed
172
177
// as it would break existing apps that set the parameter by name.
178
+
179
+ /// Creates a container object for a dark theme to be given to individual component theme mixins.
180
+ /// @param {Map} $primary The theme configuration object.
181
+ /// @returns {Map} A complete Angular Material theme map.
173
182
@function define-dark-theme ($primary , $accent : null , $warn : define-palette (palette .$red-palette )) {
174
183
// This function creates a container object for the individual component theme mixins. Consumers
175
184
// can construct such an object by calling this function, or by building the object manually.
@@ -205,6 +214,10 @@ $_emitted-density: () !default;
205
214
}
206
215
207
216
/// Gets the color configuration from the given theme or configuration.
217
+ /// @param {Map} $theme The theme map returned from `define-light-theme` or `define-dark-theme`.
218
+ /// @param {Map} $default The default value returned if the given `$theme` does not include a
219
+ /// `color` configuration.
220
+ /// @returns {Map} Color configuration for a theme.
208
221
@function get-color-config ($theme , $default : null ) {
209
222
// If a configuration has been passed, return the config directly.
210
223
@if not private-is-theme-object ($theme ) {
@@ -225,6 +238,11 @@ $_emitted-density: () !default;
225
238
}
226
239
227
240
/// Gets the density configuration from the given theme or configuration.
241
+ /// @param {Map} $theme-or-config The theme map returned from `define-light-theme` or
242
+ /// `define-dark-theme`.
243
+ /// @param {Map} $default The default value returned if the given `$theme` does not include a
244
+ /// `density` configuration.
245
+ /// @returns {Map} Density configuration for a theme.
228
246
@function get-density-config ($theme-or-config , $default : 0 ) {
229
247
// If a configuration has been passed, return the config directly.
230
248
@if not private-is-theme-object ($theme-or-config ) {
@@ -240,6 +258,11 @@ $_emitted-density: () !default;
240
258
241
259
/// Gets the typography configuration from the given theme or configuration.
242
260
/// For backwards compatibility, typography is not included by default.
261
+ /// @param {Map} $theme-or-config The theme map returned from `define-light-theme` or
262
+ /// `define-dark-theme`.
263
+ /// @param {Map} $default The default value returned if the given `$theme` does not include a
264
+ /// `typography` configuration.
265
+ /// @returns {Map} Typography configuration for a theme.
243
266
@function get-typography-config ($theme-or-config , $default : null ) {
244
267
// If a configuration has been passed, return the config directly.
245
268
@if not private-is-theme-object ($theme-or-config ) {
0 commit comments