@@ -20,21 +20,23 @@ $_emitted-color: () !default;
2020$_emitted-typography : () !default ;
2121$_emitted-density : () !default ;
2222
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.
2627@function get-contrast-color-from-palette ($palette , $hue ) {
2728 @return map .get (map .get ($palette , contrast ), $hue );
2829}
2930
3031
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.
3840@function define-palette ($base-palette , $default : 500 , $lighter : 100 , $darker : 700 ,
3941 $text : $default ) {
4042 $result : map .merge ($base-palette , (
@@ -59,14 +61,15 @@ $_emitted-density: () !default;
5961}
6062
6163
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.
7073@function get-color-from-palette ($palette , $hue : default , $opacity : null ) {
7174 // If hueKey is a number between zero and one, then it actually contains an
7275 // opacity value, so recall this function with the default hue and that given opacity.
@@ -130,9 +133,12 @@ $_emitted-density: () !default;
130133 );
131134}
132135
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
135137// 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.
136142@function define-light-theme ($primary , $accent : null , $warn : define-palette (palette .$red-palette )) {
137143 // This function creates a container object for the individual component theme mixins. Consumers
138144 // can construct such an object by calling this function, or by building the object manually.
@@ -167,9 +173,12 @@ $_emitted-density: () !default;
167173 @return private-create-backwards-compatibility-theme (_mat-validate-theme ($result ));
168174}
169175
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
172177// 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.
173182@function define-dark-theme ($primary , $accent : null , $warn : define-palette (palette .$red-palette )) {
174183 // This function creates a container object for the individual component theme mixins. Consumers
175184 // can construct such an object by calling this function, or by building the object manually.
@@ -205,6 +214,10 @@ $_emitted-density: () !default;
205214}
206215
207216/// 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.
208221@function get-color-config ($theme , $default : null ) {
209222 // If a configuration has been passed, return the config directly.
210223 @if not private-is-theme-object ($theme ) {
@@ -225,6 +238,11 @@ $_emitted-density: () !default;
225238}
226239
227240/// 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.
228246@function get-density-config ($theme-or-config , $default : 0 ) {
229247 // If a configuration has been passed, return the config directly.
230248 @if not private-is-theme-object ($theme-or-config ) {
@@ -240,6 +258,11 @@ $_emitted-density: () !default;
240258
241259/// Gets the typography configuration from the given theme or configuration.
242260/// 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.
243266@function get-typography-config ($theme-or-config , $default : null ) {
244267 // If a configuration has been passed, return the config directly.
245268 @if not private-is-theme-object ($theme-or-config ) {
0 commit comments