-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhamburger.styl
92 lines (91 loc) · 2.51 KB
/
hamburger.styl
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
// helper mixin
hamburger_tint($color = black, $tint_text = false, $labelselector = '+ label')
{$labelselector}
i, &::before, &::after
background-color: $color
if $tint_text
span
color: $color
// main mixin
hamburger($width = 32px, $thickness = 3px, $gap = 7px, $color = black, $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)
if $background != transparent && $padding == 0
$padding = round(($thickness + $gap) / 1.5)
display: none
{$labelselector}
user-select: none
position: relative
display: inline-block
width: $width
height: $height
border: $padding solid transparent
box-sizing content-box
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
if $text == false
display none
else if $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
outline: 1px solid transparent
backface-visibility: hidden
i
top: ($thickness + $gap)
font-size: 0
color: transparent
line-height: 0
if $style == 'align-left'
max-width: $width * 0.75
transform-origin: 66% center
else if $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
if $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)