|
| 1 | +// ************************************* |
| 2 | +// |
| 3 | +// Tooltip |
| 4 | +// -> Extra information on hover |
| 5 | +// |
| 6 | +// ************************************* |
| 7 | +
|
| 8 | +$tooltip-background: $slate |
| 9 | +$tooltip-color: $c-text-invert |
| 10 | + |
| 11 | +$tooltip-caretSize: 6px |
| 12 | +$tooltip-lineHeight: 1.5 |
| 13 | +$tooltip-maxWidth: 200px |
| 14 | +$tooltip-opacity: 1 |
| 15 | +$tooltip-positions: 'bottom', 'top' |
| 16 | + |
| 17 | +.tooltip |
| 18 | + display: block |
| 19 | + font-size: 14px |
| 20 | + line-height: $tooltip-lineHeight |
| 21 | + opacity: 0 |
| 22 | + position: absolute |
| 23 | + visibility: visible |
| 24 | + z-index: 100 |
| 25 | + |
| 26 | +// ------------------------------------- |
| 27 | +// Modifiers |
| 28 | +// ------------------------------------- |
| 29 | +
|
| 30 | +// ----- Positions ----- // |
| 31 | +
|
| 32 | +@each $position in $tooltip-positions |
| 33 | + |
| 34 | + .tooltip.#{$position} |
| 35 | + padding-#{$position}: $tooltip-caretSize |
| 36 | + padding-#{opposite-position($position)}: $tooltip-caretSize |
| 37 | + @if $position == 'top' or $position == 'left' |
| 38 | + margin-#{$position}: -$tooltip-caretSize |
| 39 | + @else |
| 40 | + margin-#{opposite-position($position)}: $tooltip-caretSize |
| 41 | + |
| 42 | + .tooltip-arrow |
| 43 | + border-#{$position}-color: $tooltip-background |
| 44 | + @if $position == 'top' or $position == 'bottom' |
| 45 | + #{opposite-position($position)}: 0 |
| 46 | + left: 50% |
| 47 | + margin-left: -$tooltip-caretSize |
| 48 | + @if $position == 'left' or $position == 'right' |
| 49 | + #{opposite-position($position)}: 0 |
| 50 | + top: 50% |
| 51 | + margin-top: -$tooltip-caretSize |
| 52 | + @if $position == 'top' |
| 53 | + border-width: $tooltip-caretSize $tooltip-caretSize 0 |
| 54 | + @if $position == 'left' |
| 55 | + border-width: $tooltip-caretSize 0 $tooltip-caretSize $tooltip-caretSize |
| 56 | + @if $position == 'right' |
| 57 | + border-width: $tooltip-caretSize $tooltip-caretSize $tooltip-caretSize 0 |
| 58 | + @if $position == 'bottom' |
| 59 | + border-width: 0 $tooltip-caretSize $tooltip-caretSize |
| 60 | + |
| 61 | +// ------------------------------------- |
| 62 | +// States |
| 63 | +// ------------------------------------- |
| 64 | +
|
| 65 | +// ----- In ----- // |
| 66 | +
|
| 67 | +.tooltip.in |
| 68 | + opacity: $tooltip-opacity |
| 69 | + |
| 70 | +// ------------------------------------- |
| 71 | +// Scaffolding |
| 72 | +// ------------------------------------- |
| 73 | +
|
| 74 | +// ----- Arrow ----- // |
| 75 | +
|
| 76 | +.tooltip-arrow |
| 77 | + border-color: transparent |
| 78 | + border-style: solid |
| 79 | + height: 0 |
| 80 | + position: absolute |
| 81 | + width: 0 |
| 82 | + |
| 83 | +// ----- Inner ----- // |
| 84 | +
|
| 85 | +.tooltip-inner |
| 86 | + background: $tooltip-background |
| 87 | + border-radius: 4px |
| 88 | + color: $tooltip-color |
| 89 | + max-width: $tooltip-maxWidth |
| 90 | + padding: $b-space-xs $b-space $b-space-s |
| 91 | + text-align: center |
0 commit comments