Skip to content

Commit 9d5b4f2

Browse files
Display color swatches when using before/after variants (#1374)
Fixes #1370 Turns out *all* color swatches for `before:{utility}` and `after:{utility}` were broken. This fixes that so utilities using these variants show color swatches.
1 parent db97689 commit 9d5b4f2

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,16 @@ function getColorFromDecls(
7979
): culori.Color | KeywordColor | null {
8080
let props = Object.keys(decls).filter((prop) => {
8181
// ignore content: "";
82-
if (
83-
prop === 'content' &&
84-
(decls[prop] === '""' || decls[prop] === "''" || decls[prop] === 'var(--tw-content)')
85-
) {
86-
return false
82+
if (prop === 'content') {
83+
let value = decls[prop]
84+
85+
if (Array.isArray(value) && value.length === 1) {
86+
value = value[0]
87+
}
88+
89+
if (value === '""' || value === "''" || value === 'var(--tw-content)') {
90+
return false
91+
}
8792
}
8893

8994
// ignore mask-image & mask-composite

packages/vscode-tailwindcss/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Prerelease
44

5-
- Nothing yet!
5+
- Display color swatches when using `before`/`after` variants ([#1374](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1374))
66

77
# 0.14.17
88

0 commit comments

Comments
 (0)