-
Notifications
You must be signed in to change notification settings - Fork 250
/
_grid.styl
227 lines (174 loc) · 4.62 KB
/
_grid.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
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
column($ratios = 1, $offset = 0, $cycle = 0, $gutter = $jeet.gutter, $clearfix = true, $nth = $jeet.nth)
side = _get-layout-direction()
opposite-side = opposite-position(side)
column-widths = _get-column($ratios, $gutter)
margin-last = 0
margin-l = margin-last
margin-r = column-widths[1]
$nth-selector = "nth-child"
if $nth is "type"
$nth-selector = "nth-of-type"
unless $offset == 0
if $offset < 0
$offset *= -1
$offset = _get-column($offset, column-widths[1])[0]
margin-r = margin-last = $offset + column-widths[1] * 2
else
$offset = _get-column($offset, column-widths[1])[0]
margin-l = $offset + column-widths[1]
if $clearfix
clearfix()
float: side
clear: none
text-align: inherit
width: (column-widths[0])%
margin-{side}: (margin-l)%
margin-{opposite-side}: (margin-r)%
if $cycle != 0
&:{$nth-selector}(n)
margin-{opposite-side}: (margin-r)%
float: side
clear: none
&:{$nth-selector}({$cycle}n)
margin-{opposite-side}: (margin-last)%
float: opposite-side
&:{$nth-selector}({$cycle}n + 1)
clear: both
else
&:last-child
margin-{opposite-side}: (margin-last)%
column-width($ratios = 1, $gutter = $jeet.gutter)
$ratios = _reverse($ratios) unless $jeet.parent-first is true
w = 100
for ratio in $ratios
w = 100 * ratio - $gutter + ratio * $gutter
return w + '%'
column-gutter($ratios = 1, $gutter = $jeet.gutter)
$ratios = _reverse($ratios) unless $jeet.parent-first is true
w = 100
for ratio in $ratios
$gutter = $gutter / w * 100
return $gutter + '%'
span($ratio = 1, $offset = 0, $cycle = 0, $clearfix = true, $nth = $jeet.nth)
side = _get-layout-direction()
opposite-side = opposite-position(side)
span-width = _get-span($ratio)
margin-r = 0
margin-l = margin-r
$nth-selector = "nth-child"
if $nth is "type"
$nth-selector = "nth-of-type"
unless $offset == 0
if $offset < 0
$offset *= -1
margin-r = _get-span($offset)
else
margin-l = _get-span($offset)
if $clearfix
clearfix()
float: side
clear: none
text-align: inherit
width: (span-width)%
margin-{side}: (margin-l)%
margin-{opposite-side}: (margin-r)%
if $cycle != 0
&:{$nth-selector}(n)
float: side
clear: none
&:{$nth-selector}({$cycle}n)
float: opposite-side
&:{$nth-selector}({$cycle}n + 1)
clear: both
move($ratios = 0, $col-or-span = column, $gutter = $jeet.gutter)
translate = ''
side = _get-layout-direction()
if side == right
$ratios = _replace-nth($ratios, 0, $ratios[0] * -1)
if $col-or-span == column or $col-or-span == col or $col-or-span == c
column-widths = _get-column($ratios, $gutter)
translate = column-widths[0] + column-widths[1]
else
translate = _get-span($ratios)
position: relative
left: (translate)%
unmove()
position: static
left: 0
debug($color = blue, $important = false)
if $important
*
background: rgba($color, 5%) !important
else
*
background: rgba($color, 5%)
center($max-width = $jeet.max-width, $pad = 0)
clearfix()
width: auto
max-width: $max-width
float: none
display: unquote('block')
margin-right: auto
margin-left: auto
padding-left: $pad
padding-right: $pad
uncenter()
max-width: none
margin-right: 0
margin-left: 0
padding-left: 0
padding-right: 0
stack($pad = 0, $align = false)
side = _get-layout-direction()
opposite-side = opposite-position(side)
display: unquote('block')
clear: both
float: none
width: 100%
margin-left: auto
margin-right: auto
&:first-child
margin-{side}: auto
&:last-child
margin-{opposite-side}: auto
if $pad != 0
padding-left: $pad
padding-right: $pad
if ($align is not false)
if ($align == center) or ($align == c)
text-align: center
if ($align == left) or ($align == l)
text-align: left
if ($align == right) or ($align == r)
text-align: right
unstack()
side = _get-layout-direction()
opposite-side = opposite-position(side)
text-align: side
display: inline
clear: none
width: auto
margin-left: 0
margin-right: 0
&:first-child
margin-{side}: 0
&:last-child
margin-{opposite-side}: 0
align($direction = both)
position: absolute
transform-style: preserve-3d
if ($direction == horizontal) or ($direction == h)
left: 50%
transform: translateX(-50%)
else if ($direction == vertical) or ($direction == v)
top: 50%
transform: translateY(-50%)
else
top: 50%
left: 50%
transform: translate(-50%, -50%)
clearfix()
&::after
content: ''
display: table
clear: both