@symbo.ls/scratch 2.29.64 → 2.29.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +16 -6
- package/dist/cjs/transforms/index.js +16 -6
- package/package.json +4 -4
- package/src/transforms/index.js +119 -79
package/dist/cjs/index.js
CHANGED
|
@@ -2267,12 +2267,13 @@ var isBorderStyle = (str) => [
|
|
|
2267
2267
|
"initial"
|
|
2268
2268
|
].some((v) => str.includes(v));
|
|
2269
2269
|
var transformBorder = (border) => {
|
|
2270
|
-
const arr = border.split(", ");
|
|
2270
|
+
const arr = (border + "").split(", ");
|
|
2271
2271
|
return arr.map((v) => {
|
|
2272
2272
|
v = v.trim();
|
|
2273
2273
|
if (v.slice(0, 2) === "--") return `var(${v})`;
|
|
2274
2274
|
else if (isBorderStyle(v)) return v || "solid";
|
|
2275
|
-
else if (v.slice(-2) === "px" || v.slice(-2) === "em")
|
|
2275
|
+
else if (v.slice(-2) === "px" || v.slice(-2) === "em")
|
|
2276
|
+
return v;
|
|
2276
2277
|
else if (getColor(v).length > 2) return getColor(v);
|
|
2277
2278
|
return getSpacingByKey(v, "border").border;
|
|
2278
2279
|
}).join(" ");
|
|
@@ -2292,7 +2293,10 @@ var transformBoxShadow = (shadows, globalTheme) => shadows.split("|").map((shado
|
|
|
2292
2293
|
if (v.slice(0, 2) === "--") return `var(${v})`;
|
|
2293
2294
|
if (getColor(v).length > 2) {
|
|
2294
2295
|
const color = getMediaColor(v, globalTheme);
|
|
2295
|
-
if (isObject(color))
|
|
2296
|
+
if (isObject(color))
|
|
2297
|
+
return Object.values(color).filter(
|
|
2298
|
+
(v2) => v2.includes(": " + globalTheme)
|
|
2299
|
+
)[0];
|
|
2296
2300
|
return color;
|
|
2297
2301
|
}
|
|
2298
2302
|
if (v.includes("px") || v.slice(-2) === "em") return v;
|
|
@@ -2308,9 +2312,13 @@ var transformBackgroundImage = (backgroundImage, globalTheme) => {
|
|
|
2308
2312
|
if (v.includes("url") || v.includes("gradient")) return v;
|
|
2309
2313
|
else if (CONFIG2.GRADIENT[backgroundImage]) {
|
|
2310
2314
|
return {
|
|
2311
|
-
backgroundImage: getMediaColor(
|
|
2315
|
+
backgroundImage: getMediaColor(
|
|
2316
|
+
backgroundImage,
|
|
2317
|
+
globalTheme || CONFIG2.globalTheme
|
|
2318
|
+
)
|
|
2312
2319
|
};
|
|
2313
|
-
} else if (v.includes("/") || v.startsWith("http") || v.includes("."))
|
|
2320
|
+
} else if (v.includes("/") || v.startsWith("http") || v.includes("."))
|
|
2321
|
+
return `url(${v})`;
|
|
2314
2322
|
return v;
|
|
2315
2323
|
}).join(" ");
|
|
2316
2324
|
};
|
|
@@ -2349,7 +2357,9 @@ var transformSize = (propertyName, val, props = {}, opts = {}) => {
|
|
|
2349
2357
|
if (!shouldScaleBoxSize && isBoxSize && isString(value)) {
|
|
2350
2358
|
value = value.split(" ").map((v) => {
|
|
2351
2359
|
const isSingleLetter = v.length < 3 && /[A-Z]/.test(v);
|
|
2352
|
-
const hasUnits = ["%", "vw", "vh", "ch"].some(
|
|
2360
|
+
const hasUnits = ["%", "vw", "vh", "ch"].some(
|
|
2361
|
+
(unit) => value.includes(unit)
|
|
2362
|
+
);
|
|
2353
2363
|
if (isSingleLetter && !hasUnits) return v + "_default";
|
|
2354
2364
|
return v;
|
|
2355
2365
|
}).join(" ");
|
|
@@ -1222,12 +1222,13 @@ var isBorderStyle = (str) => [
|
|
|
1222
1222
|
"initial"
|
|
1223
1223
|
].some((v) => str.includes(v));
|
|
1224
1224
|
var transformBorder = (border) => {
|
|
1225
|
-
const arr = border.split(", ");
|
|
1225
|
+
const arr = (border + "").split(", ");
|
|
1226
1226
|
return arr.map((v) => {
|
|
1227
1227
|
v = v.trim();
|
|
1228
1228
|
if (v.slice(0, 2) === "--") return `var(${v})`;
|
|
1229
1229
|
else if (isBorderStyle(v)) return v || "solid";
|
|
1230
|
-
else if (v.slice(-2) === "px" || v.slice(-2) === "em")
|
|
1230
|
+
else if (v.slice(-2) === "px" || v.slice(-2) === "em")
|
|
1231
|
+
return v;
|
|
1231
1232
|
else if (getColor(v).length > 2) return getColor(v);
|
|
1232
1233
|
return getSpacingByKey(v, "border").border;
|
|
1233
1234
|
}).join(" ");
|
|
@@ -1247,7 +1248,10 @@ var transformBoxShadow = (shadows, globalTheme) => shadows.split("|").map((shado
|
|
|
1247
1248
|
if (v.slice(0, 2) === "--") return `var(${v})`;
|
|
1248
1249
|
if (getColor(v).length > 2) {
|
|
1249
1250
|
const color = getMediaColor(v, globalTheme);
|
|
1250
|
-
if (isObject(color))
|
|
1251
|
+
if (isObject(color))
|
|
1252
|
+
return Object.values(color).filter(
|
|
1253
|
+
(v2) => v2.includes(": " + globalTheme)
|
|
1254
|
+
)[0];
|
|
1251
1255
|
return color;
|
|
1252
1256
|
}
|
|
1253
1257
|
if (v.includes("px") || v.slice(-2) === "em") return v;
|
|
@@ -1263,9 +1267,13 @@ var transformBackgroundImage = (backgroundImage, globalTheme) => {
|
|
|
1263
1267
|
if (v.includes("url") || v.includes("gradient")) return v;
|
|
1264
1268
|
else if (CONFIG2.GRADIENT[backgroundImage]) {
|
|
1265
1269
|
return {
|
|
1266
|
-
backgroundImage: getMediaColor(
|
|
1270
|
+
backgroundImage: getMediaColor(
|
|
1271
|
+
backgroundImage,
|
|
1272
|
+
globalTheme || CONFIG2.globalTheme
|
|
1273
|
+
)
|
|
1267
1274
|
};
|
|
1268
|
-
} else if (v.includes("/") || v.startsWith("http") || v.includes("."))
|
|
1275
|
+
} else if (v.includes("/") || v.startsWith("http") || v.includes("."))
|
|
1276
|
+
return `url(${v})`;
|
|
1269
1277
|
return v;
|
|
1270
1278
|
}).join(" ");
|
|
1271
1279
|
};
|
|
@@ -1304,7 +1312,9 @@ var transformSize = (propertyName, val, props = {}, opts = {}) => {
|
|
|
1304
1312
|
if (!shouldScaleBoxSize && isBoxSize && isString(value)) {
|
|
1305
1313
|
value = value.split(" ").map((v) => {
|
|
1306
1314
|
const isSingleLetter = v.length < 3 && /[A-Z]/.test(v);
|
|
1307
|
-
const hasUnits = ["%", "vw", "vh", "ch"].some(
|
|
1315
|
+
const hasUnits = ["%", "vw", "vh", "ch"].some(
|
|
1316
|
+
(unit) => value.includes(unit)
|
|
1317
|
+
);
|
|
1308
1318
|
if (isSingleLetter && !hasUnits) return v + "_default";
|
|
1309
1319
|
return v;
|
|
1310
1320
|
}).join(" ");
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@symbo.ls/scratch",
|
|
3
3
|
"description": "Φ / CSS framework and methodology.",
|
|
4
4
|
"author": "symbo.ls",
|
|
5
|
-
"version": "2.29.
|
|
5
|
+
"version": "2.29.66",
|
|
6
6
|
"files": [
|
|
7
7
|
"src",
|
|
8
8
|
"dist"
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"prepublish": "rimraf -I dist && npm run build && npm run copy:package:cjs"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@domql/utils": "^2.29.
|
|
29
|
-
"@symbo.ls/utils": "^2.29.
|
|
28
|
+
"@domql/utils": "^2.29.66",
|
|
29
|
+
"@symbo.ls/utils": "^2.29.66",
|
|
30
30
|
"color-contrast-checker": "^1.5.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "96c61cae2bc621ca0ca6ad1e234e5feebd50b415"
|
|
33
33
|
}
|
package/src/transforms/index.js
CHANGED
|
@@ -12,107 +12,142 @@ import {
|
|
|
12
12
|
getSpacingBasedOnRatio
|
|
13
13
|
} from '../system'
|
|
14
14
|
|
|
15
|
-
const isBorderStyle = str =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
15
|
+
const isBorderStyle = (str) =>
|
|
16
|
+
[
|
|
17
|
+
'none',
|
|
18
|
+
'hidden',
|
|
19
|
+
'dotted',
|
|
20
|
+
'dashed',
|
|
21
|
+
'solid',
|
|
22
|
+
'double',
|
|
23
|
+
'groove',
|
|
24
|
+
'ridge',
|
|
25
|
+
'inset',
|
|
26
|
+
'outset',
|
|
27
|
+
'initial'
|
|
28
|
+
].some((v) => str.includes(v))
|
|
29
|
+
|
|
30
|
+
export const transformBorder = (border) => {
|
|
31
|
+
const arr = (border + '').split(', ')
|
|
32
|
+
return arr
|
|
33
|
+
.map((v) => {
|
|
34
|
+
v = v.trim()
|
|
35
|
+
if (v.slice(0, 2) === '--') return `var(${v})`
|
|
36
|
+
else if (isBorderStyle(v)) return v || 'solid'
|
|
37
|
+
else if (v.slice(-2) === 'px' || v.slice(-2) === 'em')
|
|
38
|
+
return v // TODO: add map spacing
|
|
39
|
+
else if (getColor(v).length > 2) return getColor(v)
|
|
40
|
+
return getSpacingByKey(v, 'border').border
|
|
41
|
+
})
|
|
42
|
+
.join(' ')
|
|
39
43
|
}
|
|
40
44
|
|
|
41
|
-
export const transformTextStroke = stroke => {
|
|
42
|
-
return stroke
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
export const transformTextStroke = (stroke) => {
|
|
46
|
+
return stroke
|
|
47
|
+
.split(', ')
|
|
48
|
+
.map((v) => {
|
|
49
|
+
if (v.slice(0, 2) === '--') return `var(${v})`
|
|
50
|
+
if (v.includes('px')) return v
|
|
51
|
+
else if (getColor(v)) return getColor(v)
|
|
52
|
+
return v
|
|
53
|
+
})
|
|
54
|
+
.join(' ')
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
export const transformShadow = (sh, globalTheme) => getShadow(sh, globalTheme)
|
|
51
58
|
|
|
52
|
-
export const transformBoxShadow = (shadows, globalTheme) =>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
export const transformBoxShadow = (shadows, globalTheme) =>
|
|
60
|
+
shadows
|
|
61
|
+
.split('|')
|
|
62
|
+
.map((shadow) => {
|
|
63
|
+
return shadow
|
|
64
|
+
.split(',')
|
|
65
|
+
.map((v) => {
|
|
66
|
+
v = v.trim()
|
|
67
|
+
if (v.slice(0, 2) === '--') return `var(${v})`
|
|
68
|
+
if (getColor(v).length > 2) {
|
|
69
|
+
const color = getMediaColor(v, globalTheme)
|
|
70
|
+
if (isObject(color))
|
|
71
|
+
return Object.values(color).filter((v) =>
|
|
72
|
+
v.includes(': ' + globalTheme)
|
|
73
|
+
)[0]
|
|
74
|
+
return color
|
|
75
|
+
}
|
|
76
|
+
if (v.includes('px') || v.slice(-2) === 'em') return v
|
|
77
|
+
const arr = v.split(' ')
|
|
78
|
+
if (!arr.length) return v
|
|
79
|
+
return arr.map((v) => getSpacingByKey(v, 'shadow').shadow).join(' ')
|
|
80
|
+
})
|
|
81
|
+
.join(' ')
|
|
82
|
+
})
|
|
83
|
+
.join(',')
|
|
67
84
|
|
|
68
85
|
export const transformBackgroundImage = (backgroundImage, globalTheme) => {
|
|
69
86
|
const CONFIG = getActiveConfig()
|
|
70
|
-
return backgroundImage
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
return backgroundImage
|
|
88
|
+
.split(', ')
|
|
89
|
+
.map((v) => {
|
|
90
|
+
if (v.slice(0, 2) === '--') return `var(${v})`
|
|
91
|
+
if (v.includes('url') || v.includes('gradient')) return v
|
|
92
|
+
else if (CONFIG.GRADIENT[backgroundImage]) {
|
|
93
|
+
return {
|
|
94
|
+
backgroundImage: getMediaColor(
|
|
95
|
+
backgroundImage,
|
|
96
|
+
globalTheme || CONFIG.globalTheme
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
} else if (v.includes('/') || v.startsWith('http') || v.includes('.'))
|
|
100
|
+
return `url(${v})`
|
|
101
|
+
return v
|
|
102
|
+
})
|
|
103
|
+
.join(' ')
|
|
80
104
|
}
|
|
81
105
|
|
|
82
|
-
export const transfromGap =
|
|
83
|
-
|
|
84
|
-
|
|
106
|
+
export const transfromGap = (gap) =>
|
|
107
|
+
isString(gap) &&
|
|
108
|
+
gap
|
|
109
|
+
.split(' ')
|
|
110
|
+
.map((v) => getSpacingByKey(v, 'gap').gap)
|
|
111
|
+
.join(' ')
|
|
85
112
|
|
|
86
|
-
export const transformTransition = transition => {
|
|
113
|
+
export const transformTransition = (transition) => {
|
|
87
114
|
const arr = transition.split(' ')
|
|
88
115
|
|
|
89
116
|
if (!arr.length) return transition
|
|
90
117
|
|
|
91
|
-
return arr
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
118
|
+
return arr
|
|
119
|
+
.map((v) => {
|
|
120
|
+
if (v.slice(0, 2) === '--') return `var(${v})`
|
|
121
|
+
if (v.length < 3 || v.includes('ms')) {
|
|
122
|
+
const mapWithSequence = getTimingByKey(v)
|
|
123
|
+
return mapWithSequence.timing || v
|
|
124
|
+
}
|
|
125
|
+
if (getTimingFunction(v)) return getTimingFunction(v)
|
|
126
|
+
return v
|
|
127
|
+
})
|
|
128
|
+
.join(' ')
|
|
100
129
|
}
|
|
101
130
|
|
|
102
131
|
export const transformDuration = (duration, props, propertyName) => {
|
|
103
132
|
if (!isString(duration)) return
|
|
104
|
-
return duration
|
|
133
|
+
return duration
|
|
134
|
+
.split(',')
|
|
135
|
+
.map((v) => getTimingByKey(v).timing || v)
|
|
136
|
+
.join(',')
|
|
105
137
|
}
|
|
106
138
|
|
|
107
|
-
export const splitTransition = transition => {
|
|
139
|
+
export const splitTransition = (transition) => {
|
|
108
140
|
const arr = transition.split(',')
|
|
109
141
|
if (!arr.length) return
|
|
110
142
|
return arr.map(transformTransition).join(',')
|
|
111
143
|
}
|
|
112
144
|
|
|
113
|
-
export const checkIfBoxSize = propertyName => {
|
|
145
|
+
export const checkIfBoxSize = (propertyName) => {
|
|
114
146
|
const prop = propertyName.toLowerCase()
|
|
115
|
-
return (
|
|
147
|
+
return (
|
|
148
|
+
(prop.includes('width') || prop.includes('height')) &&
|
|
149
|
+
!prop.includes('border')
|
|
150
|
+
)
|
|
116
151
|
}
|
|
117
152
|
|
|
118
153
|
export const transformSize = (propertyName, val, props = {}, opts = {}) => {
|
|
@@ -124,12 +159,17 @@ export const transformSize = (propertyName, val, props = {}, opts = {}) => {
|
|
|
124
159
|
const isBoxSize = checkIfBoxSize(propertyName)
|
|
125
160
|
|
|
126
161
|
if (!shouldScaleBoxSize && isBoxSize && isString(value)) {
|
|
127
|
-
value = value
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
162
|
+
value = value
|
|
163
|
+
.split(' ')
|
|
164
|
+
.map((v) => {
|
|
165
|
+
const isSingleLetter = v.length < 3 && /[A-Z]/.test(v)
|
|
166
|
+
const hasUnits = ['%', 'vw', 'vh', 'ch'].some((unit) =>
|
|
167
|
+
value.includes(unit)
|
|
168
|
+
)
|
|
169
|
+
if (isSingleLetter && !hasUnits) return v + '_default'
|
|
170
|
+
return v
|
|
171
|
+
})
|
|
172
|
+
.join(' ')
|
|
133
173
|
}
|
|
134
174
|
|
|
135
175
|
if (opts.ratio) {
|