@thiagormoreira/nightwind 1.1.13

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