Skip to content

Commit 9c664da

Browse files
authored
feat: add color-hints/diagnostics/inlay-hints for sva/pattern/recipes (#21)
2 parents 61be3d2 + de1050f commit 9c664da

File tree

8 files changed

+66
-9
lines changed

8 files changed

+66
-9
lines changed

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"access": "restricted",
88
"baseBranch": "main",
99
"updateInternalDependencies": "patch",
10-
"ignore": []
10+
"ignore": ["sandbox-vite"]
1111
}

.changeset/khaki-paws-kneel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@pandacss/language-server': patch
3+
---
4+
5+
Add support for color-hints / diagnostics / inlay-hints in `sva` definition and `pattern` usage

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"name": "panda",
2+
"name": "panda-vscode",
33
"version": "0.0.1",
44
"private": true,
55
"description": "The repository of css panda",
66
"scripts": {
77
"prepare": "yarn build-fast",
8-
"dev": "yarn workspaces foreach -A --exclude 'sandbox-vite' -pt run dev",
9-
"build-fast": "yarn workspaces foreach -A --exclude 'sandbox-vite' -pt run build-fast",
10-
"build": "yarn workspaces foreach -A --exclude 'sandbox-vite' run build",
8+
"dev": "yarn workspaces foreach -pA --exclude 'sandbox-vite' --exclude 'panda-vscode' run dev",
9+
"build-fast": "yarn workspaces foreach -pA --exclude 'sandbox-vite' --exclude 'panda-vscode' run build-fast",
10+
"build": "yarn workspaces foreach -A --exclude 'sandbox-vite' --exclude 'panda-vscode' run build",
1111
"test": "vitest",
1212
"lint": "eslint packages --ext .ts",
1313
"fmt": "prettier --write packages",

packages/language-server/src/project-helper.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,22 @@ export class ProjectHelper {
9191
onResult(Object.assign({}, item, { box: map.value.get('base'), data: [base] })),
9292
)
9393
})
94+
parserResult.sva.forEach((item) => {
95+
const map = item.box
96+
if (!box.isMap(map)) return
97+
return item.data.forEach(({ base }) =>
98+
onResult(Object.assign({}, item, { box: map.value.get('base'), data: [base] })),
99+
)
100+
})
101+
parserResult.pattern.forEach((set, name) => {
102+
set.forEach((item) => {
103+
const map = item.box
104+
if (!box.isMap(map)) return
105+
return item.data.forEach((obj) => {
106+
onResult({ box: map, data: [obj], name, type: 'pattern' })
107+
})
108+
})
109+
})
94110
}
95111
}
96112

sandbox/vite/panda.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineConfig } from '@pandacss/dev'
2+
import { button} from "./src/button.recipe"
23

34
export default defineConfig({
45
// Whether to use css reset
@@ -13,6 +14,9 @@ export default defineConfig({
1314
// Useful for theme customization
1415
theme: {
1516
extend: {
17+
recipes: {
18+
button,
19+
},
1620
semanticTokens: {
1721
colors: {
1822
danger: {

sandbox/vite/src/App.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1-
import { css } from '../styled-system/css'
1+
import { css, sva } from '../styled-system/css'
2+
import { button } from '../styled-system/recipes'
3+
import { flex } from '../styled-system/patterns'
24
import './App.css'
35

6+
const card = sva({
7+
slots: ['label', 'icon'],
8+
base: {
9+
label: {
10+
color: 'red.200',
11+
},
12+
icon: {
13+
fontSize: '3xl',
14+
},
15+
},
16+
})
17+
18+
card()
19+
button({ size: 'sm' })
20+
flex({ direction: 'column', gap: 'initial', color: 'teal.300' })
21+
422
function App() {
523
return (
624
<>
725
<div
826
className={css({
9-
color: "blue",
27+
color: 'blue',
1028
outlineColor: 'bg',
1129
backgroundColor: 'bg.text',
1230
bgColor: 'bg',

sandbox/vite/src/button.recipe.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineRecipe } from "@pandacss/dev";
2+
3+
export const button = defineRecipe({
4+
base: {
5+
color: "amber.200",
6+
},
7+
variants: {
8+
size: {
9+
sm: {
10+
fontSize: "2xl",
11+
}
12+
}
13+
}
14+
})

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10530,9 +10530,9 @@ __metadata:
1053010530
languageName: unknown
1053110531
linkType: soft
1053210532

10533-
"panda@workspace:.":
10533+
"panda-vscode@workspace:.":
1053410534
version: 0.0.0-use.local
10535-
resolution: "panda@workspace:."
10535+
resolution: "panda-vscode@workspace:."
1053610536
dependencies:
1053710537
"@changesets/changelog-github": "npm:0.4.8"
1053810538
"@changesets/cli": "npm:2.26.2"

0 commit comments

Comments
 (0)