Skip to content

Commit dccabc3

Browse files
committed
fix: make css variable autocomplete work
1 parent 01d72ad commit dccabc3

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

Diff for: .changeset/funny-plums-brake.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@pandacss/generator': patch
3+
---
4+
5+
Fix issue where generated `CssVarKeys` type cannot provide autocomplete correctly

Diff for: packages/generator/__tests__/generate-style-props.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ describe('generate property types', () => {
1414
type CssVars = \`var(--\${string})\`
1515
type CssVarValue = ConditionalValue<Token | AnyString | (number & {})>
1616

17-
type CssVarName = | AnyString
18-
type CssVarKeys = \`--\${CssVarName}\`
17+
type CssVarName =
18+
type CssVarKeys = \`--\${CssVarName}\` | \`--\${string}\` & {}
1919

2020
export type CssVarProperties = {
2121
[key in CssVarKeys]?: CssVarValue
@@ -7510,8 +7510,8 @@ describe('generate property types', () => {
75107510
type CssVars = \`var(--\${string})\`
75117511
type CssVarValue = ConditionalValue<Token | AnyString | (number & {})>
75127512

7513-
type CssVarName = | AnyString
7514-
type CssVarKeys = \`--\${CssVarName}\`
7513+
type CssVarName =
7514+
type CssVarKeys = \`--\${CssVarName}\` | \`--\${string}\` & {}
75157515

75167516
export type CssVarProperties = {
75177517
[key in CssVarKeys]?: CssVarValue
@@ -15024,8 +15024,8 @@ describe('generate property types', () => {
1502415024
type CssVars = "var(--random-color)" | "var(--button-color)"
1502515025
type CssVarValue = ConditionalValue<Token | CssVars | AnyString | (number & {})>
1502615026

15027-
type CssVarName = "random-color" | "button-color" | AnyString
15028-
type CssVarKeys = \`--\${CssVarName}\`
15027+
type CssVarName = "random-color" | "button-color"
15028+
type CssVarKeys = \`--\${CssVarName}\` | \`--\${string}\` & {}
1502915029

1503015030
export type CssVarProperties = {
1503115031
[key in CssVarKeys]?: CssVarValue

Diff for: packages/generator/src/artifacts/types/style-props.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export function generateStyleProps(ctx: Context) {
2222
type CssVars = ${[cssVars || '`var(--${string})`'].filter(Boolean).join(' | ')}
2323
type CssVarValue = ConditionalValue<Token${ctx.globalVars.isEmpty() ? '' : ' | CssVars'} | AnyString | (number & {})>
2424
25-
type CssVarName = ${unionType(ctx.globalVars.names)} | AnyString
26-
type CssVarKeys = \`--\${CssVarName}\`
25+
type CssVarName = ${unionType(ctx.globalVars.names)}
26+
type CssVarKeys = \`--\${CssVarName}\` | \`--\${string}\` & {}
2727
2828
export type CssVarProperties = {
2929
[key in CssVarKeys]?: CssVarValue

Diff for: packages/studio/styled-system/types/conditions.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export interface Conditions {
146146
"_open": string
147147
/** `&:is([closed], [data-closed], [data-state="closed"])` */
148148
"_closed": string
149-
/** `&is(:fullscreen, [data-fullscreen])` */
149+
/** `&:is(:fullscreen, [data-fullscreen])` */
150150
"_fullscreen": string
151151
/** `&:is([data-loading], [aria-busy=true])` */
152152
"_loading": string

Diff for: packages/studio/styled-system/types/style-props.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ type AnyString = (string & {})
88
type CssVars = `var(--${string})`
99
type CssVarValue = ConditionalValue<Token | AnyString | (number & {})>
1010

11-
type CssVarName = | AnyString
12-
type CssVarKeys = `--${CssVarName}`
11+
type CssVarName =
12+
type CssVarKeys = `--${CssVarName}` | `--${string}` & {}
1313

1414
export type CssVarProperties = {
1515
[key in CssVarKeys]?: CssVarValue

0 commit comments

Comments
 (0)