File tree 3 files changed +65
-0
lines changed
packages/tailwindcss-language-server
3 files changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,30 @@ test('@utility', () => {
65
65
expect ( rewriteCss ( input . join ( '\n' ) ) ) . toBe ( output . join ( '\n' ) )
66
66
} )
67
67
68
+ test ( '@theme' , ( ) => {
69
+ let input = [
70
+ //
71
+ '@theme {' ,
72
+ ' color: red;' ,
73
+ '}' ,
74
+ '@theme inline reference static default {' ,
75
+ ' color: red;' ,
76
+ '}' ,
77
+ ]
78
+
79
+ let output = [
80
+ //
81
+ '.placeholder {' , // wrong
82
+ ' color: red;' ,
83
+ '}' ,
84
+ '.placeholder {' , // wrong
85
+ ' color: red;' ,
86
+ '}' ,
87
+ ]
88
+
89
+ expect ( rewriteCss ( input . join ( '\n' ) ) ) . toBe ( output . join ( '\n' ) )
90
+ } )
91
+
68
92
test ( '@custom-variant' , ( ) => {
69
93
let input = [
70
94
//
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export function rewriteCss(css: string) {
37
37
css = css . replace ( / @ v a r i a n t s ( \s + [ ^ { ] + ) { / g, replaceWithAtRule ( ) )
38
38
css = css . replace ( / @ r e s p o n s i v e ( \s * ) { / g, replaceWithAtRule ( ) )
39
39
css = css . replace ( / @ u t i l i t y ( \s + [ ^ { ] + ) { / g, replaceWithStyleRule ( ) )
40
+ css = css . replace ( / @ t h e m e ( \s + [ ^ { ] * ) { / g, replaceWithStyleRule ( ) )
40
41
41
42
css = css . replace ( / @ c u s t o m - v a r i a n t ( \s + [ ^ ; { ] + ) ; / g, ( match : string ) => {
42
43
let spaces = ' ' . repeat ( match . length - 11 )
Original file line number Diff line number Diff line change @@ -202,6 +202,46 @@ defineTest({
202
202
} ,
203
203
} )
204
204
205
+ defineTest ( {
206
+ name : '@theme' ,
207
+ prepare : async ( { root } ) => ( {
208
+ client : await createClient ( {
209
+ server : 'css' ,
210
+ root,
211
+ } ) ,
212
+ } ) ,
213
+ handle : async ( { client } ) => {
214
+ let doc = await client . open ( {
215
+ lang : 'tailwindcss' ,
216
+ name : 'file-1.css' ,
217
+ text : css `
218
+ @import 'tailwindcss' ;
219
+ @theme {
220
+ --color-primary : # 333 ;
221
+ }
222
+ ` ,
223
+ } )
224
+
225
+ // No errors
226
+ expect ( await doc . diagnostics ( ) ) . toEqual ( [ ] )
227
+
228
+ // Symbols show up for @custom -variant
229
+ expect ( await doc . symbols ( ) ) . toMatchObject ( [
230
+ {
231
+ kind : SymbolKind . Class ,
232
+ name : '@theme ' ,
233
+ location : {
234
+ uri : '{workspace:default}/file-1.css' ,
235
+ range : {
236
+ start : { line : 1 , character : 0 } ,
237
+ end : { line : 3 , character : 1 } ,
238
+ } ,
239
+ } ,
240
+ } ,
241
+ ] )
242
+ } ,
243
+ } )
244
+
205
245
defineTest ( {
206
246
name : '@layer statement' ,
207
247
prepare : async ( { root } ) => ( {
You can’t perform that action at this time.
0 commit comments