-
Notifications
You must be signed in to change notification settings - Fork 8
/
html-hint.sass
320 lines (245 loc) · 7.11 KB
/
html-hint.sass
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
@import './node_modules/hint.css/src/hint.scss'
/**
* based on hint.css with html content support
*/
$custom-hint-hover-helper-size: 12px
//remove default hint
.hint--html
&.hint
&:after
display: none
opacity: 0
.hint__content
background: $hintDefaultColor
color: white
padding: 8px 10px
font-size: 12px
line-height: 12px
pointer-events: none
.hint--hoverable
.hint__content
pointer-events: auto
.hint--html
position: relative
display: inline-block
&:before, &:after
position: absolute
// HACK: Trigger hardware accelerated rendering, otherwise transform was not
// working on a hidden element
@include vendor('transform', translate3d(0, 0, 0))
// HACK: visibility is set to hidden because IE & Opera don't support
// pointer-events on HTML content yet because of which hovering a hidden tooltip
// shows the tooltip.
visibility: hidden
opacity: 0
z-index: $hintZIndex
// shouldn't receive pointer events, otherwise even hovering tooltip will make it appear
pointer-events: none
@include vendor('transition', 0.3s ease)
@include vendor('transition-delay', $hintHideDelay)
&:hover:before, &:hover:after
visibility: visible
opacity: 1
&:hover:before, &:hover:after
// $hintShowDelay will apply as soon as element is hovered.
@include vendor('transition-delay', $hintShowDelay)
/**
* tooltip arrow
*/
&:before
content: ''
position: absolute
background: transparent
border: $hintArrowBorderWidth solid transparent
// move z-index 1 up than :after so that it shows over box-shadow
z-index: $hintZIndex + 1
.hint--html
.hint__content
position: absolute
// HACK: Trigger hardware accelerated rendering, otherwise transform was not
// working on a hidden element
@include vendor('transform', translate3d(0, 0, 0))
// HACK: visibility is set to hidden because IE & Opera don't support
// pointer-events on HTML content yet because of which hovering a hidden tooltip
// shows the tooltip.
visibility: hidden
opacity: 0
z-index: $hintZIndex
// shouldn't receive pointer events, otherwise even hovering tooltip will make it appear
//pointer-events: none
@include vendor('transition', 0.3s ease)
@include vendor('transition-delay', $hintHideDelay)
&:hover .hint__content,
&:focus .hint__content
visibility: visible
opacity: 1
&:hover .hint__content
// $hintShowDelay will apply as soon as element is hovered.
@include vendor('transition-delay', $hintShowDelay)
&.hint--notrans
&:before, &:after
@include vendor('transition', none)
.hint__content
@include vendor('transition', none)
@mixin ice-set-margin($property, $transitionDirection, $xDirection:0)
$translateX: -50%
@if $xDirection == -1
$translateX: -100%
@elseif $xDirection == 1
$translateX: 0
$value: unquote("#{$property}(#{$hintTransitionDistance * $transitionDirection})")
@if $translateX != 0
@include vendor('transform', translateX($translateX) $value)
@else
@include vendor('transform', $value)
@mixin ice-vertical-positioned-tooltip($propertyY, $transitionDirection, $xDirection:0)
.hint__content
#{$propertyY}: 100%
left: 50%
$translateX: -50%
@if $xDirection == -1
$translateX: -100%
@elseif $xDirection == 1
$translateX: 0
&:before, .hint__content
@include vendor('transform', translateX($translateX))
&:before
@if $xDirection != 0
margin-left: -$xDirection * $hintArrowOffsetX
.hint__content
@if $xDirection != 0
margin-left: -2 * $xDirection * $hintArrowOffsetX
.hint__content
&:after //to prevent mouse out
content: ' '
position: absolute
@if $transitionDirection == -1
top: 100%
@else
top: -$custom-hint-hover-helper-size
left: 0
height: $custom-hint-hover-helper-size
width: 100%
opacity: 0
background-color: red
&:hover .hint__content, &:focus .hint__content
@include ice-set-margin('translateY', $transitionDirection, $xDirection)
@mixin ice-horizontal-positioned-tooltip($propertyX, $transitionDirection)
&:before
// get the arrow out
margin-#{$propertyX}: -2 * $hintArrowBorderWidth
// bring back to center
margin-bottom: -1 * $hintArrowBorderWidth
.hint__content
// bring back to center
margin-bottom: -1 * floor($hintTooltipHeight / 2)
.hint__content
#{$propertyX}: 100%
bottom: 50%
.hint__content
&:after //to prevent mouse out
content: ' '
position: absolute
@if $transitionDirection == -1
left: 100%
@else
left: -$custom-hint-hover-helper-size
top: 0
height: 100%
width: $custom-hint-hover-helper-size
opacity: 0
background-color: red
&:hover .hint__content, &:focus .hint__content
@include ice-set-margin('translateX', $transitionDirection, 1)
/**
* top tooltip
*/
.#{$hintPrefix}top
@include ice-vertical-positioned-tooltip('bottom', -1)
.#{$hintPrefix}top-left
@include ice-vertical-positioned-tooltip('bottom', -1, -1)
.#{$hintPrefix}top-right
@include ice-vertical-positioned-tooltip('bottom', -1, 1)
/**
* bottom tooltip
*/
.#{$hintPrefix}bottom
@include ice-vertical-positioned-tooltip('top', 1)
.#{$hintPrefix}bottom-left
@include ice-vertical-positioned-tooltip('top', 1, -1)
.#{$hintPrefix}bottom-right
@include ice-vertical-positioned-tooltip('top', 1, 1)
/**
* right tooltip
*/
.#{$hintPrefix}right
@include ice-horizontal-positioned-tooltip('left', 1)
/**
* left tooltip
*/
.#{$hintPrefix}left
@include ice-horizontal-positioned-tooltip('right', -1)
@mixin hint-color($color)
.hint__content
background-color: $color
@include arrow-border-color($color)
/**
* Error
*/
.#{$hintPrefix}error
@include hint-color($hintErrorColor)
/**
* Warning
*/
.#{$hintPrefix}warning
@include hint-color($hintWarningColor)
/**
* Info
*/
.#{$hintPrefix}info
@include hint-color($hintInfoColor)
/**
* Success
*/
.#{$hintPrefix}success
@include hint-color($hintSuccessColor)
.hint--html
&.#{$hintPrefix}hidden
&:hover
&:after,&:before
opacity: 0
visibility: hidden
.hint__content
opacity: 0
visibility: hidden
.hint--always
&:after, &:before
opacity: 1
visibility: visible
.hint__content
opacity: 1
visibility: visible
&.#{$hintPrefix}top
.hint__content
@include ice-set-margin('translateY', -1, 0)
&.#{$hintPrefix}top-left
.hint__content
@include ice-set-margin('translateY', -1, -1)
&.#{$hintPrefix}top-right
.hint__content
@include ice-set-margin('translateY', -1, 1)
&.#{$hintPrefix}bottom
.hint__content
@include ice-set-margin('translateY', 1, 0)
&.#{$hintPrefix}bottom-left
.hint__content
@include ice-set-margin('translateY', 1, -1)
&.#{$hintPrefix}bottom-right
.hint__content
@include ice-set-margin('translateY', 1, 1)
&.#{$hintPrefix}left
.hint__content
@include ice-set-margin('translateX', -1, 1)
&.#{$hintPrefix}right
.hint__content
@include ice-set-margin('translateX', 1, 1)