|
| 1 | +//// |
| 2 | +/// @group themes |
| 3 | +/// @access public |
| 4 | +/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a> |
| 5 | +/// @author <a href="https://github.com/desig9stein" target="_blank">Marin Popov</a> |
| 6 | +//// |
| 7 | + |
| 8 | +/// Returns a map containing all style properties related to the theming the tooltip directive. |
| 9 | +/// @param {Map} $palette [$default-palette] - The palette used as basis for styling the component. |
| 10 | +/// @param {Color} $background [] - The background color of the tooltip. |
| 11 | +/// @param {Color} $text-color [] - The text color of the tooltip. |
| 12 | +/// @param {Number} $roundness [] - The border roundness of the tooltip. Smaller values mean less roundness. |
| 13 | +/// @param {String} $variant ['dark'] - Determines the default color scheme - could be either 'dark' or 'light'. |
| 14 | +/// Set to light when the surrounding area is dark. |
| 15 | +/// |
| 16 | +/// @requires extend |
| 17 | +/// @requires igx-color |
| 18 | +/// @requires text-contrast |
| 19 | +/// |
| 20 | +/// @example scss Change the checked fill color |
| 21 | +/// $my-checkbox-theme: igx-checkbox-theme($fill-color: magenta); |
| 22 | +/// // Pass the theme to the igx-checkbox component mixin |
| 23 | +/// @include igx-checkbox($my-checkbox-theme); |
| 24 | +@function igx-tooltip-theme( |
| 25 | + $palette: $default-palette, |
| 26 | + $background: null, |
| 27 | + $text-color: null, |
| 28 | + $roundness: null, |
| 29 | + $variant: 'dark' |
| 30 | +) { |
| 31 | + $name: 'igx-tooltip'; |
| 32 | + $dark-background: hexrgba(igx-color($palette, 'grays', 700)); |
| 33 | + $light-background: rgba(#fff, .94); |
| 34 | + $border-radius: rem(4px); |
| 35 | + |
| 36 | + $dark-theme: ( |
| 37 | + background: rgba($dark-background, .9), |
| 38 | + text-color: text-contrast($dark-background), |
| 39 | + roundness: $border-radius |
| 40 | + ); |
| 41 | + |
| 42 | + $light-theme: ( |
| 43 | + background: $light-background, |
| 44 | + text-color: text-contrast($light-background), |
| 45 | + roundness: $border-radius |
| 46 | + ); |
| 47 | + |
| 48 | + $default-theme: map-get(( |
| 49 | + dark: $dark-theme, |
| 50 | + light: $light-theme |
| 51 | + ), $variant); |
| 52 | + |
| 53 | + @if not($text-color) and $background { |
| 54 | + $text-color: text-contrast($background); |
| 55 | + } |
| 56 | + |
| 57 | + @return extend($default-theme, ( |
| 58 | + palette: $default-palette, |
| 59 | + name: $name, |
| 60 | + background: $background, |
| 61 | + text-color: $text-color, |
| 62 | + roundness: $roundness |
| 63 | + )); |
| 64 | +} |
| 65 | + |
| 66 | +/// @param {Map} $theme - The theme used to style the component. |
| 67 | +/// @requires {mixin} igx-root-css-vars |
| 68 | +/// @requires --var |
| 69 | +@mixin igx-tooltip($theme) { |
| 70 | + @include igx-root-css-vars($theme); |
| 71 | + |
| 72 | + %tooltip-display { |
| 73 | + display: inline-flex; |
| 74 | + justify-content: center; |
| 75 | + flex-flow: column wrap; |
| 76 | + background-color: --var($theme, 'background'); |
| 77 | + color: --var($theme, 'text-color'); |
| 78 | + border-radius: --var($theme, 'roundness'); |
| 79 | + margin: 0 auto; |
| 80 | + } |
| 81 | + |
| 82 | + %tooltip--desktop { |
| 83 | + padding: 0 rem(8px); |
| 84 | + min-height: rem(24px); |
| 85 | + } |
| 86 | + |
| 87 | + %tooltip--mobile { |
| 88 | + padding: 0 rem(16px); |
| 89 | + min-height: rem(32px); |
| 90 | + } |
| 91 | + |
| 92 | + %tooltip--hidden { |
| 93 | + display: none; |
| 94 | + } |
| 95 | +} |
| 96 | + |
| 97 | +/// Adds typography styles for the igx-tooltip component. |
| 98 | +/// Uses the 'body-2' category from the typographic scale for mobile tooltips and custom typography for desktop tooltips. |
| 99 | +/// @group typography |
| 100 | +/// @param {Map} $type-scale - A typographic scale as produced by igx-type-scale. |
| 101 | +/// @param {Map} $categories [(text-desktop: null, text-mobile: 'body-2')] - The categories from the typographic scale used for type styles. |
| 102 | +/// @requires rem |
| 103 | +/// @requires {mixin} igx-type-style |
| 104 | +@mixin igx-tooltip-typography( |
| 105 | + $type-scale, |
| 106 | + $categories: (text-desktop: null, text-mobile: 'body-2') |
| 107 | +) { |
| 108 | + $text-desktop: map-get($categories, 'text-desktop'); |
| 109 | + $text-mobile: map-get($categories, 'text-mobile'); |
| 110 | + |
| 111 | + %tooltip--mobile { |
| 112 | + @include igx-type-style($type-scale, $text-mobile); |
| 113 | + } |
| 114 | + |
| 115 | + @if $text-desktop != null { |
| 116 | + %tooltip--desktop { |
| 117 | + @include igx-type-style($type-scale, $text-desktop); |
| 118 | + } |
| 119 | + } @else { |
| 120 | + %tooltip--desktop { |
| 121 | + font-size: rem(10px); |
| 122 | + font-weight: 600; |
| 123 | + } |
| 124 | + } |
| 125 | +} |
0 commit comments