|
| 1 | +//// |
| 2 | +/// @group themes |
| 3 | +/// @access public |
| 4 | +/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a> |
| 5 | +//// |
| 6 | + |
| 7 | +/// If only background color(s) specified, text color(s) will be assigned automatically to a contrasting color. |
| 8 | +/// @param {Map} $palette [$default-palette] - The palette used as basis for styling the component. |
| 9 | +/// @param {Map} $schema [$light-schema] - The schema used as basis for styling the component. |
| 10 | +/// @param {Color} $resting-background [null]- The background color used for the highlight in its resting state. |
| 11 | +/// @param {Color} $resting-color [null] - The text color used for the highlight in its resting state. |
| 12 | +/// @param {Color} $active-background [null] - The background color used for the highlight in its active state. |
| 13 | +/// @param {Color} $active-color [null] - The text color used for the highlight in its active state. |
| 14 | +/// @requires $default-palette |
| 15 | +/// @requires $light-schema |
| 16 | +/// @requires apply-palette |
| 17 | +/// @requires text-contrast |
| 18 | +/// @requires extend |
| 19 | +/// |
| 20 | +/// @example scss Change the background and icon colors in icon highlight |
| 21 | +/// $my-avatar-theme: igx-avatar-theme($icon-background: black, $icon-color: white); |
| 22 | +/// // Pass the theme to the igx-avatar component mixin |
| 23 | +/// @include igx-avatar($my-avatar-theme); |
| 24 | +@function igx-highlight-theme( |
| 25 | + $palette: $default-palette, |
| 26 | + $schema: $light-schema, |
| 27 | + $resting-background: null, |
| 28 | + $resting-color: null, |
| 29 | + $active-background: null, |
| 30 | + $active-color: null, |
| 31 | +) { |
| 32 | + $name: 'igx-highlight'; |
| 33 | + $theme: apply-palette(map-get($schema, $name), $palette); |
| 34 | + |
| 35 | + @if not($resting-color) and $resting-background { |
| 36 | + $resting-color: text-contrast($resting-background); |
| 37 | + } |
| 38 | + |
| 39 | + @if not($active-color) and $active-background { |
| 40 | + $active-color: text-contrast($active-background); |
| 41 | + } |
| 42 | + |
| 43 | + @return extend($theme, ( |
| 44 | + name: $name, |
| 45 | + palette: $palette, |
| 46 | + resting-background: $resting-background, |
| 47 | + resting-color: $resting-color, |
| 48 | + active-background: $active-background, |
| 49 | + active-color: $active-color, |
| 50 | + )); |
| 51 | +} |
| 52 | + |
| 53 | +/// @param {Map} $theme - The theme used to style the component. |
| 54 | +/// @requires {mixin} igx-root-css-vars |
| 55 | +/// @requires rem |
| 56 | +/// @requires --var |
| 57 | +@mixin igx-highlight($theme) { |
| 58 | + @include igx-root-css-vars($theme); |
| 59 | + |
| 60 | + %igx-highlight { |
| 61 | + color: --var($theme, 'resting-color'); |
| 62 | + background: --var($theme, 'resting-background'); |
| 63 | + } |
| 64 | + |
| 65 | + %igx-highlight--active { |
| 66 | + color: --var($theme, 'active-color'); |
| 67 | + background: --var($theme, 'active-background'); |
| 68 | + } |
| 69 | +} |
| 70 | + |
0 commit comments