Skip to content

Commit 963076e

Browse files
committed
Make sure new utilities can display color swatches
1 parent f8fa135 commit 963076e

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/tailwindcss-language-service/src/util/color.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const colorRegex = new RegExp(
5757
)
5858

5959
function getColorsInString(state: State, str: string): (culori.Color | KeywordColor)[] {
60-
if (/(?:box|drop)-shadow/.test(str)) return []
60+
if (/(?:box|drop)-shadow/.test(str) && !/--tw-drop-shadow/.test(str)) return []
6161

6262
function toColor(match: RegExpMatchArray) {
6363
let color = match[1].replace(/var\([^)]+\)/, '1')
@@ -85,6 +85,17 @@ function getColorFromDecls(
8585
) {
8686
return false
8787
}
88+
89+
// ignore mask-image & mask-composite
90+
if (prop === 'mask-image' || prop === 'mask-composite') {
91+
return false
92+
}
93+
94+
// ignore `--tw-drop-shadow`
95+
if (prop === '--tw-drop-shadow') {
96+
return false
97+
}
98+
8899
return true
89100
})
90101

packages/tailwindcss-language-service/src/util/rewriting/var-fallbacks.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ export function replaceCssVarsWithFallbacks(state: State, str: string): string {
1717
return fallback
1818
}
1919

20+
if (
21+
name === '--tw-text-shadow-alpha' ||
22+
name === '--tw-drop-shadow-alpha' ||
23+
name === '--tw-shadow-alpha'
24+
) {
25+
return '100%'
26+
}
27+
2028
// Don't touch it since there's no suitable replacement
2129
return null
2230
},

0 commit comments

Comments
 (0)