@@ -29,11 +29,12 @@ import {
29
29
toValue ,
30
30
type CssProperty ,
31
31
} from "@webstudio-is/css-engine" ;
32
+ import { composeEventHandlers } from "~/shared/event-utils" ;
32
33
import {
33
34
deleteProperty ,
34
35
setProperty ,
35
- } from "../.. /features/style-panel/shared/use-style-data" ;
36
- import { composeEventHandlers } from "~/shared/event-utils " ;
36
+ } from "~/builder /features/style-panel/shared/use-style-data" ;
37
+ import { $availableVariables } from "~/builder/features/style-panel/shared/model " ;
37
38
import { parseStyleInput } from "./parse-style-input" ;
38
39
39
40
type SearchItem = {
@@ -43,19 +44,27 @@ type SearchItem = {
43
44
key : string ;
44
45
} ;
45
46
46
- const autoCompleteItems : Array < SearchItem > = [ ] ;
47
-
48
47
const getNewPropertyDescription = ( item : null | SearchItem ) => {
49
- let description : string | undefined = `Create CSS variable.` ;
50
- if ( item && item . property in propertyDescriptions ) {
48
+ let description : string | undefined = "Add CSS property." ;
49
+ if ( item ?. property . startsWith ( "--" ) ) {
50
+ description = "Create CSS variable." ;
51
+ }
52
+ if ( item && propertyDescriptions [ item . property ] ) {
51
53
description = propertyDescriptions [ item . property ] ;
52
54
}
53
55
return < Box css = { { width : theme . spacing [ 28 ] } } > { description } </ Box > ;
54
56
} ;
55
57
56
58
const getAutocompleteItems = ( ) => {
57
- if ( autoCompleteItems . length > 0 ) {
58
- return autoCompleteItems ;
59
+ const autoCompleteItems : SearchItem [ ] = [ ] ;
60
+ for ( const varValue of $availableVariables . get ( ) ) {
61
+ const property = `--${ varValue . value } ` ;
62
+ autoCompleteItems . push ( {
63
+ // consider additional properties to be custom properties
64
+ key : property ,
65
+ property,
66
+ label : property ,
67
+ } ) ;
59
68
}
60
69
for ( const property in propertiesData ) {
61
70
autoCompleteItems . push ( {
0 commit comments