daisyui 4.1.0-alpha.1 → 4.1.0-alpha.2
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/package.json +1 -1
- package/src/theming/functions.js +6 -9
package/package.json
CHANGED
package/src/theming/functions.js
CHANGED
|
@@ -3,6 +3,9 @@ import { variables, themesOrder } from "./themeDefaults"
|
|
|
3
3
|
|
|
4
4
|
import { toGamut, interpolate, wcagContrast } from "culori"
|
|
5
5
|
|
|
6
|
+
const cutNumber = (number) => (number ? +number.toFixed(6) : 0)
|
|
7
|
+
const toGamutOKLCH = toGamut("oklch")
|
|
8
|
+
|
|
6
9
|
export function isDark(color) {
|
|
7
10
|
if (wcagContrast(color, "black") < wcagContrast(color, "white")) {
|
|
8
11
|
return true
|
|
@@ -10,14 +13,8 @@ export function isDark(color) {
|
|
|
10
13
|
return false
|
|
11
14
|
}
|
|
12
15
|
export function colorObjToString(input) {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
return 0
|
|
16
|
-
}
|
|
17
|
-
return +number.toFixed(6)
|
|
18
|
-
}
|
|
19
|
-
const { l, c, h } = input
|
|
20
|
-
return `${cut(l)} ${cut(c)} ${cut(h)}`
|
|
16
|
+
const { colorLightness, colorChroma, colorHue } = input
|
|
17
|
+
return `${cutNumber(colorLightness)} ${cutNumber(colorChroma)} ${cutNumber(colorHue)}`
|
|
21
18
|
}
|
|
22
19
|
export function generateForegroundColorFrom(input, percentage = 0.8) {
|
|
23
20
|
const result = interpolate([input, isDark(input) ? "white" : "black"], "oklch")(percentage)
|
|
@@ -36,7 +33,7 @@ export function convertColorFormat(input) {
|
|
|
36
33
|
|
|
37
34
|
Object.entries(input).forEach(([rule, value]) => {
|
|
38
35
|
if (colorNames.hasOwnProperty(rule)) {
|
|
39
|
-
const colorObj =
|
|
36
|
+
const colorObj = toGamutOKLCH("oklch")(value)
|
|
40
37
|
resultObj[colorNames[rule]] = colorObjToString(colorObj)
|
|
41
38
|
} else {
|
|
42
39
|
resultObj[rule] = value
|