@@ -40,6 +40,7 @@ import { customClassesIn } from './util/classes'
40
40
import { IS_SCRIPT_SOURCE , IS_TEMPLATE_SOURCE } from './metadata/extensions'
41
41
import * as postcss from 'postcss'
42
42
import { findFileDirective } from './completions/file-paths'
43
+ import type { ThemeEntry } from './util/v4'
43
44
44
45
let isUtil = ( className ) =>
45
46
Array . isArray ( className . __info )
@@ -789,6 +790,8 @@ function provideThemeVariableCompletions(
789
790
position : Position ,
790
791
_context ?: CompletionContext ,
791
792
) : CompletionList {
793
+ if ( ! state . v4 ) return null
794
+
792
795
// Make sure we're in a CSS "context'
793
796
if ( ! isCssContext ( state , document , position ) ) return null
794
797
let text = getTextWithoutComments ( document , 'css' , {
@@ -804,52 +807,74 @@ function provideThemeVariableCompletions(
804
807
if ( themeBlock === - 1 ) return null
805
808
if ( braceLevel ( text . slice ( themeBlock ) ) !== 1 ) return null
806
809
807
- function themeVar ( label : string ) {
808
- return {
809
- label,
810
- kind : CompletionItemKind . Variable ,
811
- // insertTextFormat: InsertTextFormat.Snippet,
812
- // textEditText: `${label}-[\${1}]`,
813
- }
810
+ let entries : ThemeEntry [ ] = [
811
+ // Polyfill data for older versions of the design system
812
+ { kind : 'variable' , name : '--default-transition-duration' } ,
813
+ { kind : 'variable' , name : '--default-transition-timing-function' } ,
814
+ { kind : 'variable' , name : '--default-font-family' } ,
815
+ { kind : 'variable' , name : '--default-font-feature-settings' } ,
816
+ { kind : 'variable' , name : '--default-font-variation-settings' } ,
817
+ { kind : 'variable' , name : '--default-mono-font-family' } ,
818
+ { kind : 'variable' , name : '--default-mono-font-feature-settings' } ,
819
+ { kind : 'variable' , name : '--default-mono-font-variation-settings' } ,
820
+ { kind : 'namespace' , name : '--breakpoint' } ,
821
+ { kind : 'namespace' , name : '--color' } ,
822
+ { kind : 'namespace' , name : '--animate' } ,
823
+ { kind : 'namespace' , name : '--blur' } ,
824
+ { kind : 'namespace' , name : '--radius' } ,
825
+ { kind : 'namespace' , name : '--shadow' } ,
826
+ { kind : 'namespace' , name : '--inset-shadow' } ,
827
+ { kind : 'namespace' , name : '--drop-shadow' } ,
828
+ { kind : 'namespace' , name : '--spacing' } ,
829
+ { kind : 'namespace' , name : '--width' } ,
830
+ { kind : 'namespace' , name : '--font-family' } ,
831
+ { kind : 'namespace' , name : '--font-size' } ,
832
+ { kind : 'namespace' , name : '--letter-spacing' } ,
833
+ { kind : 'namespace' , name : '--line-height' } ,
834
+ { kind : 'namespace' , name : '--transition-timing-function' } ,
835
+ ]
836
+
837
+ if ( semver . gte ( state . version , '4.0.0-beta.1' ) ) {
838
+ entries = [
839
+ { kind : 'variable' , name : '--default-transition-duration' } ,
840
+ { kind : 'variable' , name : '--default-transition-timing-function' } ,
841
+ { kind : 'variable' , name : '--default-font-family' } ,
842
+ { kind : 'variable' , name : '--default-font-feature-settings' } ,
843
+ { kind : 'variable' , name : '--default-font-variation-settings' } ,
844
+ { kind : 'variable' , name : '--default-mono-font-family' } ,
845
+ { kind : 'variable' , name : '--default-mono-font-feature-settings' } ,
846
+ { kind : 'variable' , name : '--default-mono-font-variation-settings' } ,
847
+ { kind : 'namespace' , name : '--breakpoint' } ,
848
+ { kind : 'namespace' , name : '--color' } ,
849
+ { kind : 'namespace' , name : '--animate' } ,
850
+ { kind : 'namespace' , name : '--blur' } ,
851
+ { kind : 'namespace' , name : '--radius' } ,
852
+ { kind : 'namespace' , name : '--shadow' } ,
853
+ { kind : 'namespace' , name : '--inset-shadow' } ,
854
+ { kind : 'namespace' , name : '--drop-shadow' } ,
855
+ { kind : 'variable' , name : '--spacing' } ,
856
+ { kind : 'namespace' , name : '--container' } ,
857
+ { kind : 'namespace' , name : '--font' } ,
858
+ { kind : 'namespace' , name : '--font-size' } ,
859
+ { kind : 'namespace' , name : '--tracking' } ,
860
+ { kind : 'namespace' , name : '--leading' } ,
861
+ { kind : 'namespace' , name : '--ease' } ,
862
+ ]
814
863
}
815
864
816
- function themeNamespace ( label : string ) {
817
- return {
818
- label : `${ label } -` ,
865
+ let items : CompletionItem [ ] = [ ]
866
+
867
+ for ( let entry of entries ) {
868
+ items . push ( {
869
+ label : entry . kind === 'namespace' ? `${ entry . name } -` : entry . name ,
819
870
kind : CompletionItemKind . Variable ,
820
- // insertTextFormat: InsertTextFormat.Snippet,
821
- // textEditText: `${label}-[\${1}]`,
822
- }
871
+ } )
823
872
}
824
873
825
874
return withDefaults (
826
875
{
827
876
isIncomplete : false ,
828
- items : [
829
- themeVar ( '--default-transition-duration' ) ,
830
- themeVar ( '--default-transition-timing-function' ) ,
831
- themeVar ( '--default-font-family' ) ,
832
- themeVar ( '--default-font-feature-settings' ) ,
833
- themeVar ( '--default-font-variation-settings' ) ,
834
- themeVar ( '--default-mono-font-family' ) ,
835
- themeVar ( '--default-mono-font-feature-settings' ) ,
836
- themeVar ( '--default-mono-font-variation-settings' ) ,
837
- themeNamespace ( '--breakpoint' ) ,
838
- themeNamespace ( '--color' ) ,
839
- themeNamespace ( '--animate' ) ,
840
- themeNamespace ( '--blur' ) ,
841
- themeNamespace ( '--radius' ) ,
842
- themeNamespace ( '--shadow' ) ,
843
- themeNamespace ( '--inset-shadow' ) ,
844
- themeNamespace ( '--drop-shadow' ) ,
845
- themeNamespace ( '--spacing' ) ,
846
- themeNamespace ( '--width' ) ,
847
- themeNamespace ( '--font-family' ) ,
848
- themeNamespace ( '--font-size' ) ,
849
- themeNamespace ( '--letter-spacing' ) ,
850
- themeNamespace ( '--line-height' ) ,
851
- themeNamespace ( '--transition-timing-function' ) ,
852
- ] ,
877
+ items,
853
878
} ,
854
879
{
855
880
data : {
0 commit comments