UNPKG

3.26 kBSCSSView Raw
1// Foundation for Sites by ZURB
2// foundation.zurb.com
3// Licensed under MIT Open Source
4
5////
6/// @group tooltip
7////
8
9/// Default cursor of the defined term.
10/// @type Keyword
11$has-tip-cursor: help !default;
12
13/// Default font weight of the defined term.
14/// @type Keyword | Number
15$has-tip-font-weight: $global-weight-bold !default;
16
17/// Default border bottom of the defined term.
18/// @type List
19$has-tip-border-bottom: dotted 1px $dark-gray !default;
20
21/// Default color of the tooltip background.
22/// @type Color
23$tooltip-background-color: $black !default;
24
25/// Default color of the tooltip font.
26/// @type Color
27$tooltip-color: $white !default;
28
29/// Default padding of the tooltip background.
30/// @type Number
31$tooltip-padding: 0.75rem !default;
32
33/// Default max width for tooltips.
34/// @type Number
35$tooltip-max-width: 10rem !default;
36
37/// Default font size of the tooltip text. By default, we recommend a smaller font size than the body copy.
38/// @type Number
39$tooltip-font-size: $small-font-size !default;
40
41/// Default pip width for tooltips.
42/// @type Number
43$tooltip-pip-width: 0.75rem !default;
44
45/// Default pip height for tooltips. This is helpful for calculating the distance of the tooltip from the tooltip word.
46/// @type Number
47$tooltip-pip-height: $tooltip-pip-width * 0.866 !default;
48
49/// Default radius for tooltips.
50/// @type Number
51$tooltip-radius: $global-radius !default;
52
53@mixin has-tip {
54 position: relative;
55 display: inline-block;
56
57 border-bottom: $has-tip-border-bottom;
58 font-weight: $has-tip-font-weight;
59 cursor: $has-tip-cursor;
60}
61
62@mixin tooltip {
63 position: absolute;
64 top: calc(100% + #{$tooltip-pip-height});
65 z-index: 1200;
66
67 max-width: $tooltip-max-width;
68 padding: $tooltip-padding;
69
70 border-radius: $tooltip-radius;
71 background-color: $tooltip-background-color;
72 font-size: $tooltip-font-size;
73 color: $tooltip-color;
74
75 &::before {
76 position: absolute;
77 }
78
79 &.bottom {
80 &::before {
81 @include css-triangle($tooltip-pip-width, $tooltip-background-color, up);
82 bottom: 100%;
83 }
84
85 &.align-center::before {
86 left: 50%;
87 transform: translateX(-50%);
88 }
89 }
90
91 &.top {
92 &::before {
93 @include css-triangle($tooltip-pip-width, $tooltip-background-color, down);
94 top: 100%;
95 bottom: auto;
96 }
97
98 &.align-center::before {
99 left: 50%;
100 transform: translateX(-50%);
101 }
102 }
103
104 &.left {
105 &::before {
106 @include css-triangle($tooltip-pip-width, $tooltip-background-color, right);
107 left: 100%;
108 }
109
110 &.align-center::before {
111 bottom: auto;
112 top: 50%;
113 transform: translateY(-50%);
114 }
115 }
116
117 &.right {
118 &::before {
119 @include css-triangle($tooltip-pip-width, $tooltip-background-color, left);
120 right: 100%;
121 left: auto;
122 }
123
124 &.align-center::before {
125 bottom: auto;
126 top: 50%;
127 transform: translateY(-50%);
128 }
129 }
130
131 &.align-top::before {
132 bottom: auto;
133 top: 10%;
134 }
135
136 &.align-bottom::before {
137 bottom: 10%;
138 top: auto;
139 }
140
141 &.align-left::before {
142 left: 10%;
143 right: auto;
144 }
145
146 &.align-right::before {
147 left: auto;
148 right: 10%;
149 }
150}
151
152@mixin foundation-tooltip {
153 .has-tip {
154 @include has-tip;
155 }
156
157 .tooltip {
158 @include tooltip;
159 }
160}