@thiagormoreira/nightwind 1.3.3 → 2.0.1
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/.github/workflows/ci.yml +1 -1
- package/CHANGELOG.md +13 -1
- package/package.json +4 -1
- package/src/index.js +209 -651
package/.github/workflows/ci.yml
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,19 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [2.0.0] - 2026-02-20
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Universal Opacity Support**: Dynamic CSS attribute selectors ([class*=".../"]) now support ANY opacity modifier (including arbitrary values like `bg-red-500/[0.3]`) with zero performance overhead.
|
|
12
|
+
- **100% Color Utility Coverage**: Added support for `outline-`, `decoration-`, `accent-`, `caret-`, `fill-`, `stroke-`, and `shadow-color` (via `--tw-shadow-color`).
|
|
13
|
+
- **Enhanced Transitions**: Default transition duration increased to `400ms` with `ease-in-out` for a smoother theme-switching experience.
|
|
14
|
+
- **Compatibility**: Verified support for Tailwind CSS v3 and prepared for v4 "CSS-first" configuration.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- **PostCSS Performance**: Resolved Out-Of-Memory (OOM) errors and hangs caused by static opacity combinatorial explosion.
|
|
18
|
+
- **Color Inversion Precision**: Improved `white`/`black` inversion when modifiers are present.
|
|
19
|
+
- **Utility Conflicts**: Fixed detection logic for overlapping utilities like `ring-` and `ring-offset-`.
|
|
20
|
+
- **Selector Robustness**: Improved handling of `::placeholder`, `divide`, and complex pseudo-variants.
|
|
9
21
|
|
|
10
22
|
## [1.1.13] - 2023-02-21
|
|
11
23
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thiagormoreira/nightwind",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "An automatic, overridable, customisable Tailwind dark mode plugin",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
"lint": "eslint .",
|
|
32
32
|
"format": "prettier --write \"**/*.{js,jsx,json,md}\""
|
|
33
33
|
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=20.12.0"
|
|
36
|
+
},
|
|
34
37
|
"devDependencies": {
|
|
35
38
|
"@tailwindcss/postcss": "^4.2.0",
|
|
36
39
|
"autoprefixer": "^10.4.24",
|
package/src/index.js
CHANGED
|
@@ -1,60 +1,39 @@
|
|
|
1
1
|
const plugin = require("tailwindcss/plugin")
|
|
2
2
|
|
|
3
3
|
const nightwind = plugin(
|
|
4
|
-
function ({ addComponents, addUtilities, theme, variants, config }) {
|
|
4
|
+
function ({ addBase, addComponents, addUtilities, theme, variants, config }) {
|
|
5
5
|
const darkSelector = ".dark"
|
|
6
|
-
const fixedElementClass = `.${theme(
|
|
7
|
-
|
|
8
|
-
"nightwind-prevent"
|
|
9
|
-
)}`
|
|
10
|
-
const fixedBlockClass = `.${theme(
|
|
11
|
-
"nightwind.fixedBlockClass",
|
|
12
|
-
"nightwind-prevent-block"
|
|
13
|
-
)}`
|
|
6
|
+
const fixedElementClass = `.${theme("nightwind.fixedClass", "nightwind-prevent")}`
|
|
7
|
+
const fixedBlockClass = `.${theme("nightwind.fixedBlockClass", "nightwind-prevent-block")}`
|
|
14
8
|
const transitionConfig = theme("nightwind.transitionClasses", "default")
|
|
9
|
+
const colors = theme("colors")
|
|
15
10
|
const colorClasses = []
|
|
16
11
|
const transitionClasses = []
|
|
17
12
|
const typographyValues = {}
|
|
18
13
|
const typographyClasses = []
|
|
19
|
-
const colors = theme("colors")
|
|
20
14
|
const colorVariants = ["hover"]
|
|
21
|
-
const prefixes = ["text", "bg", "border"]
|
|
15
|
+
const prefixes = ["text", "bg", "border", "ring", "ring-offset", "divide", "placeholder", "outline", "decoration", "accent", "caret", "fill", "stroke", "shadow", "from", "via", "to"]
|
|
22
16
|
const weights = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900]
|
|
23
17
|
let importantSelector = ""
|
|
24
18
|
let importantProperty = ""
|
|
25
19
|
|
|
26
20
|
if (variants("nightwind")) {
|
|
27
|
-
typeof variants("nightwind") === "object"
|
|
28
|
-
? colorVariants.push(...variants("nightwind"))
|
|
29
|
-
: colorVariants.push(variants("nightwind"))
|
|
21
|
+
typeof variants("nightwind") === "object" ? colorVariants.push(...variants("nightwind")) : colorVariants.push(variants("nightwind"))
|
|
30
22
|
} else if (variants("nightwind.variants")) {
|
|
31
|
-
typeof variants("nightwind.variants") === "object"
|
|
32
|
-
? colorVariants.push(...variants("nightwind.variants"))
|
|
33
|
-
: colorVariants.push(variants("nightwind.variants"))
|
|
23
|
+
typeof variants("nightwind.variants") === "object" ? colorVariants.push(...variants("nightwind.variants")) : colorVariants.push(variants("nightwind.variants"))
|
|
34
24
|
}
|
|
35
25
|
|
|
36
26
|
if (theme("nightwind.colorClasses")) {
|
|
37
|
-
typeof theme("nightwind.colorClasses") === "object"
|
|
38
|
-
? prefixes.push(...theme("nightwind.colorClasses"))
|
|
39
|
-
: prefixes.push(theme("nightwind.colorClasses"))
|
|
27
|
+
typeof theme("nightwind.colorClasses") === "object" ? prefixes.push(...theme("nightwind.colorClasses")) : prefixes.push(theme("nightwind.colorClasses"))
|
|
40
28
|
if (theme("nightwind.colorClasses").includes("gradient")) {
|
|
41
|
-
prefixes
|
|
42
|
-
prefixes.push(...["from", "via", "to"])
|
|
43
|
-
}
|
|
44
|
-
} else if (variants("nightwind.colorClasses")) {
|
|
45
|
-
typeof variants("nightwind.colorClasses") === "object"
|
|
46
|
-
? prefixes.push(...variants("nightwind.colorClasses"))
|
|
47
|
-
: prefixes.push(variants("nightwind.colorClasses"))
|
|
48
|
-
if (variants("nightwind.colorClasses").includes("gradient")) {
|
|
49
|
-
prefixes.splice(prefixes.indexOf("gradient"), 1)
|
|
50
|
-
prefixes.push(...["from", "via", "to"])
|
|
29
|
+
// Gradient already handled in default prefixes now, but keeping for compatibility
|
|
30
|
+
if (!prefixes.includes("from")) prefixes.push(...["from", "via", "to"])
|
|
51
31
|
}
|
|
52
32
|
}
|
|
53
33
|
|
|
54
34
|
if (config("important")) {
|
|
55
35
|
if (typeof config("important") === "string") {
|
|
56
|
-
importantSelector = `${config("important")}${theme("nightwind.importantNode") ? "" : " "
|
|
57
|
-
}`
|
|
36
|
+
importantSelector = `${config("important")}${theme("nightwind.importantNode") ? "" : " "}`
|
|
58
37
|
}
|
|
59
38
|
if (config("important") === true) {
|
|
60
39
|
importantProperty = " !important"
|
|
@@ -62,28 +41,14 @@ const nightwind = plugin(
|
|
|
62
41
|
}
|
|
63
42
|
|
|
64
43
|
function hexToRGB(h, alpha) {
|
|
65
|
-
if (h.includes("var(--"))
|
|
66
|
-
return h
|
|
67
|
-
}
|
|
44
|
+
if (!h || h.includes("var(--")) return h
|
|
68
45
|
if (h.length == 4) {
|
|
69
|
-
let rh = h[1] + h[1]
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var r = parseInt(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
if (h.length == 7) {
|
|
77
|
-
var r = parseInt(h.slice(1, 3), 16),
|
|
78
|
-
g = parseInt(h.slice(3, 5), 16),
|
|
79
|
-
b = parseInt(h.slice(5, 7), 16)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (alpha) {
|
|
83
|
-
return "rgba(" + r + ", " + g + ", " + b + ", " + alpha + ")"
|
|
84
|
-
} else {
|
|
85
|
-
return "rgb(" + r + ", " + g + ", " + b + ")"
|
|
86
|
-
}
|
|
46
|
+
let rh = h[1] + h[1], gh = h[2] + h[2], bh = h[3] + h[3]
|
|
47
|
+
var r = parseInt(rh, 16), g = parseInt(gh, 16), b = parseInt(bh, 16)
|
|
48
|
+
} else if (h.length == 7) {
|
|
49
|
+
var r = parseInt(h.slice(1, 3), 16), g = parseInt(h.slice(3, 5), 16), b = parseInt(h.slice(5, 7), 16)
|
|
50
|
+
} else return h
|
|
51
|
+
return alpha ? `rgba(${r}, ${g}, ${b}, ${alpha})` : `rgb(${r}, ${g}, ${b})`
|
|
87
52
|
}
|
|
88
53
|
|
|
89
54
|
const hexToTailwind = (hex) => {
|
|
@@ -91,144 +56,55 @@ const nightwind = plugin(
|
|
|
91
56
|
if (hex != "inherit" && hex != "current" && hex != "transparent") {
|
|
92
57
|
Object.keys(colors).forEach((col) => {
|
|
93
58
|
if (typeof theme(`colors.${col}`) === "string") {
|
|
94
|
-
if (hex === theme(`colors.${col}`))
|
|
95
|
-
colorCode = col
|
|
96
|
-
}
|
|
59
|
+
if (hex === theme(`colors.${col}`)) colorCode = col
|
|
97
60
|
} else if (typeof theme(`colors.${col}`) === "object") {
|
|
98
61
|
Object.keys(theme(`colors.${col}`)).forEach((wei) => {
|
|
99
|
-
if (hex === theme(`colors.${col}.${wei}`))
|
|
100
|
-
colorCode = col + "-" + wei
|
|
101
|
-
}
|
|
62
|
+
if (hex === theme(`colors.${col}.${wei}`)) colorCode = col + "-" + wei
|
|
102
63
|
})
|
|
103
64
|
}
|
|
104
65
|
})
|
|
105
|
-
} else
|
|
106
|
-
colorCode = hex
|
|
107
|
-
}
|
|
66
|
+
} else colorCode = hex
|
|
108
67
|
return colorCode
|
|
109
68
|
}
|
|
110
69
|
|
|
111
|
-
// Invert color logic
|
|
112
|
-
|
|
113
|
-
let whiteSelector = "#000"
|
|
114
|
-
let blackSelector = "#fff"
|
|
115
|
-
if (theme(`nightwind.colors.white`)) {
|
|
116
|
-
const colorMap = theme(`nightwind.colors.white`)
|
|
117
|
-
whiteSelector = theme(`colors.${colorMap}`)
|
|
118
|
-
? theme(`colors.${colorMap}`)
|
|
119
|
-
: colorMap
|
|
120
|
-
}
|
|
121
|
-
if (theme(`nightwind.colors.black`)) {
|
|
122
|
-
const colorMap = theme(`nightwind.colors.black`)
|
|
123
|
-
blackSelector = theme(`colors.${colorMap}`)
|
|
124
|
-
? theme(`colors.${colorMap}`)
|
|
125
|
-
: colorMap
|
|
126
|
-
}
|
|
127
|
-
|
|
128
70
|
const invertColor = (colorClass) => {
|
|
129
71
|
if (colorClass.includes("white") || colorClass.includes("black")) {
|
|
130
72
|
return {
|
|
131
|
-
colorValue: colorClass.includes("white")
|
|
132
|
-
|
|
133
|
-
: blackSelector,
|
|
134
|
-
defaultColorValue: colorClass.includes("white")
|
|
135
|
-
? theme("colors.white")
|
|
136
|
-
: theme("colors.black"),
|
|
73
|
+
colorValue: colorClass.includes("white") ? (theme("nightwind.colors.white") ? (theme("colors." + theme("nightwind.colors.white")) || theme("nightwind.colors.white")) : "#000") : (theme("nightwind.colors.black") ? (theme("colors." + theme("nightwind.colors.black")) || theme("nightwind.colors.black")) : "#fff"),
|
|
74
|
+
defaultColorValue: colorClass.includes("white") ? theme("colors.white") : theme("colors.black"),
|
|
137
75
|
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
colorClass === "transparent" ||
|
|
141
|
-
colorClass === "current"
|
|
142
|
-
) {
|
|
143
|
-
return {
|
|
144
|
-
colorValue: colorClass,
|
|
145
|
-
defaultColorValue: colorClass,
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
const colorValues = colorClass.split("-")
|
|
149
|
-
const weight = colorValues.pop()
|
|
150
|
-
const color = colorValues.pop()
|
|
151
|
-
const defaultValue = theme(`colors.${color}.${weight}`)
|
|
76
|
+
}
|
|
77
|
+
if (colorClass === "inherit" || colorClass === "transparent" || colorClass === "current") return { colorValue: colorClass, defaultColorValue: colorClass }
|
|
152
78
|
|
|
153
|
-
|
|
154
|
-
|
|
79
|
+
const colorValues = colorClass.split("-")
|
|
80
|
+
const weight = colorValues.pop()
|
|
81
|
+
const color = colorValues.pop()
|
|
82
|
+
const defaultValue = theme(`colors.${color}.${weight}`)
|
|
83
|
+
if (!defaultValue) return { colorValue: null, defaultColorValue: null }
|
|
155
84
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
case "reduced":
|
|
159
|
-
let reducedInvertWeightIndex =
|
|
160
|
-
10 - weights.indexOf(Number(weight))
|
|
161
|
-
reducedInvertWeightIndex > 9
|
|
162
|
-
? (reducedInvertWeightIndex = 9)
|
|
163
|
-
: reducedInvertWeightIndex
|
|
164
|
-
invertWeight = String(weights[reducedInvertWeightIndex])
|
|
165
|
-
break
|
|
166
|
-
}
|
|
167
|
-
} else if (theme("nightwind.colorScale")) {
|
|
168
|
-
if (theme(`nightwind.colorScale.${weight}`)) {
|
|
169
|
-
invertWeight = String(theme(`nightwind.colorScale.${weight}`))
|
|
170
|
-
}
|
|
171
|
-
}
|
|
85
|
+
let invertWeightIndex = 9 - weights.indexOf(Number(weight))
|
|
86
|
+
let invertWeight = String(weights[invertWeightIndex])
|
|
172
87
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
) {
|
|
185
|
-
const colorMap = theme(`nightwind.colors.${color}`)
|
|
186
|
-
if (theme(`colors.${colorMap}.${invertWeight}`)) {
|
|
187
|
-
return {
|
|
188
|
-
colorValue: theme(`colors.${colorMap}.${invertWeight}`),
|
|
189
|
-
defaultColorValue: defaultValue,
|
|
190
|
-
}
|
|
191
|
-
} else if (colorMap.split(".").length === 2) {
|
|
192
|
-
return {
|
|
193
|
-
colorValue: theme(`colors.${colorMap}`),
|
|
194
|
-
defaultColorValue: defaultValue,
|
|
195
|
-
}
|
|
196
|
-
} else if (
|
|
197
|
-
theme(`colors.${colorMap}`) &&
|
|
198
|
-
theme(`colors.${color}.${invertWeight}`)
|
|
199
|
-
) {
|
|
200
|
-
return {
|
|
201
|
-
colorValue: theme(`colors.${color}.${invertWeight}`),
|
|
202
|
-
defaultColorValue: defaultValue,
|
|
203
|
-
}
|
|
204
|
-
} else {
|
|
205
|
-
return {
|
|
206
|
-
colorValue: colorMap,
|
|
207
|
-
defaultColorValue: defaultValue,
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
} else if (theme(`nightwind.colors.${color}.default`)) {
|
|
211
|
-
const colorMap = theme(`nightwind.colors.${color}.default`)
|
|
212
|
-
return {
|
|
213
|
-
colorValue: theme(`colors.${colorMap}.${invertWeight}`),
|
|
214
|
-
defaultColorValue: defaultValue,
|
|
215
|
-
}
|
|
216
|
-
} else {
|
|
217
|
-
return {
|
|
218
|
-
colorValue: theme(`colors.${color}.${invertWeight}`),
|
|
219
|
-
defaultColorValue: defaultValue,
|
|
220
|
-
}
|
|
221
|
-
}
|
|
88
|
+
if (theme("nightwind.colorScale.preset") === "reduced") {
|
|
89
|
+
let ri = 10 - weights.indexOf(Number(weight)); invertWeight = String(weights[ri > 9 ? 9 : ri])
|
|
90
|
+
} else if (theme(`nightwind.colorScale.${weight}`)) {
|
|
91
|
+
invertWeight = String(theme(`nightwind.colorScale.${weight}`))
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let colorValue = theme(`colors.${color}.${invertWeight}`)
|
|
95
|
+
if (theme(`nightwind.colors.${color}.${weight}`)) {
|
|
96
|
+
colorValue = theme(`colors.${theme(`nightwind.colors.${color}.${weight}`)}`) || theme(`nightwind.colors.${color}.${weight}`)
|
|
97
|
+
} else if (theme(`nightwind.colors.${color}`) && typeof theme(`nightwind.colors.${color}`) === "string") {
|
|
98
|
+
const colorMap = theme(`nightwind.colors.${color}`)
|
|
99
|
+
colorValue = theme(`colors.${colorMap}.${invertWeight}`) || theme(`colors.${colorMap}`) || theme(`colors.${color}.${invertWeight}`) || colorMap
|
|
222
100
|
}
|
|
101
|
+
|
|
102
|
+
return { colorValue, defaultColorValue: defaultValue }
|
|
223
103
|
}
|
|
224
104
|
|
|
225
105
|
// Generate transition classes
|
|
226
|
-
|
|
227
106
|
let transitionDurationValue = "400ms"
|
|
228
|
-
if (
|
|
229
|
-
theme("nightwind.transitionDuration") === false ||
|
|
230
|
-
theme("transitionDuration.nightwind") === false
|
|
231
|
-
) {
|
|
107
|
+
if (theme("nightwind.transitionDuration") === false || theme("transitionDuration.nightwind") === false) {
|
|
232
108
|
transitionDurationValue = ""
|
|
233
109
|
} else if (typeof theme("nightwind.transitionDuration") === "string") {
|
|
234
110
|
transitionDurationValue = theme("nightwind.transitionDuration")
|
|
@@ -238,535 +114,217 @@ const nightwind = plugin(
|
|
|
238
114
|
|
|
239
115
|
if (transitionDurationValue) {
|
|
240
116
|
const transitionPrefixes = []
|
|
241
|
-
if (transitionConfig === "full")
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
(typeof transitionConfig === "string" &&
|
|
246
|
-
prefixes.includes(transitionConfig))
|
|
247
|
-
) {
|
|
248
|
-
typeof transitionConfig === "object"
|
|
249
|
-
? transitionPrefixes.push(...transitionConfig)
|
|
250
|
-
: transitionPrefixes.push(transitionConfig)
|
|
251
|
-
} else {
|
|
252
|
-
transitionPrefixes.push("text", "bg", "border")
|
|
253
|
-
}
|
|
117
|
+
if (transitionConfig === "full") transitionPrefixes.push(...prefixes)
|
|
118
|
+
else if (typeof transitionConfig === "object" || (typeof transitionConfig === "string" && prefixes.includes(transitionConfig))) {
|
|
119
|
+
typeof transitionConfig === "object" ? transitionPrefixes.push(...transitionConfig) : transitionPrefixes.push(transitionConfig)
|
|
120
|
+
} else transitionPrefixes.push("text", "bg", "border")
|
|
254
121
|
|
|
255
122
|
Object.keys(colors).forEach((color) => {
|
|
256
123
|
transitionPrefixes.forEach((prefix) => {
|
|
257
|
-
if (prefix === "from" || prefix === "via" || prefix === "to")
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
color == "current" ||
|
|
263
|
-
color == "white" ||
|
|
264
|
-
color == "black"
|
|
265
|
-
) {
|
|
266
|
-
const transitionClass = {
|
|
267
|
-
[`${config("important") ? importantSelector : ""
|
|
268
|
-
}.nightwind .${prefix}-${color}`]: {
|
|
269
|
-
transitionDuration: transitionDurationValue,
|
|
270
|
-
transitionProperty: theme("transitionProperty.colors"),
|
|
271
|
-
transitionTimingFunction: "ease-in-out",
|
|
272
|
-
},
|
|
273
|
-
[`${config("important") ? importantSelector : ""
|
|
274
|
-
}.nightwind .dark\\:${prefix}-${color}`]: {
|
|
275
|
-
transitionDuration: transitionDurationValue,
|
|
276
|
-
transitionProperty: theme("transitionProperty.colors"),
|
|
277
|
-
transitionTimingFunction: "ease-in-out",
|
|
278
|
-
},
|
|
124
|
+
if (prefix === "from" || prefix === "via" || prefix === "to") return
|
|
125
|
+
if (color == "transparent" || color == "current" || color == "white" || color == "black") {
|
|
126
|
+
const tc = {
|
|
127
|
+
[`${config("important") ? importantSelector : ""}.nightwind .${prefix}-${color}`]: { transitionDuration: transitionDurationValue, transitionProperty: theme("transitionProperty.colors"), transitionTimingFunction: "ease-in-out" },
|
|
128
|
+
[`${config("important") ? importantSelector : ""}.nightwind .dark\\:${prefix}-${color}`]: { transitionDuration: transitionDurationValue, transitionProperty: theme("transitionProperty.colors"), transitionTimingFunction: "ease-in-out" },
|
|
279
129
|
}
|
|
280
|
-
transitionClasses.push(
|
|
130
|
+
transitionClasses.push(tc)
|
|
281
131
|
} else {
|
|
282
132
|
weights.forEach((weight) => {
|
|
283
|
-
const
|
|
284
|
-
[`${config("important") ? importantSelector : ""
|
|
285
|
-
|
|
286
|
-
transitionDuration: transitionDurationValue,
|
|
287
|
-
transitionProperty: theme("transitionProperty.colors"),
|
|
288
|
-
transitionTimingFunction: "ease-in-out",
|
|
289
|
-
},
|
|
290
|
-
[`${config("important") ? importantSelector : ""
|
|
291
|
-
}.nightwind .dark\\:${prefix}-${color}-${weight}`]: {
|
|
292
|
-
transitionDuration: transitionDurationValue,
|
|
293
|
-
transitionProperty: theme("transitionProperty.colors"),
|
|
294
|
-
transitionTimingFunction: "ease-in-out",
|
|
295
|
-
},
|
|
133
|
+
const tc = {
|
|
134
|
+
[`${config("important") ? importantSelector : ""}.nightwind .${prefix}-${color}-${weight}`]: { transitionDuration: transitionDurationValue, transitionProperty: theme("transitionProperty.colors"), transitionTimingFunction: "ease-in-out" },
|
|
135
|
+
[`${config("important") ? importantSelector : ""}.nightwind .dark\\:${prefix}-${color}-${weight}`]: { transitionDuration: transitionDurationValue, transitionProperty: theme("transitionProperty.colors"), transitionTimingFunction: "ease-in-out" },
|
|
296
136
|
}
|
|
297
|
-
transitionClasses.push(
|
|
137
|
+
transitionClasses.push(tc)
|
|
298
138
|
})
|
|
299
139
|
}
|
|
300
140
|
})
|
|
301
141
|
})
|
|
302
142
|
}
|
|
303
143
|
|
|
304
|
-
//
|
|
305
|
-
|
|
306
|
-
if (theme("nightwind.typography")) {
|
|
307
|
-
Object.keys(theme("typography")).forEach((modifier) => {
|
|
308
|
-
Object.keys(theme(`typography.${modifier}.css`)).forEach((n) => {
|
|
309
|
-
const themeParser = JSON.parse(
|
|
310
|
-
JSON.stringify(theme(`typography.${modifier}.css[${n}]`))
|
|
311
|
-
)
|
|
312
|
-
Object.keys(themeParser).forEach((classname) => {
|
|
313
|
-
const themeClass = themeParser[classname]
|
|
314
|
-
if (
|
|
315
|
-
typeof themeClass === "string" &&
|
|
316
|
-
(classname.includes("color") || classname.includes("Color"))
|
|
317
|
-
) {
|
|
318
|
-
const colorValue = hexToTailwind(themeClass)
|
|
319
|
-
if (!typographyValues[`${modifier}`]) {
|
|
320
|
-
typographyValues[`${modifier}`] = {}
|
|
321
|
-
}
|
|
322
|
-
if (!typographyValues[`${modifier}`]["prose"]) {
|
|
323
|
-
typographyValues[`${modifier}`]["prose"] = {}
|
|
324
|
-
}
|
|
325
|
-
typographyValues[`${modifier}`]["prose"][classname] = colorValue
|
|
326
|
-
} else if (typeof themeClass === "object") {
|
|
327
|
-
Object.keys(themeClass).forEach((property) => {
|
|
328
|
-
const themeProperty = themeClass[property]
|
|
329
|
-
if (
|
|
330
|
-
(typeof themeProperty === "string" &&
|
|
331
|
-
property.includes("color")) ||
|
|
332
|
-
property.includes("Color")
|
|
333
|
-
) {
|
|
334
|
-
const colorValue = hexToTailwind(themeProperty)
|
|
335
|
-
if (!typographyValues[`${modifier}`]) {
|
|
336
|
-
typographyValues[`${modifier}`] = {}
|
|
337
|
-
}
|
|
338
|
-
if (!typographyValues[`${modifier}`][`${classname}`]) {
|
|
339
|
-
typographyValues[`${modifier}`][`${classname}`] = {}
|
|
340
|
-
}
|
|
341
|
-
typographyValues[`${modifier}`][`${classname}`][property] =
|
|
342
|
-
colorValue
|
|
343
|
-
}
|
|
344
|
-
})
|
|
345
|
-
}
|
|
346
|
-
})
|
|
347
|
-
})
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
Object.keys(typographyValues).forEach((modifier) => {
|
|
351
|
-
Object.keys(typographyValues[modifier]).forEach((classname) => {
|
|
352
|
-
if (classname === "prose") {
|
|
353
|
-
Object.keys(typographyValues[modifier]["prose"]).forEach(
|
|
354
|
-
(property) => {
|
|
355
|
-
let themeValue = ""
|
|
356
|
-
let nightwindValue = ""
|
|
357
|
-
if (modifier === "DEFAULT") {
|
|
358
|
-
nightwindValue = theme(`nightwind.typography.${property}`)
|
|
359
|
-
} else {
|
|
360
|
-
nightwindValue = theme(
|
|
361
|
-
`nightwind.typography.${modifier}.${property}`
|
|
362
|
-
)
|
|
363
|
-
}
|
|
364
|
-
theme(`colors.${nightwindValue}`)
|
|
365
|
-
? (themeValue = theme(`colors.${nightwindValue}`))
|
|
366
|
-
: (themeValue = nightwindValue)
|
|
367
|
-
|
|
368
|
-
const colorValue = themeValue
|
|
369
|
-
? themeValue
|
|
370
|
-
: invertColor(typographyValues[modifier]["prose"][property])
|
|
371
|
-
.colorValue
|
|
372
|
-
const defaultColorValue = invertColor(
|
|
373
|
-
typographyValues[modifier]["prose"][property]
|
|
374
|
-
).defaultColorValue
|
|
375
|
-
|
|
376
|
-
const typographyClass = {
|
|
377
|
-
[`${importantSelector}${darkSelector} .prose${modifier !== "DEFAULT" ? `-${modifier}` : ""
|
|
378
|
-
}`]: {
|
|
379
|
-
[`${property}`]: colorValue,
|
|
380
|
-
},
|
|
381
|
-
[`${importantSelector}${darkSelector} ${fixedElementClass}.prose${modifier !== "DEFAULT" ? `-${modifier}` : ""
|
|
382
|
-
}`]: {
|
|
383
|
-
[`${property}`]: defaultColorValue,
|
|
384
|
-
},
|
|
385
|
-
[`${importantSelector}${darkSelector} ${fixedBlockClass} .prose${modifier !== "DEFAULT" ? `-${modifier}` : ""
|
|
386
|
-
}`]: {
|
|
387
|
-
[`${property}`]: defaultColorValue,
|
|
388
|
-
},
|
|
389
|
-
}
|
|
390
|
-
typographyClasses.push(typographyClass)
|
|
391
|
-
|
|
392
|
-
if (transitionDurationValue) {
|
|
393
|
-
const typographyTransitionClass = {
|
|
394
|
-
[`${config("important") ? importantSelector : ""
|
|
395
|
-
}.nightwind .prose${modifier !== "DEFAULT" ? `-${modifier}` : ""
|
|
396
|
-
}`]: {
|
|
397
|
-
transitionDuration: transitionDurationValue,
|
|
398
|
-
transitionProperty: theme("transitionProperty.colors"),
|
|
399
|
-
transitionTimingFunction: "ease-in-out",
|
|
400
|
-
},
|
|
401
|
-
[`${config("important") ? importantSelector : ""
|
|
402
|
-
}.nightwind .dark\\:prose${modifier !== "DEFAULT" ? `-${modifier}` : ""
|
|
403
|
-
}`]: {
|
|
404
|
-
transitionDuration: transitionDurationValue,
|
|
405
|
-
transitionProperty: theme("transitionProperty.colors"),
|
|
406
|
-
transitionTimingFunction: "ease-in-out",
|
|
407
|
-
},
|
|
408
|
-
}
|
|
409
|
-
transitionClasses.push(typographyTransitionClass)
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
)
|
|
413
|
-
} else {
|
|
414
|
-
Object.keys(typographyValues[modifier][classname]).forEach(
|
|
415
|
-
(property) => {
|
|
416
|
-
let themeValue = ""
|
|
417
|
-
let nightwindValue = ""
|
|
418
|
-
if (modifier === "DEFAULT") {
|
|
419
|
-
nightwindValue = theme(
|
|
420
|
-
`nightwind.typography.${classname}.${property}`
|
|
421
|
-
)
|
|
422
|
-
} else {
|
|
423
|
-
nightwindValue = theme(
|
|
424
|
-
`nightwind.typography.${modifier}.${classname}.${property}`
|
|
425
|
-
)
|
|
426
|
-
}
|
|
427
|
-
theme(`colors.${nightwindValue}`)
|
|
428
|
-
? (themeValue = theme(`colors.${nightwindValue}`))
|
|
429
|
-
: (themeValue = nightwindValue)
|
|
430
|
-
|
|
431
|
-
const colorValue = themeValue
|
|
432
|
-
? themeValue
|
|
433
|
-
: invertColor(typographyValues[modifier][classname][property])
|
|
434
|
-
.colorValue
|
|
435
|
-
const defaultColorValue = invertColor(
|
|
436
|
-
typographyValues[modifier][classname][property]
|
|
437
|
-
).defaultColorValue
|
|
438
|
-
|
|
439
|
-
const typographyClass = {
|
|
440
|
-
[`${importantSelector}${darkSelector} .prose${modifier !== "DEFAULT" ? `-${modifier}` : ""
|
|
441
|
-
} ${classname}`]: {
|
|
442
|
-
[`${property}`]: colorValue,
|
|
443
|
-
},
|
|
444
|
-
[`${importantSelector}${darkSelector} .prose${modifier !== "DEFAULT" ? `-${modifier}` : ""
|
|
445
|
-
} ${classname}${fixedElementClass}`]: {
|
|
446
|
-
[`${property}`]: defaultColorValue,
|
|
447
|
-
},
|
|
448
|
-
[`${importantSelector}${darkSelector} ${fixedBlockClass} .prose${modifier !== "DEFAULT" ? `-${modifier}` : ""
|
|
449
|
-
} ${classname}`]: {
|
|
450
|
-
[`${property}`]: defaultColorValue,
|
|
451
|
-
},
|
|
452
|
-
[`${importantSelector}${darkSelector} .prose${modifier !== "DEFAULT" ? `-${modifier}` : ""
|
|
453
|
-
} ${fixedBlockClass} ${classname}`]: {
|
|
454
|
-
[`${property}`]: defaultColorValue,
|
|
455
|
-
},
|
|
456
|
-
}
|
|
457
|
-
typographyClasses.push(typographyClass)
|
|
458
|
-
if (transitionDurationValue) {
|
|
459
|
-
const typographyTransitionClass = {
|
|
460
|
-
[`${config("important") ? importantSelector : ""
|
|
461
|
-
}.nightwind .prose${modifier !== "DEFAULT" ? `-${modifier}` : ""
|
|
462
|
-
} ${classname}`]: {
|
|
463
|
-
transitionDuration: transitionDurationValue,
|
|
464
|
-
transitionProperty: theme("transitionProperty.colors"),
|
|
465
|
-
transitionTimingFunction: "ease-in-out",
|
|
466
|
-
},
|
|
467
|
-
[`${config("important") ? importantSelector : ""
|
|
468
|
-
}.nightwind .dark\\:prose${modifier !== "DEFAULT" ? `-${modifier}` : ""
|
|
469
|
-
} ${classname}`]: {
|
|
470
|
-
transitionDuration: transitionDurationValue,
|
|
471
|
-
transitionProperty: theme("transitionProperty.colors"),
|
|
472
|
-
transitionTimingFunction: "ease-in-out",
|
|
473
|
-
},
|
|
474
|
-
}
|
|
475
|
-
transitionClasses.push(typographyTransitionClass)
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
)
|
|
479
|
-
}
|
|
480
|
-
})
|
|
481
|
-
})
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
// Compose color classes
|
|
485
|
-
|
|
144
|
+
// Compose colors
|
|
486
145
|
prefixes.forEach((prefix) => {
|
|
487
146
|
Object.keys(colors).forEach((color) => {
|
|
488
147
|
if (color == "white" || color == "black") {
|
|
489
|
-
|
|
490
|
-
colorClasses.push(
|
|
491
|
-
|
|
492
|
-
colorVariants.forEach((variant) => {
|
|
493
|
-
let baseVar = variant + "\\:" + prefix + "-" + color
|
|
494
|
-
colorClasses.push(baseVar)
|
|
495
|
-
})
|
|
496
|
-
} else {
|
|
497
|
-
return false
|
|
498
|
-
}
|
|
499
|
-
})
|
|
500
|
-
})
|
|
501
|
-
|
|
502
|
-
prefixes.forEach((prefix) => {
|
|
503
|
-
Object.keys(colors).forEach((color) => {
|
|
504
|
-
if (
|
|
505
|
-
color == "transparent" ||
|
|
506
|
-
color == "current" ||
|
|
507
|
-
color == "white" ||
|
|
508
|
-
color == "black"
|
|
509
|
-
) {
|
|
510
|
-
return false
|
|
511
|
-
} else if (typeof colors[color] !== "object") {
|
|
512
|
-
// Flat custom colors (e.g. { "custom-hex": "#1a2b3c" })
|
|
513
|
-
let base = prefix + "-" + color
|
|
514
|
-
colorClasses.push(base)
|
|
515
|
-
|
|
516
|
-
colorVariants.forEach((variant) => {
|
|
517
|
-
let baseVar = variant + "\\:" + prefix + "-" + color
|
|
518
|
-
colorClasses.push(baseVar)
|
|
519
|
-
})
|
|
520
|
-
} else {
|
|
521
|
-
// Nested colors (e.g. { "red": { "500": "#ef4444" } })
|
|
148
|
+
colorClasses.push(`${prefix}-${color}`)
|
|
149
|
+
colorVariants.forEach(v => colorClasses.push(`${v}\\:${prefix}-${color}`))
|
|
150
|
+
} else if (typeof colors[color] === "object") {
|
|
522
151
|
weights.forEach((weight) => {
|
|
523
|
-
|
|
524
|
-
colorClasses.push(
|
|
525
|
-
|
|
526
|
-
colorVariants.forEach((variant) => {
|
|
527
|
-
let baseVar =
|
|
528
|
-
variant + "\\:" + prefix + "-" + color + "-" + weight
|
|
529
|
-
colorClasses.push(baseVar)
|
|
530
|
-
})
|
|
152
|
+
colorClasses.push(`${prefix}-${color}-${weight}`)
|
|
153
|
+
colorVariants.forEach(v => colorClasses.push(`${v}\\:${prefix}-${color}-${weight}`))
|
|
531
154
|
})
|
|
532
155
|
}
|
|
533
156
|
})
|
|
534
157
|
})
|
|
535
158
|
|
|
536
|
-
// Generate dark classes
|
|
537
|
-
|
|
538
159
|
const nightwindClasses = colorClasses.map((colorClass) => {
|
|
539
160
|
let pseudoVariant = ""
|
|
161
|
+
colorVariants.forEach((v) => { if (colorClass.includes(v)) pseudoVariant = (v == "last" || v == "first") ? ":" + v + "-child" : (v == "odd") ? ":nth-child(odd)" : (v == "even") ? ":nth-child(2n)" : (v == "group-hover") ? "" : ":" + v })
|
|
540
162
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
} else if (variant == "odd") {
|
|
546
|
-
pseudoVariant = ":nth-child(odd)"
|
|
547
|
-
} else if (variant == "even") {
|
|
548
|
-
pseudoVariant = ":nth-child(2n)"
|
|
549
|
-
} else if (variant == "group-hover") {
|
|
550
|
-
pseudoVariant = ""
|
|
551
|
-
} else {
|
|
552
|
-
pseudoVariant = ":" + variant
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
})
|
|
163
|
+
const invertResults = invertColor(colorClass)
|
|
164
|
+
let colorValue = invertResults.colorValue
|
|
165
|
+
let defaultColorValue = invertResults.defaultColorValue
|
|
166
|
+
if (!colorValue) return null
|
|
556
167
|
|
|
557
|
-
let
|
|
558
|
-
let defaultColorValue = invertColor(colorClass).defaultColorValue
|
|
168
|
+
let cleanClass = colorClass.replace(/\\/g, "")
|
|
559
169
|
|
|
560
|
-
const generateClass = (prefix, property) => {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
const twOpacityVar = `var(--tw-${prefix})`
|
|
170
|
+
const generateClass = (prefix, property, selectorSuffix = "") => {
|
|
171
|
+
const twOpacityVar = `var(--tw-${prefix}, 1)`
|
|
172
|
+
const selector = `${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${selectorSuffix}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${selectorSuffix}`
|
|
564
173
|
return {
|
|
565
|
-
[
|
|
566
|
-
{
|
|
567
|
-
|
|
568
|
-
[`${property}`]:
|
|
569
|
-
hexToRGB(`${colorValue}`, twOpacityVar) +
|
|
570
|
-
importantProperty,
|
|
571
|
-
},
|
|
572
|
-
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} .${colorClass}\\/\\*${pseudoVariant}${fixedElementClass}`]:
|
|
573
|
-
{
|
|
574
|
-
[`${property}`]: defaultColorValue + importantProperty,
|
|
575
|
-
[`${property}`]:
|
|
576
|
-
hexToRGB(`${defaultColorValue}`, twOpacityVar) +
|
|
577
|
-
importantProperty,
|
|
578
|
-
},
|
|
579
|
-
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}\\/\\*${pseudoVariant}`]:
|
|
580
|
-
{
|
|
581
|
-
[`${property}`]: defaultColorValue + importantProperty,
|
|
582
|
-
[`${property}`]:
|
|
583
|
-
hexToRGB(`${defaultColorValue}`, twOpacityVar) +
|
|
584
|
-
importantProperty,
|
|
585
|
-
},
|
|
174
|
+
[selector]: { [property]: hexToRGB(colorValue, twOpacityVar) + importantProperty },
|
|
175
|
+
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}${selectorSuffix}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${fixedElementClass}${selectorSuffix}`]: { [property]: hexToRGB(defaultColorValue, twOpacityVar) + importantProperty },
|
|
176
|
+
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}${selectorSuffix}, ${importantSelector}${darkSelector} ${fixedBlockClass} [class*="${cleanClass}/"]${pseudoVariant}${selectorSuffix}`]: { [property]: hexToRGB(defaultColorValue, twOpacityVar) + importantProperty }
|
|
586
177
|
}
|
|
587
178
|
}
|
|
588
179
|
|
|
589
|
-
if (
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
180
|
+
if (colorClass.includes("ring-offset-")) {
|
|
181
|
+
const selector = `${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}`
|
|
182
|
+
return {
|
|
183
|
+
[selector]: { "--tw-ring-offset-color": colorValue + importantProperty },
|
|
184
|
+
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${fixedElementClass}`]: { "--tw-ring-offset-color": defaultColorValue + importantProperty },
|
|
185
|
+
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} [class*="${cleanClass}/"]${pseudoVariant}`]: { "--tw-ring-offset-color": defaultColorValue + importantProperty }
|
|
186
|
+
}
|
|
595
187
|
}
|
|
596
|
-
|
|
597
|
-
if (
|
|
598
|
-
|
|
599
|
-
colorClass
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
188
|
+
if (colorClass.includes("ring-")) return generateClass("ring-opacity", "--tw-ring-color")
|
|
189
|
+
if (colorClass.includes("divide-")) {
|
|
190
|
+
const twOpacityVar = `var(--tw-divide-opacity, 1)`
|
|
191
|
+
const selector = `${importantSelector}${darkSelector} .${colorClass}${pseudoVariant} > :not([hidden]) ~ :not([hidden]), ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant} > :not([hidden]) ~ :not([hidden])`
|
|
192
|
+
return {
|
|
193
|
+
[selector]: { borderColor: hexToRGB(colorValue, twOpacityVar) + importantProperty },
|
|
194
|
+
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass} > :not([hidden]) ~ :not([hidden]), ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${fixedElementClass} > :not([hidden]) ~ :not([hidden])`]: { borderColor: hexToRGB(defaultColorValue, twOpacityVar) + importantProperty },
|
|
195
|
+
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant} > :not([hidden]) ~ :not([hidden]), ${importantSelector}${darkSelector} ${fixedBlockClass} [class*="${cleanClass}/"]${pseudoVariant} > :not([hidden]) ~ :not([hidden])`]: { borderColor: hexToRGB(defaultColorValue, twOpacityVar) + importantProperty }
|
|
196
|
+
}
|
|
603
197
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
198
|
+
if (colorClass.includes("placeholder-")) {
|
|
199
|
+
const twOpacityVar = `var(--tw-placeholder-opacity, 1)`
|
|
200
|
+
const selector = `${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}::placeholder, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}::placeholder`
|
|
201
|
+
return {
|
|
202
|
+
[selector]: { color: hexToRGB(colorValue, twOpacityVar) + importantProperty },
|
|
203
|
+
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}::placeholder, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${fixedElementClass}::placeholder`]: { color: hexToRGB(defaultColorValue, twOpacityVar) + importantProperty },
|
|
204
|
+
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}::placeholder, ${importantSelector}${darkSelector} ${fixedBlockClass} [class*="${cleanClass}/"]${pseudoVariant}::placeholder`]: { color: hexToRGB(defaultColorValue, twOpacityVar) + importantProperty }
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (colorClass.includes("text-")) return generateClass("text-opacity", "color")
|
|
208
|
+
if (colorClass.includes("bg-")) return generateClass("bg-opacity", "backgroundColor")
|
|
209
|
+
if (colorClass.includes("border-")) return generateClass("border-opacity", "borderColor")
|
|
210
|
+
if (colorClass.includes("ring-")) return generateClass("ring-opacity", "--tw-ring-color")
|
|
211
|
+
if (colorClass.includes("outline-")) {
|
|
212
|
+
const selector = `${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}`
|
|
213
|
+
return {
|
|
214
|
+
[selector]: { "outlineColor": colorValue + importantProperty },
|
|
215
|
+
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${fixedElementClass}`]: { "outlineColor": defaultColorValue + importantProperty },
|
|
216
|
+
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} [class*="${cleanClass}/"]${pseudoVariant}`]: { "outlineColor": defaultColorValue + importantProperty }
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (colorClass.includes("decoration-")) {
|
|
220
|
+
const selector = `${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}`
|
|
615
221
|
return {
|
|
616
|
-
[
|
|
617
|
-
{
|
|
618
|
-
|
|
619
|
-
borderColor:
|
|
620
|
-
hexToRGB(`${colorValue}`, twOpacityVar) +
|
|
621
|
-
importantProperty,
|
|
622
|
-
},
|
|
623
|
-
[`${importantSelector}${darkSelector} ${fixedElementClass}.${colorClass}${pseudoVariant} > :not([hidden]) ~ :not([hidden]), ${importantSelector}${darkSelector} ${fixedElementClass}.${colorClass}\\/\\*${pseudoVariant} > :not([hidden]) ~ :not([hidden])`]:
|
|
624
|
-
{
|
|
625
|
-
borderColor: defaultColorValue + importantProperty,
|
|
626
|
-
borderColor:
|
|
627
|
-
hexToRGB(`${defaultColorValue}`, twOpacityVar) +
|
|
628
|
-
importantProperty,
|
|
629
|
-
},
|
|
630
|
-
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant} > :not([hidden]) ~ :not([hidden]), ${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}\\/\\*${pseudoVariant} > :not([hidden]) ~ :not([hidden])`]:
|
|
631
|
-
{
|
|
632
|
-
borderColor: defaultColorValue + importantProperty,
|
|
633
|
-
borderColor:
|
|
634
|
-
hexToRGB(`${defaultColorValue}`, twOpacityVar) +
|
|
635
|
-
importantProperty,
|
|
636
|
-
},
|
|
222
|
+
[selector]: { "textDecorationColor": colorValue + importantProperty },
|
|
223
|
+
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${fixedElementClass}`]: { "textDecorationColor": defaultColorValue + importantProperty },
|
|
224
|
+
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} [class*="${cleanClass}/"]${pseudoVariant}`]: { "textDecorationColor": defaultColorValue + importantProperty }
|
|
637
225
|
}
|
|
638
|
-
}
|
|
639
|
-
|
|
226
|
+
}
|
|
227
|
+
if (colorClass.includes("accent-")) {
|
|
228
|
+
const selector = `${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}`
|
|
640
229
|
return {
|
|
641
|
-
[
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
hexToRGB(`${colorValue}`, twOpacityVar) +
|
|
645
|
-
importantProperty,
|
|
646
|
-
},
|
|
647
|
-
[`${importantSelector}${darkSelector} ${fixedElementClass}.${colorClass}::placeholder, ${importantSelector}${darkSelector} ${fixedElementClass}.${colorClass}\\/\\*::placeholder`]:
|
|
648
|
-
{
|
|
649
|
-
color: defaultColorValue + importantProperty,
|
|
650
|
-
color:
|
|
651
|
-
hexToRGB(`${defaultColorValue}`, twOpacityVar) +
|
|
652
|
-
importantProperty,
|
|
653
|
-
},
|
|
654
|
-
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}::placeholder, ${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}\\/\\*::placeholder`]:
|
|
655
|
-
{
|
|
656
|
-
color: defaultColorValue + importantProperty,
|
|
657
|
-
color:
|
|
658
|
-
hexToRGB(`${defaultColorValue}`, twOpacityVar) +
|
|
659
|
-
importantProperty,
|
|
660
|
-
},
|
|
230
|
+
[selector]: { "accentColor": colorValue + importantProperty },
|
|
231
|
+
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${fixedElementClass}`]: { "accentColor": defaultColorValue + importantProperty },
|
|
232
|
+
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} [class*="${cleanClass}/"]${pseudoVariant}`]: { "accentColor": defaultColorValue + importantProperty }
|
|
661
233
|
}
|
|
662
|
-
}
|
|
234
|
+
}
|
|
235
|
+
if (colorClass.includes("caret-")) {
|
|
236
|
+
const selector = `${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}`
|
|
663
237
|
return {
|
|
664
|
-
[
|
|
665
|
-
{
|
|
666
|
-
|
|
667
|
-
},
|
|
668
|
-
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} .${colorClass}\\/\\*${pseudoVariant}${fixedElementClass}`]:
|
|
669
|
-
{
|
|
670
|
-
"--tw-ring-offset-color": defaultColorValue + importantProperty,
|
|
671
|
-
},
|
|
672
|
-
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}\\/\\*${pseudoVariant}`]:
|
|
673
|
-
{
|
|
674
|
-
"--tw-ring-offset-color": defaultColorValue + importantProperty,
|
|
675
|
-
},
|
|
238
|
+
[selector]: { "caretColor": colorValue + importantProperty },
|
|
239
|
+
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${fixedElementClass}`]: { "caretColor": defaultColorValue + importantProperty },
|
|
240
|
+
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} [class*="${cleanClass}/"]${pseudoVariant}`]: { "caretColor": defaultColorValue + importantProperty }
|
|
676
241
|
}
|
|
677
|
-
}
|
|
242
|
+
}
|
|
243
|
+
if (colorClass.includes("fill-")) {
|
|
244
|
+
const selector = `${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}`
|
|
678
245
|
return {
|
|
679
|
-
[
|
|
680
|
-
{
|
|
681
|
-
|
|
682
|
-
"--tw-gradient-stops":
|
|
683
|
-
`var(--tw-gradient-from), var(--tw-gradient-to, ${hexToRGB(
|
|
684
|
-
`${colorValue}`,
|
|
685
|
-
"0"
|
|
686
|
-
)})` + importantProperty,
|
|
687
|
-
},
|
|
688
|
-
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} .${colorClass}\\/\\*${pseudoVariant}${fixedElementClass}`]:
|
|
689
|
-
{
|
|
690
|
-
"--tw-gradient-from": defaultColorValue + importantProperty,
|
|
691
|
-
"--tw-gradient-stops":
|
|
692
|
-
`var(--tw-gradient-from), var(--tw-gradient-to, ${hexToRGB(
|
|
693
|
-
`${defaultColorValue}`,
|
|
694
|
-
"0"
|
|
695
|
-
)})` + importantProperty,
|
|
696
|
-
},
|
|
697
|
-
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}\\/\\*${pseudoVariant}`]:
|
|
698
|
-
{
|
|
699
|
-
"--tw-gradient-from": defaultColorValue + importantProperty,
|
|
700
|
-
"--tw-gradient-stops":
|
|
701
|
-
`var(--tw-gradient-from), var(--tw-gradient-to, ${hexToRGB(
|
|
702
|
-
`${defaultColorValue}`,
|
|
703
|
-
"0"
|
|
704
|
-
)})` + importantProperty,
|
|
705
|
-
},
|
|
246
|
+
[selector]: { "fill": colorValue + importantProperty },
|
|
247
|
+
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${fixedElementClass}`]: { "fill": defaultColorValue + importantProperty },
|
|
248
|
+
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} [class*="${cleanClass}/"]${pseudoVariant}`]: { "fill": defaultColorValue + importantProperty }
|
|
706
249
|
}
|
|
707
|
-
}
|
|
250
|
+
}
|
|
251
|
+
if (colorClass.includes("stroke-")) {
|
|
252
|
+
const selector = `${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}`
|
|
708
253
|
return {
|
|
709
|
-
[
|
|
710
|
-
{
|
|
711
|
-
|
|
712
|
-
`var(--tw-gradient-from), ${colorValue}, var(--tw-gradient-to, ${hexToRGB(
|
|
713
|
-
`${colorValue}`,
|
|
714
|
-
"0"
|
|
715
|
-
)})` + importantProperty,
|
|
716
|
-
},
|
|
717
|
-
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} .${colorClass}\\/\\*${pseudoVariant}${fixedElementClass}`]:
|
|
718
|
-
{
|
|
719
|
-
"--tw-gradient-stops":
|
|
720
|
-
`var(--tw-gradient-from), ${defaultColorValue}, var(--tw-gradient-to, ${hexToRGB(
|
|
721
|
-
`${defaultColorValue}`,
|
|
722
|
-
"0"
|
|
723
|
-
)})` + importantProperty,
|
|
724
|
-
},
|
|
725
|
-
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}\\/\\*${pseudoVariant}`]:
|
|
726
|
-
{
|
|
727
|
-
"--tw-gradient-stops":
|
|
728
|
-
`var(--tw-gradient-from), ${defaultColorValue}, var(--tw-gradient-to, ${hexToRGB(
|
|
729
|
-
`${defaultColorValue}`,
|
|
730
|
-
"0"
|
|
731
|
-
)})` + importantProperty,
|
|
732
|
-
},
|
|
254
|
+
[selector]: { "stroke": colorValue + importantProperty },
|
|
255
|
+
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${fixedElementClass}`]: { "stroke": defaultColorValue + importantProperty },
|
|
256
|
+
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} [class*="${cleanClass}/"]${pseudoVariant}`]: { "stroke": defaultColorValue + importantProperty }
|
|
733
257
|
}
|
|
734
|
-
}
|
|
258
|
+
}
|
|
259
|
+
if (colorClass.includes("shadow-")) {
|
|
260
|
+
const selector = `${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}`
|
|
735
261
|
return {
|
|
736
|
-
[
|
|
737
|
-
{
|
|
738
|
-
|
|
739
|
-
},
|
|
740
|
-
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} .${colorClass}\\/\\*${pseudoVariant}${fixedElementClass}`]:
|
|
741
|
-
{
|
|
742
|
-
"--tw-gradient-to": defaultColorValue + importantProperty,
|
|
743
|
-
},
|
|
744
|
-
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}\\/\\*${pseudoVariant}`]:
|
|
745
|
-
{
|
|
746
|
-
"--tw-gradient-to": defaultColorValue + importantProperty,
|
|
747
|
-
},
|
|
262
|
+
[selector]: { "--tw-shadow-color": colorValue + importantProperty },
|
|
263
|
+
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${fixedElementClass}`]: { "--tw-shadow-color": defaultColorValue + importantProperty },
|
|
264
|
+
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} [class*="${cleanClass}/"]${pseudoVariant}`]: { "--tw-shadow-color": defaultColorValue + importantProperty }
|
|
748
265
|
}
|
|
749
266
|
}
|
|
750
|
-
|
|
267
|
+
if (colorClass.includes("from-")) {
|
|
268
|
+
const s = `${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}`
|
|
269
|
+
return {
|
|
270
|
+
[s]: { "--tw-gradient-from": colorValue + importantProperty, "--tw-gradient-stops": `var(--tw-gradient-from), var(--tw-gradient-to, ${hexToRGB(colorValue, "0")})` + importantProperty },
|
|
271
|
+
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${fixedElementClass}`]: { "--tw-gradient-from": defaultColorValue + importantProperty, "--tw-gradient-stops": `var(--tw-gradient-from), var(--tw-gradient-to, ${hexToRGB(defaultColorValue, "0")})` + importantProperty },
|
|
272
|
+
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} [class*="${cleanClass}/"]${pseudoVariant}`]: { "--tw-gradient-from": defaultColorValue + importantProperty, "--tw-gradient-stops": `var(--tw-gradient-from), var(--tw-gradient-to, ${hexToRGB(defaultColorValue, "0")})` + importantProperty }
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (colorClass.includes("via-")) {
|
|
276
|
+
const s = `${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}`
|
|
277
|
+
return {
|
|
278
|
+
[s]: { "--tw-gradient-stops": `var(--tw-gradient-from), ${colorValue}, var(--tw-gradient-to, ${hexToRGB(colorValue, "0")})` + importantProperty },
|
|
279
|
+
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${fixedElementClass}`]: { "--tw-gradient-stops": `var(--tw-gradient-from), ${defaultColorValue}, var(--tw-gradient-to, ${hexToRGB(defaultColorValue, "0")})` + importantProperty },
|
|
280
|
+
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} [class*="${cleanClass}/"]${pseudoVariant}`]: { "--tw-gradient-stops": `var(--tw-gradient-from), ${defaultColorValue}, var(--tw-gradient-to, ${hexToRGB(defaultColorValue, "0")})` + importantProperty }
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (colorClass.includes("to-")) {
|
|
284
|
+
const s = `${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}`
|
|
285
|
+
return {
|
|
286
|
+
[s]: { "--tw-gradient-to": colorValue + importantProperty },
|
|
287
|
+
[`${importantSelector}${darkSelector} .${colorClass}${pseudoVariant}${fixedElementClass}, ${importantSelector}${darkSelector} [class*="${cleanClass}/"]${pseudoVariant}${fixedElementClass}`]: { "--tw-gradient-to": defaultColorValue + importantProperty },
|
|
288
|
+
[`${importantSelector}${darkSelector} ${fixedBlockClass} .${colorClass}${pseudoVariant}, ${importantSelector}${darkSelector} ${fixedBlockClass} [class*="${cleanClass}/"]${pseudoVariant}`]: { "--tw-gradient-to": defaultColorValue + importantProperty }
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return null
|
|
292
|
+
}).filter(Boolean)
|
|
293
|
+
|
|
294
|
+
if (theme("nightwind.typography")) {
|
|
295
|
+
Object.keys(theme("typography") || {}).forEach((modifier) => {
|
|
296
|
+
const css = theme(`typography.${modifier}.css`) || []
|
|
297
|
+
css.forEach(n => {
|
|
298
|
+
Object.keys(n).forEach(classname => {
|
|
299
|
+
const colorProp = Object.keys(n[classname]).find(p => p.includes("color") || p.includes("Color"))
|
|
300
|
+
if (colorProp) {
|
|
301
|
+
const colorVal = hexToTailwind(n[classname][colorProp])
|
|
302
|
+
if (!typographyValues[modifier]) typographyValues[modifier] = {}
|
|
303
|
+
if (!typographyValues[modifier][classname]) typographyValues[modifier][classname] = {}
|
|
304
|
+
typographyValues[modifier][classname][colorProp] = colorVal
|
|
305
|
+
}
|
|
306
|
+
})
|
|
307
|
+
})
|
|
308
|
+
})
|
|
751
309
|
|
|
752
|
-
|
|
310
|
+
Object.keys(typographyValues).forEach((modifier) => {
|
|
311
|
+
Object.keys(typographyValues[modifier]).forEach((classname) => {
|
|
312
|
+
Object.keys(typographyValues[modifier][classname]).forEach((property) => {
|
|
313
|
+
const invertResults = invertColor(typographyValues[modifier][classname][property])
|
|
314
|
+
const colorValue = invertResults.colorValue || typographyValues[modifier][classname][property]
|
|
315
|
+
const defaultColorValue = invertResults.defaultColorValue
|
|
316
|
+
const s = `${importantSelector}${darkSelector} .${classname}${modifier !== "DEFAULT" ? `-${modifier}` : ""}`
|
|
317
|
+
typographyClasses.push({ [s]: { [property]: colorValue }, [`${s}${fixedElementClass}`]: { [property]: defaultColorValue } })
|
|
318
|
+
})
|
|
319
|
+
})
|
|
320
|
+
})
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
addComponents(nightwindClasses)
|
|
753
324
|
addComponents(typographyClasses)
|
|
754
|
-
theme("nightwind.importantNode")
|
|
755
|
-
? addComponents(transitionClasses, { variants: ["responsive"] })
|
|
756
|
-
: addUtilities(transitionClasses, { variants: ["responsive"] })
|
|
757
|
-
},
|
|
758
|
-
{
|
|
759
|
-
theme: {
|
|
760
|
-
extend: {
|
|
761
|
-
transitionDuration: {
|
|
762
|
-
0: "0ms",
|
|
763
|
-
},
|
|
764
|
-
},
|
|
765
|
-
},
|
|
325
|
+
theme("nightwind.importantNode") ? addComponents(transitionClasses) : addUtilities(transitionClasses)
|
|
766
326
|
},
|
|
767
|
-
{
|
|
768
|
-
purge: ["./node_modules/nightwind/**/*.js"],
|
|
769
|
-
}
|
|
327
|
+
{ theme: { extend: { transitionDuration: { 0: "0ms" } } } }
|
|
770
328
|
)
|
|
771
329
|
|
|
772
330
|
module.exports = nightwind
|