-
Notifications
You must be signed in to change notification settings - Fork 88
/
simptip.scss
413 lines (355 loc) · 9.64 KB
/
simptip.scss
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
//----------------------------------------------------
// SimpTip v1.0.4 \\
// A simple CSS tooltip made with Sass \\
//-----------------------------------------------------
// source: https://github.com/arashmanteghi/simptip/
// ducoment: http://arashm.net/lab/simptip/
// by @ArashManteghi - http://arashm.net
//-----------------------------------------------------
// ****************************** Variables ****************************/
//tooltip's default height
$tooltipHeight: 22px;
//tooltip's default arrow size
$arrowSize: 6px;
//tooltip's default box color
$tooltipColor: #323232;
//tooltip's default text color
$tooltipTextColor: #ecf0f1;
//diverse color variables
$c-success: #62c462;
$c-info: #5bc0de;
$c-danger: #e74c3c;
$c-warning: #e67e22;
// ******************************** Mixins *****************************/
//generate custom colors for tooltip's box and the texts. we use it without argumant for default color
@mixin applyColor($color:$tooltipColor, $textColor:$tooltipTextColor) {
@each $position in top, bottom, left, right {
&.simptip-position-#{$position}{
&:before{border-#{$position}-color: $color;}
&:after{background-color: $color; color: $textColor;}
}
}
@each $position in top, bottom {
&.simptip-position-#{$position} {
&.half-arrow {
&:before {border-right: $arrowSize+1px solid $color;}
}
}
}
}
@mixin border-radius($radius: 4px) {
-webkit-border-radius: $radius;
border-radius: $radius;
}
@mixin box-sizing($box-model) {
-webkit-box-sizing: $box-model;
-moz-box-sizing: $box-model;
box-sizing: $box-model;
}
@mixin transition($transition...) {
-webkit-transition: $transition;
-moz-transition: $transition;
-o-transition: $transition;
-ms-transition: $transition;
transition: $transition;
}
@mixin fade ($duration: 0.2s) {
@include transition(opacity $duration linear, visibility $duration linear);
}
@mixin transform($string){
-webkit-transform: $string;
-moz-transform: $string;
-ms-transform: $string;
-o-transform: $string;
transform: $string;
}
//generate multiline tooltips
@mixin multiline ($width: 150px, $align: left) {
height: auto;
width: $width;
padding: $tooltipHeight/2;
line-height: $tooltipHeight - 3px;
white-space: normal;
text-align: $align;
}
// ******************* Customize CSS Output *********************/
// No need to delete or comment out code.
// Simply set any features you don't want to compile to false to
// reduce the CSS output to only what you need.
// Positioning
$left-positioning: true!default;
$right-positioning: true!default;
$top-positioning: true!default;
$bottom-positioning: true!default;
// Half Arrows
$half-arrows: true!default;
// Extra Features
$movable: true!default;
$soft-edge: true!default;
$fade-effect: true!default;
$multiline: true!default;
// Diverse Colors
$coloring: true!default;
/********************************* Core ******************************/
[data-tooltip] {
position: relative;
display: inline-block;
@include box-sizing(content-box);
&:before, &:after {
position: absolute;
visibility: hidden;
opacity: 0;
z-index: 999999;
@include box-sizing(content-box);
// Force Hardware Acceleration in WebKit with translate3d - Refrence: http://davidwalsh.name/translate3d
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
// tooltip arrow
&:before {
content: '';
border: $arrowSize solid transparent;
}
// tooltip box
&:after {
height: $tooltipHeight;
padding: $tooltipHeight/2 $tooltipHeight/2 0 $tooltipHeight/2;
font-size: 13px;
line-height: $tooltipHeight/2;
content: attr(data-tooltip);
white-space: nowrap;
}
@include applyColor();
&:hover, &:focus{
background-color: transparent;
&:before, &:after {
opacity: 1;
visibility: visible;
}
}
}
/******************************* Position ****************************/
//___________________ Left & Right Silent Classes ___________________/
%shared--left-and-right {
&:before, &:after {bottom: 50%;}
&:before{margin-bottom: $arrowSize * -1 + 1; } // -5px
&:after {margin-bottom: $tooltipHeight/-1.5;}
@if $half-arrows == true {
&.half-arrow{
&:before {
bottom: 16px;
border-style: none;
border-top: $arrowSize+1px solid transparent;
}
}
}
@if $multiline == true {
&.simptip-multiline {
&:before, &:after {
@include transform(translateY(50%));
-webkit-filter: blur(0px);
filter: blur(0px);
margin-bottom: 0;
}
&:before{margin-bottom: 0;}
@if $half-arrows == true {
&.half-arrow{ &:before {margin-bottom: -2px;} }
}
}
}
}
//_____________________ End: Silent Classes _______________________/
// Right Position Styling
@if $right-positioning == true {
.simptip-position-right {
@extend %shared--left-and-right;
&:before,&:after {left: 100%;}
&:before{margin-left: -2px;}
&:after{margin-left: 10px;}
@if $movable == true {
&.simptip-movable {
&:before {margin-left: -10px;}
&:after {margin-left: 2px;}
&:hover{
&:before, &:after {@include transform(translateX(10px));}
}
@if $half-arrows == true {
&.half-arrow:before{margin-left: -5px;}
}
@if $multiline == true { //here here here
&.simptip-multiline {
&:hover {
&:before, &:after {@include transform(translate(10px, 50%));}
}
}
}
}
}
@if $half-arrows == true {
&.half-arrow{
&:before {
margin-left: 3px;
border-right: $arrowSize+1px solid $tooltipColor;
}
}
}
}
}
// Left Position Styling
@if $left-positioning == true {
.simptip-position-left {
@extend %shared--left-and-right;
&:before,&:after {right: 100%;}
&:before{margin-right: -2px;}
&:after{margin-right: 10px;}
@if $movable == true {
&.simptip-movable {
&:before {margin-right: -10px;}
&:after {margin-right: 2px;}
&:hover{
&:before, &:after {@include transform(translateX(-10px));}
}
@if $half-arrows == true {
&.half-arrow:before{margin-right: -5px;}
}
@if $multiline == true { //here here here
&.simptip-multiline {
&:hover {
&:before, &:after {@include transform(translate(-10px, 50%));}
}
}
}
}
}
@if $half-arrows == true {
&.half-arrow{
&:before {
margin-right: 3px;
border-left: $arrowSize+1px solid $tooltipColor;
}
}
}
}
}
//_________________ Top & Bottom Silent Classes _________________/
%shared--top-and-bottom {
&:before, &:after {
left: 50%;
@include transform(translateX(-50%));
}
&:after {width: auto;}
@if $half-arrows == true {
&.half-arrow{
&:before {
border-style: none;
border-right: $arrowSize+1px solid $tooltipColor;
}
}
}
}
//_____________________ End: Silent Classes _______________________/
// Bottom Position Styling
@if $bottom-positioning == true {
.simptip-position-bottom {
@extend %shared--top-and-bottom;
&:before, &:after {top: 100%;}
&:before {margin-top: $arrowSize * -1 + 1; } // -5px
&:after {margin-top: 7px;}
&:hover{
&:before, &:after {@include transform(translate(-50%, 0));}
}
@if $movable == true {
&.simptip-movable {
&:before {margin-top: -15px;}
&:after {margin-top: -3px;}
&:hover{
&:before, &:after {@include transform(translate(-50%, 10px));}
}
@if $half-arrows == true {
&.half-arrow {
&:before { margin-top: -10px; }
}
}
}
}
@if $half-arrows == true {
&.half-arrow{
&:before {
margin-top: 0;
border-top: $arrowSize+1px solid transparent;
}
}
}
}
}
// Top Position Styling
@if $top-positioning == true {
.simptip-position-top {
@extend %shared--top-and-bottom;
&:before, &:after {bottom: 100%;}
&:before {margin-bottom: $arrowSize * -1 + 1; } // -5px
&:after {margin-bottom: 7px;}
&:hover{
&:before, &:after {@include transform(translate(-50%, 0px));}
}
@if $movable == true {
&.simptip-movable {
&:before {margin-bottom: -15px;}
&:after {margin-bottom: -3px;}
&:hover{
&:before, &:after {@include transform(translate(-50%, -10px));}
}
@if $half-arrows == true {
&.half-arrow {
&:before { margin-bottom: -10px; }
}
}
}
}
@if $half-arrows == true {
&.half-arrow{
&:before {
margin-bottom: 0;
border-bottom: $arrowSize+1px solid transparent;
}
}
}
}
}
/******************************* Features ****************************/
// animate movement on hover
@if $movable == true {
.simptip-movable {
&:before, &:after {
@include transition(all 0.1s linear);
}
}
}
//soft edge
@if $soft-edge == true {
.simptip-smooth {
&:after{ @include border-radius();}
}
}
//fade effect
@if $fade-effect == true {
.simptip-fade {
&:before, &:after{
@include fade();
}
}
}
//multiline tooltip
@if $multiline == true {
.simptip-multiline {
&:after { @include multiline(); }
}
}
/**************************** Diverse Colors *************************/
@if $coloring == true {
.simptip-success {@include applyColor($c-success);}
.simptip-info {@include applyColor($c-info);}
.simptip-danger {@include applyColor($c-danger);}
.simptip-warning {@include applyColor($c-warning);}
}