Skip to content

Commit cc8dd1c

Browse files
Reload variants when editing the theme in v4 (#1094)
Fixes #1093
1 parent aef7cff commit cc8dd1c

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

packages/tailwindcss-language-server/src/projects.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import type {
4545
Settings,
4646
ClassNames,
4747
Variant,
48+
ClassEntry,
4849
} from '@tailwindcss/language-service/src/util/state'
4950
import { provideDiagnostics } from './lsp/diagnosticsProvider'
5051
import { doCodeActions } from '@tailwindcss/language-service/src/codeActions/codeActionProvider'
@@ -1014,7 +1015,7 @@ export async function createProjectService(
10141015
},
10151016
})
10161017

1017-
let classList = designSystem.getClassList().map((className) => {
1018+
let classList: ClassEntry[] = designSystem.getClassList().map((className) => {
10181019
return [
10191020
className[0],
10201021
{
@@ -1025,7 +1026,8 @@ export async function createProjectService(
10251026
})
10261027

10271028
state.designSystem = designSystem
1028-
state.classList = classList as any
1029+
state.classList = classList
1030+
state.variants = getVariants(state)
10291031

10301032
console.log('---- RELOADED ----')
10311033
},

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ export interface Variant {
8989
selectors: (params?: { value?: string; label?: string }) => string[]
9090
}
9191

92+
export interface ClassMetadata {
93+
color: culori.Color | KeywordColor | null
94+
modifiers?: string[]
95+
}
96+
97+
export type ClassEntry = [string, ClassMetadata]
98+
9299
export interface State {
93100
enabled: boolean
94101
isCssConfig?: boolean
@@ -127,7 +134,7 @@ export interface State {
127134
editor?: EditorState
128135
jit?: boolean
129136
jitContext?: any
130-
classList?: Array<[string, { color: culori.Color | KeywordColor | null; modifiers?: string[] }]>
137+
classList?: ClassEntry[]
131138
classListContainsMetadata?: boolean
132139
pluginVersions?: string
133140
completionItemData?: Record<string, any>

packages/vscode-tailwindcss/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Prerelease
44

5-
- Nothing yet!
5+
- Reload variants when editing the theme in v4 ([#1094](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1094))
66

77
## 0.12.14
88

0 commit comments

Comments
 (0)