From de1050fb02f3068216c2a393c88c045c004b8463 Mon Sep 17 00:00:00 2001 From: Alexandre Stahmer Date: Thu, 2 Nov 2023 00:42:46 +0100 Subject: [PATCH] feat: add color-hints/diagnostics/inlay-hints for sva/pattern/recipes --- .changeset/config.json | 2 +- .changeset/khaki-paws-kneel.md | 5 +++++ package.json | 8 +++---- .../language-server/src/project-helper.ts | 16 ++++++++++++++ sandbox/vite/panda.config.ts | 4 ++++ sandbox/vite/src/App.tsx | 22 +++++++++++++++++-- sandbox/vite/src/button.recipe.ts | 14 ++++++++++++ yarn.lock | 4 ++-- 8 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 .changeset/khaki-paws-kneel.md create mode 100644 sandbox/vite/src/button.recipe.ts diff --git a/.changeset/config.json b/.changeset/config.json index ab848d1..f1652ed 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -7,5 +7,5 @@ "access": "restricted", "baseBranch": "main", "updateInternalDependencies": "patch", - "ignore": [] + "ignore": ["sandbox-vite"] } diff --git a/.changeset/khaki-paws-kneel.md b/.changeset/khaki-paws-kneel.md new file mode 100644 index 0000000..9af3816 --- /dev/null +++ b/.changeset/khaki-paws-kneel.md @@ -0,0 +1,5 @@ +--- +'@pandacss/language-server': patch +--- + +Add support for color-hints / diagnostics / inlay-hints in `sva` definition and `pattern` usage diff --git a/package.json b/package.json index 6f90a6f..5c968c4 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/language-server/src/project-helper.ts b/packages/language-server/src/project-helper.ts index 92052a2..fda8150 100644 --- a/packages/language-server/src/project-helper.ts +++ b/packages/language-server/src/project-helper.ts @@ -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' }) + }) + }) + }) } } diff --git a/sandbox/vite/panda.config.ts b/sandbox/vite/panda.config.ts index a3c8047..8005662 100644 --- a/sandbox/vite/panda.config.ts +++ b/sandbox/vite/panda.config.ts @@ -1,4 +1,5 @@ import { defineConfig } from '@pandacss/dev' +import { button} from "./src/button.recipe" export default defineConfig({ // Whether to use css reset @@ -13,6 +14,9 @@ export default defineConfig({ // Useful for theme customization theme: { extend: { + recipes: { + button, + }, semanticTokens: { colors: { danger: { diff --git a/sandbox/vite/src/App.tsx b/sandbox/vite/src/App.tsx index 9a48b5e..02c3171 100644 --- a/sandbox/vite/src/App.tsx +++ b/sandbox/vite/src/App.tsx @@ -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 ( <>