Skip to content

Commit

Permalink
feat: add color-hints/diagnostics/inlay-hints for sva/pattern/recipes (
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Nov 2, 2023
2 parents 61be3d2 + de1050f commit 9c664da
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
"ignore": ["sandbox-vite"]
}
5 changes: 5 additions & 0 deletions .changeset/khaki-paws-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pandacss/language-server': patch
---

Add support for color-hints / diagnostics / inlay-hints in `sva` definition and `pattern` usage
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "panda",
"name": "panda-vscode",
"version": "0.0.1",
"private": true,
"description": "The repository of css panda",
"scripts": {
"prepare": "yarn build-fast",
"dev": "yarn workspaces foreach -A --exclude 'sandbox-vite' -pt run dev",
"build-fast": "yarn workspaces foreach -A --exclude 'sandbox-vite' -pt run build-fast",
"build": "yarn workspaces foreach -A --exclude 'sandbox-vite' run build",
"dev": "yarn workspaces foreach -pA --exclude 'sandbox-vite' --exclude 'panda-vscode' run dev",
"build-fast": "yarn workspaces foreach -pA --exclude 'sandbox-vite' --exclude 'panda-vscode' run build-fast",
"build": "yarn workspaces foreach -A --exclude 'sandbox-vite' --exclude 'panda-vscode' run build",
"test": "vitest",
"lint": "eslint packages --ext .ts",
"fmt": "prettier --write packages",
Expand Down
16 changes: 16 additions & 0 deletions packages/language-server/src/project-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ export class ProjectHelper {
onResult(Object.assign({}, item, { box: map.value.get('base'), data: [base] })),
)
})
parserResult.sva.forEach((item) => {
const map = item.box
if (!box.isMap(map)) return
return item.data.forEach(({ base }) =>
onResult(Object.assign({}, item, { box: map.value.get('base'), data: [base] })),
)
})
parserResult.pattern.forEach((set, name) => {
set.forEach((item) => {
const map = item.box
if (!box.isMap(map)) return
return item.data.forEach((obj) => {
onResult({ box: map, data: [obj], name, type: 'pattern' })
})
})
})
}
}

Expand Down
4 changes: 4 additions & 0 deletions sandbox/vite/panda.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from '@pandacss/dev'
import { button} from "./src/button.recipe"

export default defineConfig({
// Whether to use css reset
Expand All @@ -13,6 +14,9 @@ export default defineConfig({
// Useful for theme customization
theme: {
extend: {
recipes: {
button,
},
semanticTokens: {
colors: {
danger: {
Expand Down
22 changes: 20 additions & 2 deletions sandbox/vite/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
import { css } from '../styled-system/css'
import { css, sva } from '../styled-system/css'
import { button } from '../styled-system/recipes'
import { flex } from '../styled-system/patterns'
import './App.css'

const card = sva({
slots: ['label', 'icon'],
base: {
label: {
color: 'red.200',
},
icon: {
fontSize: '3xl',
},
},
})

card()
button({ size: 'sm' })
flex({ direction: 'column', gap: 'initial', color: 'teal.300' })

function App() {
return (
<>
<div
className={css({
color: "blue",
color: 'blue',
outlineColor: 'bg',
backgroundColor: 'bg.text',
bgColor: 'bg',
Expand Down
14 changes: 14 additions & 0 deletions sandbox/vite/src/button.recipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineRecipe } from "@pandacss/dev";

export const button = defineRecipe({
base: {
color: "amber.200",
},
variants: {
size: {
sm: {
fontSize: "2xl",
}
}
}
})
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10530,9 +10530,9 @@ __metadata:
languageName: unknown
linkType: soft

"panda@workspace:.":
"panda-vscode@workspace:.":
version: 0.0.0-use.local
resolution: "panda@workspace:."
resolution: "panda-vscode@workspace:."
dependencies:
"@changesets/changelog-github": "npm:0.4.8"
"@changesets/cli": "npm:2.26.2"
Expand Down

0 comments on commit 9c664da

Please sign in to comment.