-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
63 lines (60 loc) · 1.32 KB
/
build.js
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
const buildSpacing = function () {
const T = new Map([
['p', 'padding'],
['m', 'margin']
])
const D = new Map([
['t', ['top']],
['r', ['right']],
['b', ['bottom']],
['l', ['left']],
['a', ['top', 'right', 'bottom', 'left']],
['x', ['left', 'right']],
['y', ['top', 'bottom']]
])
const S = new Map([
['none', 0],
['auto', 'auto'],
['xs', '2rpx'],
['sm', '4rpx'],
['md', '8rpx'],
['lg', '16rpx'],
['xl', '32rpx'],
['xxl', '20%']
])
let res = ''
for (const t of T.keys()) {
for (const d of D.keys()) {
for (const s of S.keys()) {
if (s === 'auto' && !['l', 'r', 'x'].includes(d)) continue
const name = `.${t}${d}-${s}`
const value = S.get(s)
const prop = T.get(t)
const dir = D.get(d)
res += name + ' {'
for (const d of dir) {
res += `${prop}-${d}: ${value};`
}
res += '}'
}
}
}
console.log(res)
return res
}
const buildRotate = function () {
const step = 45
const begin = 45
const end = 315
let res = ''
for (let i = begin; i <= end; i += step) {
res += `.rotate-${i} {transform: rotate(${i}deg);}`
}
console.log(res)
}
buildSpacing()
// buildRotate()
module.exports = {
buildSpacing, // 生成间距类
buildRotate // 生成旋转类
}