daisyui 4.3.0-alpha.7 → 4.3.0-alpha.8
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/full.css +0 -1188
- package/package.json +5 -6
- package/src/index.js +34 -32
- package/src/lib/addPrefix.js +6 -6
- package/src/lib/responsiveRegex.js +1 -1
- package/src/lib/utility-classes.js +1 -1
- package/src/theming/colorNames.js +1 -1
- package/src/theming/functions.js +197 -185
- package/src/theming/index.js +1 -1
- package/src/theming/themeDefaults.js +46 -44
- package/src/theming/themes.js +1 -1
- package/src/docs/src/lib/data/themes.js +0 -34
- package/src/experiments/playground/src/components/Demo.astro +0 -160
- package/src/experiments/playground/src/env.d.ts +0 -1
- package/src/experiments/playground/src/layouts/Main.astro +0 -15
- package/src/experiments/playground/src/pages/LTR.astro +0 -8
- package/src/experiments/playground/src/pages/RTL.astro +0 -8
- package/src/experiments/playground/src/pages/dark.astro +0 -8
- package/src/experiments/playground/src/pages/demo.astro +0 -8
- package/src/experiments/playground/src/pages/index.astro +0 -32
- package/src/experiments/playground/src/pages/light.astro +0 -8
- package/themes.js +0 -2
- /package/dist/{base.cjs → base.js} +0 -0
- /package/dist/{styled.cjs → styled.js} +0 -0
- /package/dist/{unstyled.cjs → unstyled.js} +0 -0
- /package/dist/{utilities-styled.cjs → utilities-styled.js} +0 -0
- /package/dist/{utilities-unstyled.cjs → utilities-unstyled.js} +0 -0
- /package/dist/{utilities.cjs → utilities.js} +0 -0
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "daisyui",
|
|
3
|
-
"version": "4.3.0-alpha.
|
|
3
|
+
"version": "4.3.0-alpha.8",
|
|
4
4
|
"description": "daisyUI - Tailwind CSS Components",
|
|
5
5
|
"author": "Pouya Saadeghi",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://daisyui.com",
|
|
8
|
-
"type": "module",
|
|
9
8
|
"repository": {
|
|
10
9
|
"type": "git",
|
|
11
10
|
"url": "git+https://github.com/saadeghi/daisyui.git"
|
|
@@ -33,16 +32,16 @@
|
|
|
33
32
|
"ui"
|
|
34
33
|
],
|
|
35
34
|
"main": "src/index.js",
|
|
36
|
-
"
|
|
35
|
+
"typings": "src/index.d.ts",
|
|
37
36
|
"types": "src/index.d.ts",
|
|
38
37
|
"files": [
|
|
39
|
-
"themes.js",
|
|
40
38
|
"src/lib/**/*.js",
|
|
41
|
-
"dist/*.
|
|
39
|
+
"dist/*.js",
|
|
42
40
|
"dist/{themes,styled,unstyled,full}.css",
|
|
43
41
|
"src/index.js",
|
|
44
42
|
"src/theming/*.js",
|
|
45
|
-
"src
|
|
43
|
+
"src/theming/*.d.ts",
|
|
44
|
+
"src/index.d.ts"
|
|
46
45
|
],
|
|
47
46
|
"engines": {
|
|
48
47
|
"node": ">=16.9.0"
|
package/src/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
// const tailwindColors = require("tailwindcss/colors")
|
|
2
2
|
// const tailwindPlugin = require("tailwindcss/plugin")
|
|
3
|
-
|
|
3
|
+
const tailwindPlugin = require("./lib/createPlugin")
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const postcssJs = require("postcss-js")
|
|
6
|
+
const pc = require("picocolors")
|
|
7
|
+
const postcssPrefix = require("./lib/addPrefix")
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
const daisyuiInfo = require("../package.json")
|
|
10
|
+
const utilities = require("../dist/utilities")
|
|
11
|
+
const base = require("../dist/base")
|
|
12
|
+
const unstyled = require("../dist/unstyled")
|
|
13
|
+
const styled = require("../dist/styled")
|
|
14
|
+
const utilitiesUnstyled = require("../dist/utilities-unstyled")
|
|
15
|
+
const utilitiesStyled = require("../dist/utilities-styled")
|
|
16
|
+
const themes = require("./theming/themes")
|
|
17
|
+
const colorFunctions = require("./theming/functions")
|
|
18
|
+
const utilityClasses = require("./lib/utility-classes")
|
|
19
|
+
let colorObject = require("./theming/index")
|
|
20
20
|
|
|
21
21
|
const mainFunction = ({ addBase, addComponents, config }) => {
|
|
22
22
|
let logs = false
|
|
@@ -25,7 +25,7 @@ const mainFunction = ({ addBase, addComponents, config }) => {
|
|
|
25
25
|
}
|
|
26
26
|
if (logs) {
|
|
27
27
|
console.log()
|
|
28
|
-
console.log(`🌼 ${magenta("daisyUI")} ${dim(version)}`)
|
|
28
|
+
console.log(`🌼 ${pc.magenta("daisyUI")} ${pc.dim(daisyuiInfo.version)}`)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// inject @base style
|
|
@@ -44,7 +44,7 @@ const mainFunction = ({ addBase, addComponents, config }) => {
|
|
|
44
44
|
let postcssJsProcess
|
|
45
45
|
if (prefix) {
|
|
46
46
|
try {
|
|
47
|
-
postcssJsProcess = sync(postcssPrefix({ prefix, ignore: [] }))
|
|
47
|
+
postcssJsProcess = postcssJs.sync(postcssPrefix({ prefix, ignore: [] }))
|
|
48
48
|
} catch (error) {
|
|
49
49
|
logs && console.error(`Error occurred and prevent applying the "prefix" option:`, error)
|
|
50
50
|
}
|
|
@@ -56,7 +56,7 @@ const mainFunction = ({ addBase, addComponents, config }) => {
|
|
|
56
56
|
|
|
57
57
|
addComponents(file)
|
|
58
58
|
|
|
59
|
-
const themeInjector = injectThemes(addBase, config, themes)
|
|
59
|
+
const themeInjector = colorFunctions.injectThemes(addBase, config, themes)
|
|
60
60
|
themeInjector
|
|
61
61
|
|
|
62
62
|
// inject @utilities style needed by components
|
|
@@ -79,42 +79,44 @@ const mainFunction = ({ addBase, addComponents, config }) => {
|
|
|
79
79
|
if (logs) {
|
|
80
80
|
if (config("daisyui.styled") == false) {
|
|
81
81
|
console.log(
|
|
82
|
-
`├─ ${yellow("ℹ︎")} ${blue("styled")} ${reset("config is")} ${blue(
|
|
83
|
-
"
|
|
84
|
-
)}`
|
|
82
|
+
`├─ ${pc.yellow("ℹ︎")} ${pc.blue("styled")} ${pc.reset("config is")} ${pc.blue(
|
|
83
|
+
"false"
|
|
84
|
+
)} ${pc.dim("\tcomponents won't have design decisions")}`
|
|
85
85
|
)
|
|
86
86
|
}
|
|
87
87
|
if (config("daisyui.utils") == false) {
|
|
88
88
|
console.log(
|
|
89
|
-
`├─ ${yellow("ℹ︎")} ${blue("utils")} ${reset("config is")} ${blue(
|
|
90
|
-
"
|
|
91
|
-
)}`
|
|
89
|
+
`├─ ${pc.yellow("ℹ︎")} ${pc.blue("utils")} ${pc.reset("config is")} ${pc.blue(
|
|
90
|
+
"false"
|
|
91
|
+
)} ${pc.dim("\tdaisyUI utility classes are disabled")}`
|
|
92
92
|
)
|
|
93
93
|
}
|
|
94
94
|
if (config("daisyui.prefix") && config("daisyui.prefix") !== "") {
|
|
95
95
|
console.log(
|
|
96
|
-
`├─ ${green("✔︎")} ${blue("prefix")} is enabled${dim(
|
|
96
|
+
`├─ ${pc.green("✔︎")} ${pc.blue("prefix")} is enabled${pc.dim(
|
|
97
97
|
"\t\tdaisyUI classnames must use"
|
|
98
|
-
)} ${blue(config("daisyui.prefix"))} ${dim("prefix")}`
|
|
98
|
+
)} ${pc.blue(config("daisyui.prefix"))} ${pc.dim("prefix")}`
|
|
99
99
|
)
|
|
100
100
|
}
|
|
101
101
|
if (themeInjector.themeOrder.length > 0) {
|
|
102
102
|
console.log(
|
|
103
|
-
`├─ ${green("✔︎")} ${themeInjector.themeOrder.length} ${
|
|
103
|
+
`├─ ${pc.green("✔︎")} ${themeInjector.themeOrder.length} ${
|
|
104
104
|
themeInjector.themeOrder.length > 1 ? "themes" : "theme"
|
|
105
|
-
} added${dim("\t\thttps://daisyui.com/docs/themes")}`
|
|
105
|
+
} added${pc.dim("\t\thttps://daisyui.com/docs/themes")}`
|
|
106
106
|
)
|
|
107
107
|
}
|
|
108
108
|
if (themeInjector.themeOrder.length === 0) {
|
|
109
109
|
console.log(
|
|
110
|
-
`├─ ${yellow("ℹ︎")} All themes are disabled in config${dim(
|
|
110
|
+
`├─ ${pc.yellow("ℹ︎")} All themes are disabled in config${pc.dim(
|
|
111
111
|
"\t\thttps://daisyui.com/docs/themes"
|
|
112
112
|
)}`
|
|
113
113
|
)
|
|
114
114
|
}
|
|
115
115
|
let messages = [
|
|
116
|
-
`${green("❤︎")} ${reset("Support daisyUI project:")}\t${dim(
|
|
117
|
-
|
|
116
|
+
`${pc.green("❤︎")} ${pc.reset("Support daisyUI project:")}\t${pc.dim(
|
|
117
|
+
daisyuiInfo.funding.url
|
|
118
|
+
)}`,
|
|
119
|
+
`${pc.green("★")} ${pc.reset("Star daisyUI on GitHub")}\t${pc.dim(
|
|
118
120
|
"https://github.com/saadeghi/daisyui"
|
|
119
121
|
)}`,
|
|
120
122
|
]
|
|
@@ -123,7 +125,7 @@ const mainFunction = ({ addBase, addComponents, config }) => {
|
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
|
|
126
|
-
|
|
128
|
+
module.exports = tailwindPlugin(mainFunction, {
|
|
127
129
|
theme: {
|
|
128
130
|
extend: {
|
|
129
131
|
colors: {
|
package/src/lib/addPrefix.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const Tokenizer = require("css-selector-tokenizer")
|
|
2
2
|
|
|
3
3
|
function itMatchesOne(arr, term) {
|
|
4
4
|
return arr.some((i) => term.search(i) >= 0)
|
|
@@ -61,7 +61,7 @@ function iterateSelectorNodes(selector, options) {
|
|
|
61
61
|
return iterateSelectorNodes(node, options)
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
if (itMatchesOne(ignore, stringify(node))) return node
|
|
64
|
+
if (itMatchesOne(ignore, Tokenizer.stringify(node))) return node
|
|
65
65
|
|
|
66
66
|
return prefixNode(node, prefix)
|
|
67
67
|
}),
|
|
@@ -71,7 +71,7 @@ function iterateSelectorNodes(selector, options) {
|
|
|
71
71
|
/**
|
|
72
72
|
* @type {import('postcss').PluginCreator}
|
|
73
73
|
*/
|
|
74
|
-
|
|
74
|
+
module.exports = (opts = {}) => {
|
|
75
75
|
const { prefix, ignore } = {
|
|
76
76
|
prefix: "",
|
|
77
77
|
ignore: [],
|
|
@@ -92,13 +92,13 @@ export default (opts = {}) => {
|
|
|
92
92
|
postcssPlugin: "addprefix",
|
|
93
93
|
Root(root, postcss) {
|
|
94
94
|
root.walkRules((rule) => {
|
|
95
|
-
const parsed = parse(rule.selector)
|
|
95
|
+
const parsed = Tokenizer.parse(rule.selector)
|
|
96
96
|
const selector = iterateSelectorNodes(parsed, { prefix, ignore })
|
|
97
97
|
|
|
98
|
-
rule.selector = stringify(selector)
|
|
98
|
+
rule.selector = Tokenizer.stringify(selector)
|
|
99
99
|
})
|
|
100
100
|
},
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
module.exports.postcss = true
|
package/src/theming/functions.js
CHANGED
|
@@ -1,214 +1,226 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const colorNames = require("./colorNames")
|
|
2
|
+
const themeDefaults = require("./themeDefaults")
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const { toGamut, interpolate, wcagContrast } = require("culori")
|
|
5
5
|
|
|
6
|
-
const cutNumber = (number) => (number ? +number.toFixed(6) : 0)
|
|
7
|
-
const toGamutOKLCH = toGamut("oklch")
|
|
6
|
+
const cutNumber = (number) => (number ? +number.toFixed(6) : 0);
|
|
7
|
+
const toGamutOKLCH = toGamut("oklch");
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return `${cutNumber(l)} ${cutNumber(c)} ${cutNumber(h)}`
|
|
17
|
-
}
|
|
18
|
-
export function generateForegroundColorFrom(input, percentage = 0.8) {
|
|
19
|
-
const result = interpolate([input, isDark(input) ? "white" : "black"], "oklch")(percentage)
|
|
20
|
-
return colorObjToString(result)
|
|
21
|
-
}
|
|
22
|
-
export function generateDarkenColorFrom(input, percentage = 0.07) {
|
|
23
|
-
const result = interpolate([input, "black"], "oklch")(percentage)
|
|
24
|
-
return colorObjToString(result)
|
|
25
|
-
}
|
|
26
|
-
export function convertColorFormat(input) {
|
|
27
|
-
if (typeof input !== "object" || input === null) {
|
|
28
|
-
return input
|
|
29
|
-
}
|
|
9
|
+
module.exports = {
|
|
10
|
+
isDark: (color) => {
|
|
11
|
+
if (wcagContrast(color, "black") < wcagContrast(color, "white")) {
|
|
12
|
+
return true
|
|
13
|
+
}
|
|
14
|
+
return false
|
|
15
|
+
},
|
|
30
16
|
|
|
31
|
-
|
|
17
|
+
colorObjToString: function (input) {
|
|
18
|
+
const { l, c, h } = input
|
|
19
|
+
return `${cutNumber(l)} ${cutNumber(c)} ${cutNumber(h)}`
|
|
20
|
+
},
|
|
32
21
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} else {
|
|
38
|
-
resultObj[rule] = value
|
|
39
|
-
}
|
|
22
|
+
generateForegroundColorFrom: function (input, percentage = 0.8) {
|
|
23
|
+
const result = interpolate([input, this.isDark(input) ? "white" : "black"], "oklch")(percentage)
|
|
24
|
+
return this.colorObjToString(result)
|
|
25
|
+
},
|
|
40
26
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
generateDarkenColorFrom: function (input, percentage = 0.07) {
|
|
28
|
+
const result = interpolate([input, "black"], "oklch")(percentage)
|
|
29
|
+
return this.colorObjToString(result)
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
convertColorFormat: function (input) {
|
|
33
|
+
if (typeof input !== "object" || input === null) {
|
|
34
|
+
return input
|
|
47
35
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
36
|
+
|
|
37
|
+
const resultObj = {}
|
|
38
|
+
|
|
39
|
+
Object.entries(input).forEach(([rule, value]) => {
|
|
40
|
+
if (Object.hasOwn(colorNames,rule)) {
|
|
41
|
+
const colorObj = toGamutOKLCH(value)
|
|
42
|
+
resultObj[colorNames[rule]] = this.colorObjToString(colorObj)
|
|
51
43
|
} else {
|
|
52
|
-
resultObj[
|
|
44
|
+
resultObj[rule] = value
|
|
53
45
|
}
|
|
54
|
-
}
|
|
55
46
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
47
|
+
// auto generate base colors
|
|
48
|
+
if (!Object.hasOwn(input, "base-100")) {
|
|
49
|
+
resultObj["--b1"] = "100 0 0"
|
|
50
|
+
}
|
|
51
|
+
if (!Object.hasOwn(input, "base-200")) {
|
|
52
|
+
resultObj["--b2"] = this.generateDarkenColorFrom(input["base-100"], 0.07)
|
|
53
|
+
}
|
|
54
|
+
if (!Object.hasOwn(input, "base-300")) {
|
|
55
|
+
if (Object.hasOwn(input, "base-200")) {
|
|
56
|
+
resultObj["--b3"] = this.generateDarkenColorFrom(input["base-200"], 0.07)
|
|
57
|
+
} else {
|
|
58
|
+
resultObj["--b3"] = this.generateDarkenColorFrom(input["base-100"], 0.14)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
69
61
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!Object.hasOwn(input, "primary-content")) {
|
|
75
|
-
resultObj["--pc"] = generateForegroundColorFrom(input["primary"], 0.8)
|
|
76
|
-
}
|
|
77
|
-
if (!Object.hasOwn(input, "secondary-content")) {
|
|
78
|
-
resultObj["--sc"] = generateForegroundColorFrom(input["secondary"], 0.8)
|
|
79
|
-
}
|
|
80
|
-
if (!Object.hasOwn(input, "accent-content")) {
|
|
81
|
-
resultObj["--ac"] = generateForegroundColorFrom(input["accent"], 0.8)
|
|
82
|
-
}
|
|
83
|
-
if (!Object.hasOwn(input, "neutral-content")) {
|
|
84
|
-
resultObj["--nc"] = generateForegroundColorFrom(input["neutral"], 0.8)
|
|
85
|
-
}
|
|
86
|
-
if (!Object.hasOwn(input, "info-content")) {
|
|
87
|
-
if (Object.hasOwn(input, "info")) {
|
|
88
|
-
resultObj["--inc"] = generateForegroundColorFrom(input["info"], 0.8)
|
|
89
|
-
} else {
|
|
90
|
-
resultObj["--inc"] = "0 0 0"
|
|
62
|
+
// auto generate state colors
|
|
63
|
+
|
|
64
|
+
if (!Object.hasOwn(input, "info")) {
|
|
65
|
+
resultObj["--in"] = "0.7206 0.191 231.6"
|
|
91
66
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (Object.hasOwn(input, "success")) {
|
|
95
|
-
resultObj["--suc"] = generateForegroundColorFrom(input["success"], 0.8)
|
|
96
|
-
} else {
|
|
97
|
-
resultObj["--suc"] = "0 0 0"
|
|
67
|
+
if (!Object.hasOwn(input, "success")) {
|
|
68
|
+
resultObj["--su"] = "0.7441 0.213 164.75"
|
|
98
69
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (Object.hasOwn(input, "warning")) {
|
|
102
|
-
resultObj["--wac"] = generateForegroundColorFrom(input["warning"], 0.8)
|
|
103
|
-
} else {
|
|
104
|
-
resultObj["--wac"] = "0 0 0"
|
|
70
|
+
if (!Object.hasOwn(input, "warning")) {
|
|
71
|
+
resultObj["--wa"] = "0.8471 0.199 83.87"
|
|
105
72
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (Object.hasOwn(input, "error")) {
|
|
109
|
-
resultObj["--erc"] = generateForegroundColorFrom(input["error"], 0.8)
|
|
110
|
-
} else {
|
|
111
|
-
resultObj["--erc"] = "0 0 0"
|
|
73
|
+
if (!Object.hasOwn(input, "error")) {
|
|
74
|
+
resultObj["--er"] = "0.7176 0.221 22.18"
|
|
112
75
|
}
|
|
113
|
-
}
|
|
114
76
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
77
|
+
// auto generate content colors
|
|
78
|
+
if (!Object.hasOwn(input, "base-content")) {
|
|
79
|
+
resultObj["--bc"] = this.generateForegroundColorFrom(input["base-100"], 0.8)
|
|
80
|
+
}
|
|
81
|
+
if (!Object.hasOwn(input, "primary-content")) {
|
|
82
|
+
resultObj["--pc"] = this.generateForegroundColorFrom(input["primary"], 0.8)
|
|
83
|
+
}
|
|
84
|
+
if (!Object.hasOwn(input, "secondary-content")) {
|
|
85
|
+
resultObj["--sc"] = this.generateForegroundColorFrom(input["secondary"], 0.8)
|
|
86
|
+
}
|
|
87
|
+
if (!Object.hasOwn(input, "accent-content")) {
|
|
88
|
+
resultObj["--ac"] = this.generateForegroundColorFrom(input["accent"], 0.8)
|
|
89
|
+
}
|
|
90
|
+
if (!Object.hasOwn(input, "neutral-content")) {
|
|
91
|
+
resultObj["--nc"] = this.generateForegroundColorFrom(input["neutral"], 0.8)
|
|
92
|
+
}
|
|
93
|
+
if (!Object.hasOwn(input, "info-content")) {
|
|
94
|
+
if (Object.hasOwn(input, "info")) {
|
|
95
|
+
resultObj["--inc"] = this.generateForegroundColorFrom(input["info"], 0.8)
|
|
96
|
+
} else {
|
|
97
|
+
resultObj["--inc"] = "0 0 0"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!Object.hasOwn(input, "success-content")) {
|
|
101
|
+
if (Object.hasOwn(input, "success")) {
|
|
102
|
+
resultObj["--suc"] = this.generateForegroundColorFrom(input["success"], 0.8)
|
|
103
|
+
} else {
|
|
104
|
+
resultObj["--suc"] = "0 0 0"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (!Object.hasOwn(input, "warning-content")) {
|
|
108
|
+
if (Object.hasOwn(input, "warning")) {
|
|
109
|
+
resultObj["--wac"] = this.generateForegroundColorFrom(input["warning"], 0.8)
|
|
110
|
+
} else {
|
|
111
|
+
resultObj["--wac"] = "0 0 0"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (!Object.hasOwn(input, "error-content")) {
|
|
115
|
+
if (Object.hasOwn(input, "error")) {
|
|
116
|
+
resultObj["--erc"] = this.generateForegroundColorFrom(input["error"], 0.8)
|
|
117
|
+
} else {
|
|
118
|
+
resultObj["--erc"] = "0 0 0"
|
|
119
|
+
}
|
|
119
120
|
}
|
|
120
|
-
})
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
// add css variables if not exist
|
|
123
|
+
Object.entries(themeDefaults.variables).forEach((item) => {
|
|
124
|
+
const [variable, value] = item
|
|
125
|
+
if (!Object.hasOwn(input, variable)) {
|
|
126
|
+
resultObj[variable] = value
|
|
127
|
+
}
|
|
128
|
+
})
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const includedThemesObj = {}
|
|
132
|
-
// add default themes
|
|
133
|
-
const themeRoot = config("daisyui.themeRoot") ?? ":root"
|
|
134
|
-
Object.entries(themes).forEach(([theme, value]) => {
|
|
135
|
-
includedThemesObj[theme] = convertColorFormat(value)
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
// add custom themes
|
|
139
|
-
if (Array.isArray(config("daisyui.themes"))) {
|
|
140
|
-
config("daisyui.themes").forEach((item) => {
|
|
141
|
-
if (typeof item === "object" && item !== null) {
|
|
142
|
-
Object.entries(item).forEach(([customThemeName, customThemevalue]) => {
|
|
143
|
-
includedThemesObj[customThemeName] = convertColorFormat(customThemevalue)
|
|
144
|
-
})
|
|
130
|
+
// add other custom styles
|
|
131
|
+
if (!Object.hasOwn(colorNames,rule)) {
|
|
132
|
+
resultObj[rule] = value
|
|
145
133
|
}
|
|
146
134
|
})
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
themeOrder.push(theme)
|
|
158
|
-
}
|
|
135
|
+
|
|
136
|
+
return resultObj
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
injectThemes: function (addBase, config, themes) {
|
|
140
|
+
const includedThemesObj = {}
|
|
141
|
+
// add default themes
|
|
142
|
+
const themeRoot = config("daisyui.themeRoot") ?? ":root"
|
|
143
|
+
Object.entries(themes).forEach(([theme, value]) => {
|
|
144
|
+
includedThemesObj[theme] = this.convertColorFormat(value)
|
|
159
145
|
})
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
themeOrder.forEach((themeName, index) => {
|
|
169
|
-
if (index === 0) {
|
|
170
|
-
// first theme as root
|
|
171
|
-
themesToInject[themeRoot] = includedThemesObj[themeName]
|
|
172
|
-
} else if (index === 1) {
|
|
173
|
-
// auto dark
|
|
174
|
-
if (config("daisyui.darkTheme")) {
|
|
175
|
-
if (
|
|
176
|
-
themeOrder[0] !== config("daisyui.darkTheme") &&
|
|
177
|
-
themeOrder.includes(config("daisyui.darkTheme"))
|
|
178
|
-
) {
|
|
179
|
-
themesToInject["@media (prefers-color-scheme: dark)"] = {
|
|
180
|
-
[themeRoot]: includedThemesObj[`${config("daisyui.darkTheme")}`],
|
|
181
|
-
}
|
|
146
|
+
|
|
147
|
+
// add custom themes
|
|
148
|
+
if (Array.isArray(config("daisyui.themes"))) {
|
|
149
|
+
config("daisyui.themes").forEach((item) => {
|
|
150
|
+
if (typeof item === "object" && item !== null) {
|
|
151
|
+
Object.entries(item).forEach(([customThemeName, customThemevalue]) => {
|
|
152
|
+
includedThemesObj[customThemeName] = this.convertColorFormat(customThemevalue)
|
|
153
|
+
})
|
|
182
154
|
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
let themeOrder = []
|
|
159
|
+
if (Array.isArray(config("daisyui.themes"))) {
|
|
160
|
+
config("daisyui.themes").forEach((theme) => {
|
|
161
|
+
if (typeof theme === "object" && theme !== null) {
|
|
162
|
+
Object.keys(theme).forEach((customThemeName) => {
|
|
163
|
+
themeOrder.push(customThemeName)
|
|
164
|
+
})
|
|
165
|
+
} else if (Object.hasOwn(includedThemesObj, theme)) {
|
|
166
|
+
themeOrder.push(theme)
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
} else if (config("daisyui.themes") === true) {
|
|
170
|
+
themeOrder = themeDefaults.themeOrder
|
|
171
|
+
} else {
|
|
172
|
+
themeOrder = ["light", "dark"]
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// inject themes in order
|
|
176
|
+
const themesToInject = {}
|
|
177
|
+
themeOrder.forEach((themeName, index) => {
|
|
178
|
+
if (index === 0) {
|
|
179
|
+
// first theme as root
|
|
180
|
+
themesToInject[themeRoot] = includedThemesObj[themeName]
|
|
181
|
+
} else if (index === 1) {
|
|
182
|
+
// auto dark
|
|
183
|
+
if (config("daisyui.darkTheme")) {
|
|
184
|
+
if (
|
|
185
|
+
themeOrder[0] !== config("daisyui.darkTheme") &&
|
|
186
|
+
themeOrder.includes(config("daisyui.darkTheme"))
|
|
187
|
+
) {
|
|
188
|
+
themesToInject["@media (prefers-color-scheme: dark)"] = {
|
|
189
|
+
[themeRoot]: includedThemesObj[`${config("daisyui.darkTheme")}`],
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
} else if (config("daisyui.darkTheme") === false) {
|
|
193
|
+
// disables prefers-color-scheme: dark
|
|
194
|
+
} else {
|
|
195
|
+
if (themeOrder[0] !== "dark" && themeOrder.includes("dark")) {
|
|
196
|
+
themesToInject["@media (prefers-color-scheme: dark)"] = {
|
|
197
|
+
[themeRoot]: includedThemesObj["dark"],
|
|
198
|
+
}
|
|
188
199
|
}
|
|
189
200
|
}
|
|
201
|
+
// theme 0 with name
|
|
202
|
+
themesToInject["[data-theme=" + themeOrder[0] + "]"] = includedThemesObj[themeOrder[0]]
|
|
203
|
+
themesToInject[
|
|
204
|
+
themeRoot + ":has(input.theme-controller[value=" + themeOrder[0] + "]:checked)"
|
|
205
|
+
] = includedThemesObj[themeOrder[0]]
|
|
206
|
+
// theme 1 with name
|
|
207
|
+
themesToInject["[data-theme=" + themeOrder[1] + "]"] = includedThemesObj[themeOrder[1]]
|
|
208
|
+
themesToInject[
|
|
209
|
+
themeRoot + ":has(input.theme-controller[value=" + themeOrder[1] + "]:checked)"
|
|
210
|
+
] = includedThemesObj[themeOrder[1]]
|
|
211
|
+
} else {
|
|
212
|
+
themesToInject["[data-theme=" + themeName + "]"] = includedThemesObj[themeName]
|
|
213
|
+
themesToInject[
|
|
214
|
+
themeRoot + ":has(input.theme-controller[value=" + themeName + "]:checked)"
|
|
215
|
+
] = includedThemesObj[themeName]
|
|
190
216
|
}
|
|
191
|
-
|
|
192
|
-
themesToInject["[data-theme=" + themeOrder[0] + "]"] = includedThemesObj[themeOrder[0]]
|
|
193
|
-
themesToInject[
|
|
194
|
-
themeRoot + ":has(input.theme-controller[value=" + themeOrder[0] + "]:checked)"
|
|
195
|
-
] = includedThemesObj[themeOrder[0]]
|
|
196
|
-
// theme 1 with name
|
|
197
|
-
themesToInject["[data-theme=" + themeOrder[1] + "]"] = includedThemesObj[themeOrder[1]]
|
|
198
|
-
themesToInject[
|
|
199
|
-
themeRoot + ":has(input.theme-controller[value=" + themeOrder[1] + "]:checked)"
|
|
200
|
-
] = includedThemesObj[themeOrder[1]]
|
|
201
|
-
} else {
|
|
202
|
-
themesToInject["[data-theme=" + themeName + "]"] = includedThemesObj[themeName]
|
|
203
|
-
themesToInject[themeRoot + ":has(input.theme-controller[value=" + themeName + "]:checked)"] =
|
|
204
|
-
includedThemesObj[themeName]
|
|
205
|
-
}
|
|
206
|
-
})
|
|
217
|
+
})
|
|
207
218
|
|
|
208
|
-
|
|
219
|
+
addBase(themesToInject)
|
|
209
220
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
221
|
+
return {
|
|
222
|
+
includedThemesObj,
|
|
223
|
+
themeOrder,
|
|
224
|
+
}
|
|
225
|
+
},
|
|
214
226
|
}
|
package/src/theming/index.js
CHANGED