tooltip.scss
75 lines
| 1 | :root { |
| 2 | --tooltip-rotation: 0deg; |
| 3 | --tooltip-width: 250px; |
| 4 | } |
| 5 | |
| 6 | @mixin tooltipBase { |
| 7 | position: absolute; |
| 8 | left: 50%; |
| 9 | transform: translate(-50%, 0) rotate(var(--tooltip-rotation)); |
| 10 | content: attr(tooltip); |
| 11 | background-color: var(--neutral--300); |
| 12 | color: var(--neutral--0); |
| 13 | font-size: 14px; |
| 14 | line-height: 1.7; |
| 15 | padding: 4px 16px; |
| 16 | border-radius: 4px; |
| 17 | font-weight: 400; |
| 18 | max-width: var(--tooltip-width); |
| 19 | box-sizing: border-box; |
| 20 | line-height: normal; |
| 21 | white-space: normal; |
| 22 | animation: fadeIn 0.3s; |
| 23 | min-width: 200px; |
| 24 | } |
| 25 | |
| 26 | .has-tooltip--bottom::after { |
| 27 | @include tooltipBase; |
| 28 | top: calc(100% + 5px); |
| 29 | text-align: -webkit-center; |
| 30 | } |
| 31 | |
| 32 | .has-tooltip--bottom-rotated::after { |
| 33 | @include tooltipBase; |
| 34 | bottom: calc(100% + 5px); |
| 35 | } |
| 36 | |
| 37 | .has-tooltip--top::after { |
| 38 | @include tooltipBase; |
| 39 | bottom: calc(100% + 5px); |
| 40 | } |
| 41 | |
| 42 | .has-tooltip--top-rotated::after { |
| 43 | @include tooltipBase; |
| 44 | top: calc(100% + 5px); |
| 45 | } |
| 46 | |
| 47 | .has-tooltip--left::after { |
| 48 | @include tooltipBase; |
| 49 | top: 50%; |
| 50 | left: auto; |
| 51 | right: calc(100% + 5px); |
| 52 | transform: translate(0, -50%) rotate(var(--tooltip-rotation)); |
| 53 | } |
| 54 | |
| 55 | .has-tooltip--left-rotated::after { |
| 56 | @include tooltipBase; |
| 57 | top: 50%; |
| 58 | left: calc(100% + 5px); |
| 59 | transform: translate(0, -50%) rotate(var(--tooltip-rotation)); |
| 60 | } |
| 61 | |
| 62 | .has-tooltip--right::after { |
| 63 | @include tooltipBase; |
| 64 | top: 50%; |
| 65 | left: calc(100% + 5px); |
| 66 | transform: translate(0, -50%) rotate(var(--tooltip-rotation)); |
| 67 | } |
| 68 | |
| 69 | .has-tooltip--right-rotated::after { |
| 70 | @include tooltipBase; |
| 71 | top: 50%; |
| 72 | left: auto; |
| 73 | right: calc(100% + 5px); |
| 74 | transform: translate(0, -50%) rotate(var(--tooltip-rotation)); |
| 75 | } |