Skip to content

Commit

Permalink
Reload variants when editing the theme in v4 (#1094)
Browse files Browse the repository at this point in the history
Fixes #1093
  • Loading branch information
thecrypticace authored Nov 22, 2024
1 parent aef7cff commit cc8dd1c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/tailwindcss-language-server/src/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import type {
Settings,
ClassNames,
Variant,
ClassEntry,
} from '@tailwindcss/language-service/src/util/state'
import { provideDiagnostics } from './lsp/diagnosticsProvider'
import { doCodeActions } from '@tailwindcss/language-service/src/codeActions/codeActionProvider'
Expand Down Expand Up @@ -1014,7 +1015,7 @@ export async function createProjectService(
},
})

let classList = designSystem.getClassList().map((className) => {
let classList: ClassEntry[] = designSystem.getClassList().map((className) => {
return [
className[0],
{
Expand All @@ -1025,7 +1026,8 @@ export async function createProjectService(
})

state.designSystem = designSystem
state.classList = classList as any
state.classList = classList
state.variants = getVariants(state)

console.log('---- RELOADED ----')
},
Expand Down
9 changes: 8 additions & 1 deletion packages/tailwindcss-language-service/src/util/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ export interface Variant {
selectors: (params?: { value?: string; label?: string }) => string[]
}

export interface ClassMetadata {
color: culori.Color | KeywordColor | null
modifiers?: string[]
}

export type ClassEntry = [string, ClassMetadata]

export interface State {
enabled: boolean
isCssConfig?: boolean
Expand Down Expand Up @@ -127,7 +134,7 @@ export interface State {
editor?: EditorState
jit?: boolean
jitContext?: any
classList?: Array<[string, { color: culori.Color | KeywordColor | null; modifiers?: string[] }]>
classList?: ClassEntry[]
classListContainsMetadata?: boolean
pluginVersions?: string
completionItemData?: Record<string, any>
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode-tailwindcss/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Prerelease

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

## 0.12.14

Expand Down

0 comments on commit cc8dd1c

Please sign in to comment.