@spark-ui/tailwind-plugins 2.10.13 → 2.11.0
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/CHANGELOG.md
CHANGED
@@ -3,6 +3,16 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [2.11.0](https://github.com/adevinta/spark/compare/@spark-ui/tailwind-plugins@2.10.14...@spark-ui/tailwind-plugins@2.11.0) (2023-06-08)
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
- update eslint rules based on team consensus ([d20f04c](https://github.com/adevinta/spark/commit/d20f04c5f4e6b5ed381d3db412108f58196767a1))
|
11
|
+
|
12
|
+
## [2.10.14](https://github.com/adevinta/spark/compare/@spark-ui/tailwind-plugins@2.10.13...@spark-ui/tailwind-plugins@2.10.14) (2023-06-01)
|
13
|
+
|
14
|
+
**Note:** Version bump only for package @spark-ui/tailwind-plugins
|
15
|
+
|
6
16
|
## [2.10.13](https://github.com/adevinta/spark/compare/@spark-ui/tailwind-plugins@2.10.12...@spark-ui/tailwind-plugins@2.10.13) (2023-06-01)
|
7
17
|
|
8
18
|
**Note:** Version bump only for package @spark-ui/tailwind-plugins
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@spark-ui/tailwind-plugins",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.11.0",
|
4
4
|
"description": "Spark Tailwind plugins",
|
5
5
|
"publishConfig": {
|
6
6
|
"access": "public"
|
@@ -23,5 +23,5 @@
|
|
23
23
|
},
|
24
24
|
"homepage": "https://sparkui.vercel.app",
|
25
25
|
"license": "MIT",
|
26
|
-
"gitHead": "
|
26
|
+
"gitHead": "41085d490de00dc6f4f98499e70cd23728b10ab9"
|
27
27
|
}
|
@@ -16,9 +16,7 @@ function getCSSVariableDeclarations(_theme, htmlFontSize) {
|
|
16
16
|
|
17
17
|
function traverse(theme, paths = []) {
|
18
18
|
Object.entries(theme).forEach(([key, value]) => {
|
19
|
-
if (isObject(value))
|
20
|
-
return traverse(value, paths.concat(key))
|
21
|
-
}
|
19
|
+
if (isObject(value)) return traverse(value, paths.concat(key))
|
22
20
|
|
23
21
|
if (isStringOrNumber(value)) {
|
24
22
|
const getFormattedValue = () => {
|
@@ -28,9 +26,7 @@ function getCSSVariableDeclarations(_theme, htmlFontSize) {
|
|
28
26
|
return `${red} ${green} ${blue}`
|
29
27
|
}
|
30
28
|
|
31
|
-
if (/rem$/gi.test(value))
|
32
|
-
return getRemEquivalentValue(value, htmlFontSize)
|
33
|
-
}
|
29
|
+
if (/rem$/gi.test(value)) return getRemEquivalentValue(value, htmlFontSize)
|
34
30
|
|
35
31
|
return value
|
36
32
|
}
|
@@ -64,13 +64,8 @@ function getCSSVariableReferences(_theme) {
|
|
64
64
|
|
65
65
|
if (isObject(value)) {
|
66
66
|
Object.keys(value).forEach(k => {
|
67
|
-
if (k === DEFAULT_KEY)
|
68
|
-
|
69
|
-
}
|
70
|
-
|
71
|
-
if (!isObject(value[k]) && !isCamelCase(k)) {
|
72
|
-
return
|
73
|
-
}
|
67
|
+
if (k === DEFAULT_KEY) return
|
68
|
+
if (!isObject(value[k]) && !isCamelCase(k)) return
|
74
69
|
|
75
70
|
const tmp = value[k]
|
76
71
|
delete value[k]
|
@@ -89,9 +84,8 @@ function getCSSVariableReferences(_theme) {
|
|
89
84
|
if (isColorValue && isHex(value)) {
|
90
85
|
return `rgb(var(--${paths.join('-')}-${key}) / <alpha-value>)`
|
91
86
|
}
|
92
|
-
|
93
|
-
|
94
|
-
}
|
87
|
+
|
88
|
+
if (isScreenValue) return String(value).toLowerCase()
|
95
89
|
|
96
90
|
return `var(--${paths.join('-')}-${key.toLowerCase()})`
|
97
91
|
})()
|
package/spark-theme/index.js
CHANGED
@@ -40,18 +40,15 @@ module.exports = plugin.withOptions(
|
|
40
40
|
|
41
41
|
const { htmlFontSize = 16, themes } = opts
|
42
42
|
|
43
|
-
if (!themes.default)
|
44
|
-
throw new Error(missingDefaultThemeErrorMsg)
|
45
|
-
}
|
43
|
+
if (!themes.default) throw new Error(missingDefaultThemeErrorMsg)
|
46
44
|
|
47
45
|
const { missingItems, additionalItems } = retrieveArrayDifferences({
|
48
46
|
ref: getAllObjectKeys(themeUtils.defaultTheme),
|
49
47
|
comp: getAllObjectKeys(themes.default),
|
50
48
|
})
|
51
49
|
|
52
|
-
if (missingItems.length)
|
53
|
-
|
54
|
-
}
|
50
|
+
if (missingItems.length) throw new Error(missingItemsErrorMsg('default', missingItems))
|
51
|
+
|
55
52
|
if (additionalItems.length) {
|
56
53
|
throw new Error(additionalItemsErrorMsg('default', additionalItems))
|
57
54
|
}
|
@@ -61,21 +58,16 @@ module.exports = plugin.withOptions(
|
|
61
58
|
})
|
62
59
|
|
63
60
|
Object.entries(themes).forEach(([key, value]) => {
|
64
|
-
if (key === 'default')
|
65
|
-
return
|
66
|
-
}
|
61
|
+
if (key === 'default') return
|
67
62
|
|
68
63
|
const { missingItems, additionalItems } = retrieveArrayDifferences({
|
69
64
|
ref: getAllObjectKeys(themeUtils.defaultTheme),
|
70
65
|
comp: getAllObjectKeys(value),
|
71
66
|
})
|
72
67
|
|
73
|
-
if (missingItems.length)
|
74
|
-
|
75
|
-
|
76
|
-
if (additionalItems.length) {
|
77
|
-
throw new Error(additionalItemsErrorMsg(key, additionalItems))
|
78
|
-
}
|
68
|
+
if (missingItems.length) throw new Error(missingItemsErrorMsg(key, missingItems))
|
69
|
+
|
70
|
+
if (additionalItems.length) throw new Error(additionalItemsErrorMsg(key, additionalItems))
|
79
71
|
|
80
72
|
addBase({
|
81
73
|
[`[data-theme="${key}"]`]: getObjectDifferences(
|
@@ -92,9 +84,7 @@ module.exports = plugin.withOptions(
|
|
92
84
|
|
93
85
|
const { themes } = opts
|
94
86
|
|
95
|
-
if (!themes.default)
|
96
|
-
throw new Error(missingDefaultThemeErrorMsg)
|
97
|
-
}
|
87
|
+
if (!themes.default) throw new Error(missingDefaultThemeErrorMsg)
|
98
88
|
|
99
89
|
return { theme: getCSSVariableReferences(themes.default) }
|
100
90
|
}
|
package/spark-theme/utils.js
CHANGED
@@ -7,9 +7,7 @@ function isStringOrNumber(value) {
|
|
7
7
|
}
|
8
8
|
|
9
9
|
function isHex(value) {
|
10
|
-
if (typeof value === 'number')
|
11
|
-
return false
|
12
|
-
}
|
10
|
+
if (typeof value === 'number') return false
|
13
11
|
|
14
12
|
const regexp = /^#[0-9a-fA-F]+$/
|
15
13
|
|
@@ -44,9 +42,7 @@ const doubleHyphensRegex = /(?<!var\()--+/g
|
|
44
42
|
function getAllObjectKeys(obj, path = '') {
|
45
43
|
return Object.keys(obj).flatMap(key => {
|
46
44
|
const newPath = path ? `${path}.${key}` : key
|
47
|
-
if (isObject(obj[key]))
|
48
|
-
return getAllObjectKeys(obj[key], newPath)
|
49
|
-
}
|
45
|
+
if (isObject(obj[key])) return getAllObjectKeys(obj[key], newPath)
|
50
46
|
|
51
47
|
return newPath
|
52
48
|
})
|
@@ -72,9 +68,8 @@ function getObjectDifferences(reference, comparison) {
|
|
72
68
|
const diffObj = {}
|
73
69
|
|
74
70
|
Object.keys(comparison).forEach(key => {
|
75
|
-
if (reference[key] === comparison[key])
|
76
|
-
|
77
|
-
}
|
71
|
+
if (reference[key] === comparison[key]) return
|
72
|
+
|
78
73
|
diffObj[key] = comparison[key]
|
79
74
|
})
|
80
75
|
|