-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhamburger.less
113 lines (112 loc) · 2.86 KB
/
hamburger.less
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
// helper mixin
.hamburger_tint(@color: #000, @tint_text: false, @labelselector: ~"+ label") {
@{labelselector} {
i, &::before, &::after {
background-color: @color;
}
& when (@tint_text = true) {
span {
color: @color;
}
}
}
}
// main mixin
.hamburger(@width: 32px, @thickness: 3px, @gap: 7px, @color: #000, @background: transparent, @tint_text: false, @radius: 0, @radius_background: 0, @anim: 0.25s, @labelselector: ~'+ label', @padding: 0, @text: 'right', @style: false) {
@height: (@thickness*3) + (@gap*2);
& when not (@background = transparent) and (@padding = 0) {
@padding: round((@thickness + @gap) / 1.5);
}
display: none;
@{labelselector} {
user-select: none;
position: relative;
display: inline-block;
width: @width;
height: @height;
box-sizing: content-box;
border: @padding solid transparent;
z-index: 1050;
line-height: @height;
white-space: nowrap;
background: @background;
border-radius: @radius_background;
span {
display: inline-block;
position: absolute;
left: 100%;
margin-top: 1px;
transition: color @anim;
margin-left: @padding;
& when (@text = false) {
display: none;
}
& when not (@text = false) and (@text = left) {
left: auto;
right: 100%;
margin-left: 0;
margin-right: @padding;
}
&::before, &::after {
content: '';
display: inline-block;
min-width: 10px;
width: @width*0.2;
}
}
i, &::before, &::after {
position: absolute;
left: 0;
display: block;
will-change: transform, background-color;
width: @width;
height: @thickness;
border-radius: @radius;
transition: transform @anim, background-color @anim;
backface-visibility: hidden;
outline: 1px solid transparent; // Firefox jagged animation fix
}
i {
top: @thickness + @gap;
// hide text
font-size: 0;
color: transparent;
line-height: 0;
& when (@style = 'align-left') {
max-width: @width * 0.75;
transform-origin: 66% center;
}
& when not (@style = 'align-left') and (@style = 'align-right') {
max-width: @width * 0.75;
margin-left: @width * 0.25;
transform-origin: 33% center;
}
}
&::before, &::after {
content: '';
}
&::before {
top: 0;
}
&::after {
bottom: 0;
}
&:hover {
cursor: pointer;
}
}
&:checked when not (@anim = -1) {
@{labelselector} {
i {
transform: scaleX(0.001);
}
&::before {
transform: translateY(@gap + @thickness) rotate(45deg);
}
&::after {
transform: translateY(-(@gap + @thickness)) rotate(-45deg);
}
}
}
.hamburger_tint(@color, @tint_text, @labelselector);
}