Open
Description
Currently, the following works great:
:root {
--example-red: "#ff0000";
}
const MyComponent = styled`
color: var(--example-red); // here the --example-red detection works perfectly
However.... the following does not work:
const MyComponent = styled`
color: ${(props) => (props.color || "var(--example-red)")}; // here the example-red doesn't get detected
color: ${(props) => (props.color || css`var(--example-red)`)}; // here it barely works, doesn't autocomplete but does detect the variable and allows e.g. pressing it to go to its source
This is probably because the plugin is only intended to mark tagged styled
and css
strings, which are always expected to be of the form of "key-value pairs" (recursively). That does work for almost all cases, but fails in this particular case, because the string "var(--example-red)"
is just a value, without any color
key or a colon to separate them.
I would like this plugin to be updated so that it works with such "value-only" strings.
Note that css`var(--example-red)`
is actually not really valid to write in code, because such objects are often not accepted as string parameters for some components.
Metadata
Metadata
Assignees
Labels
No labels