-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtypish.scss
77 lines (69 loc) · 1.92 KB
/
typish.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
// Turns on pre-wrap on a box to allow multiple spaces to work.
//
// .box {
// @include typish-code;
// @include typish-cursor($color: #7bd);
// }
//
// @include typish-keyframes;
@mixin typish-code {
white-space: pre-wrap;
}
// Adds a cursor to a box. Be sure to also include `typish-keyframes`.
// Available parameters are:
//
// - $color: The color
// - $width: cursor width
// - $height: cursor height
// - $left: how much space to offset from the left
// - $top: how much space to offset from the top
// - $speed: speed of the blinking in milliseconds
// - $blinkontype: set to false to disable blinking while typing
//
// .box {
// @include typish-code;
// @include typish-cursor($color: #7bd, $width: 1px);
// }
@mixin typish-cursor($color: #e74c3c, $width: 2px, $height: 1.4em, $left: 5px, $top: 1px, $speed: 500ms, $blinkontype: true) {
&:after {
content: '';
display: inline-block;
vertical-align: baseline;
height: $height;
width: $width;
background: $color;
margin-left: $left;
position: relative;
top: $top;
-webkit-animation: typish-blink $speed linear infinite;
animation: typish-blink $speed linear infinite;
}
@if ($blinkontype != true) {
&.-typish-typing:after {
-webkit-animation: none;
animation: none;
}
}
&.-nocursor:after {
display: none;
}
}
// Adds the blink animation keyframes. Include this at the top-level of your document.
//
// @include typish-keyframes;
@mixin typish-keyframes($duration: 30%, $fade: 10%) {
@-webkit-keyframes typish-blink {
0% { opacity: 1; }
#{$duration} { opacity: 1; }
#{$fade + $duration} { opacity: 0; }
#{100% - $fade} { opacity: 0; }
100% { opacity: 1; }
}
@keyframes typish-blink {
0% { opacity: 1; }
#{$duration} { opacity: 1; }
#{$fade + $duration} { opacity: 0; }
#{100% - $fade} { opacity: 0; }
100% { opacity: 1; }
}
}