@cwcss/crosswind 0.1.4 → 0.1.5
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/rules-effects.ts +5 -1
- package/src/rules.ts +6 -2
package/package.json
CHANGED
package/src/rules-effects.ts
CHANGED
|
@@ -27,7 +27,11 @@ function buildShadowColorCache(colors: Record<string, any>): Map<string, string>
|
|
|
27
27
|
|
|
28
28
|
function applyShadowOpacity(color: string, opacity: number): string {
|
|
29
29
|
if (color.charCodeAt(0) === 35) { // '#'
|
|
30
|
-
|
|
30
|
+
let hex = color.slice(1)
|
|
31
|
+
// Expand 3-char hex (#rgb) to 6-char (#rrggbb)
|
|
32
|
+
if (hex.length === 3) {
|
|
33
|
+
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]
|
|
34
|
+
}
|
|
31
35
|
const r = Number.parseInt(hex.slice(0, 2), 16)
|
|
32
36
|
const g = Number.parseInt(hex.slice(2, 4), 16)
|
|
33
37
|
const b = Number.parseInt(hex.slice(4, 6), 16)
|
package/src/rules.ts
CHANGED
|
@@ -419,9 +419,13 @@ function applyOpacity(color: string, opacity: number): string {
|
|
|
419
419
|
cleanColor = color.slice(1, -1)
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
-
// If color is hex (#rrggbb), convert to rgb with alpha
|
|
422
|
+
// If color is hex (#rgb or #rrggbb), convert to rgb with alpha
|
|
423
423
|
if (cleanColor.charCodeAt(0) === 35) { // '#' char code for faster check
|
|
424
|
-
|
|
424
|
+
let hex = cleanColor.slice(1)
|
|
425
|
+
// Expand 3-char hex (#rgb) to 6-char (#rrggbb)
|
|
426
|
+
if (hex.length === 3) {
|
|
427
|
+
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]
|
|
428
|
+
}
|
|
425
429
|
const r = Number.parseInt(hex.slice(0, 2), 16)
|
|
426
430
|
const g = Number.parseInt(hex.slice(2, 4), 16)
|
|
427
431
|
const b = Number.parseInt(hex.slice(4, 6), 16)
|