Skip to content

Commit a8f0eac

Browse files
chore: wip
1 parent 666877a commit a8f0eac

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

packages/crosswind/src/rules-effects.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ function buildShadowColorCache(colors: Record<string, any>): Map<string, string>
2727

2828
function applyShadowOpacity(color: string, opacity: number): string {
2929
if (color.charCodeAt(0) === 35) { // '#'
30-
const hex = color.slice(1)
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+
}
3135
const r = Number.parseInt(hex.slice(0, 2), 16)
3236
const g = Number.parseInt(hex.slice(2, 4), 16)
3337
const b = Number.parseInt(hex.slice(4, 6), 16)

packages/crosswind/src/rules.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,13 @@ function applyOpacity(color: string, opacity: number): string {
419419
cleanColor = color.slice(1, -1)
420420
}
421421

422-
// If color is hex (#rrggbb), convert to rgb with alpha
422+
// If color is hex (#rgb or #rrggbb), convert to rgb with alpha
423423
if (cleanColor.charCodeAt(0) === 35) { // '#' char code for faster check
424-
const hex = cleanColor.slice(1)
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+
}
425429
const r = Number.parseInt(hex.slice(0, 2), 16)
426430
const g = Number.parseInt(hex.slice(2, 4), 16)
427431
const b = Number.parseInt(hex.slice(4, 6), 16)

0 commit comments

Comments
 (0)