@dmisdm/pandatail 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,8 @@ Use your Tailwind v4 stylesheet as the **only** config for [Panda CSS](https://p
4
4
 
5
5
  `@theme` becomes Panda tokens (still pointing at Tailwind's CSS variables, so both engines agree),
6
6
  `@source` becomes Panda's `include`/`exclude`, and `@custom-variant` becomes Panda conditions.
7
- No `panda.config.ts` required. You get Panda's typed `css()`, recipes and slot recipes alongside Tailwind utilities.
7
+ No `panda.config.ts` required. Use Panda's typed `css()` alongside Tailwind utilities, and try the experimental
8
+ [`@panda` directive](#experimental-panda-css-config) for styles and recipes.
8
9
 
9
10
  ```css
10
11
  /* src/app.css */
@@ -12,13 +13,26 @@ No `panda.config.ts` required. You get Panda's typed `css()`, recipes and slot r
12
13
  @source "../ui";
13
14
  @source not "../ui/legacy.tsx";
14
15
  @custom-variant dark (&:where(.dark, .dark *));
15
- @custom-variant hocus { &:hover, &:focus { @slot; } }
16
- @theme { --color-brand-500: oklch(0.62 0.21 260); --radius-pill: 999px; }
16
+ @custom-variant hocus {
17
+ &:hover,
18
+ &:focus {
19
+ @slot;
20
+ }
21
+ }
22
+ @theme {
23
+ --color-brand-500: oklch(0.62 0.21 260);
24
+ --radius-pill: 999px;
25
+ }
17
26
  ```
18
27
 
19
28
  ```tsx
20
29
  import { css } from "./styled-system/css";
21
- css({ bg: "brand.500", rounded: "pill", _hocus: { p: 2 }, _dark: { bg: "blue.900" } });
30
+ css({
31
+ bg: "brand.500",
32
+ rounded: "pill",
33
+ _hocus: { p: 2 },
34
+ _dark: { bg: "blue.900" },
35
+ });
22
36
  ```
23
37
 
24
38
  ## Requirements
@@ -42,19 +56,32 @@ pandatail codegen --css src/app.css # styled-system/ only
42
56
  pandatail cssgen --css src/app.css -o out.css # stylesheet only
43
57
  pandatail watch --css src/app.css # rebuild on change
44
58
  pandatail studio --css src/app.css # live Panda Studio (Panda >= 2.4)
59
+ pandatail check --css src/app.css # diagnostics without codegen or CSS output
45
60
  ```
46
61
 
47
- | Option | Meaning |
48
- | --- | --- |
49
- | `-c, --css` | Tailwind entry stylesheet (required) |
50
- | `-o, --out` | Output CSS file (default `<outdir>/styles.css`) |
51
- | `--config` | Optional `panda.config.ts`, merged on top |
52
- | `--outdir` | Codegen dir (default `styled-system`; keep the last segment `styled-system` or set `importMap` in your config) |
53
- | `-i, --include` | Source glob, repeatable. Replaces the defaults |
54
- | `--cwd` | Project root |
62
+ | Option | Meaning |
63
+ | --------------- | -------------------------------------------------------------------------------------------------------------- |
64
+ | `-c, --css` | Tailwind entry stylesheet (takes precedence over `--shadcn`) |
65
+ | `--shadcn` | Read the entry stylesheet from `components.json` → `tailwind.css` |
66
+ | `-o, --out` | Output CSS file (default `<outdir>/styles.css`) |
67
+ | `--config` | Optional `panda.config.ts`, merged on top |
68
+ | `--outdir` | Codegen dir (default `styled-system`; keep the last segment `styled-system` or set `importMap` in your config) |
69
+ | `-i, --include` | Source glob, repeatable. Replaces the defaults |
70
+ | `--cwd` | Project root |
55
71
 
56
72
  Import the generated `styled-system/styles.css` after Tailwind's CSS.
57
73
 
74
+ For shadcn projects, use `--shadcn` in place of `--css` with any project command:
75
+
76
+ ```sh
77
+ pandatail build --shadcn
78
+ pandatail studio --shadcn --cwd packages/ui
79
+ ```
80
+
81
+ At startup, Pandatail reads `components.json` from `--cwd` (or the current directory) and resolves
82
+ `tailwind.css` relative to that directory. In a monorepo, point `--cwd` at the workspace that owns
83
+ the config. An explicit `--css` skips config discovery.
84
+
58
85
  ### Panda Studio
59
86
 
60
87
  `pandatail studio --css src/app.css` opens [Panda Studio](https://panda-css.com/docs/theming/studio)
@@ -67,9 +94,171 @@ Studio previews resolve simple aliases from `@theme` and unconditional `:root` d
67
94
  stylesheets. They don't run your app's CSS cascade, so conditional overrides and unresolved CSS
68
95
  variables may not render. Normal builds still reference Tailwind's variables.
69
96
 
97
+ ## Experimental `@panda` CSS config
98
+
99
+ Keep colors, shadows, and other individual tokens in Tailwind's `@theme`. Use `@panda` for named
100
+ compositions and component recipes. For example, a surface that combines color, border, radius,
101
+ and elevation is a Panda **layer style**, not a new token type.
102
+
103
+ ```css
104
+ /* app.css */
105
+ @import "tailwindcss";
106
+ @reference "./design.panda.css";
107
+
108
+ @theme static {
109
+ --color-panel: #f4f4f5;
110
+ --color-panel-foreground: #18181b;
111
+ --radius-panel: 0.75rem;
112
+ --shadow-raised: 0 2px 6px #0002;
113
+ --text-title: 1.5rem;
114
+ --text-title--line-height: 1.25;
115
+ }
116
+ ```
117
+
118
+ ```css
119
+ /* design.panda.css */
120
+ @panda text-style title {
121
+ font-size: title;
122
+ line-height: var(--text-title--line-height);
123
+ font-weight: 600;
124
+ }
125
+
126
+ @panda layer-style surface.raised {
127
+ @description "Elevated panel";
128
+ background-color: panel;
129
+ color: panel-foreground;
130
+ border: 1px solid;
131
+ border-radius: panel;
132
+ box-shadow: raised;
133
+ &:hover {
134
+ box-shadow: none;
135
+ }
136
+ }
137
+
138
+ @panda recipe card {
139
+ layer-style: surface.raised;
140
+ text-style: title;
141
+ @option density regular {
142
+ padding: 1rem;
143
+ }
144
+ @option density compact {
145
+ padding: 0.75rem;
146
+ }
147
+ @defaults {
148
+ density: regular;
149
+ }
150
+ }
151
+ ```
152
+
153
+ `css({ textStyle: "title", layerStyle: "surface.raised" })` and `card({ density: "compact" })`
154
+ use the generated, typed Panda APIs. Style blocks accept CSS declarations, nested selectors and
155
+ CSS queries such as `@media`. Values can be Panda token names (like `panel`) or CSS values.
156
+ The other composition directive is `@panda animation-style`; use dotted names to group styles
157
+ and `.DEFAULT` for a group's base style.
158
+
159
+ Prefer a relative `@reference` for these definitions: Pandatail reads it, but Tailwind doesn't
160
+ emit its rules. Inline `@panda` blocks also work in Pandatail, but Tailwind's optimizer can warn
161
+ about and retain unknown block at-rules. `@theme static` ensures Tailwind outputs variables used
162
+ only by Panda. Tailwind's `@apply` and `@variant` inside Panda style blocks aren't supported.
163
+
164
+ For options without CSS shorthand, add `@panda config "./panda.json";` in either stylesheet.
165
+ This accepts plain Panda config data, such as semantic tokens, slot recipes, compound variants,
166
+ `staticCss`, and `strictTokens`. Pandatail locates the JSON relative to the declaring stylesheet;
167
+ settings such as `include` and `outdir` are still relative to the project root. Precedence is:
168
+ Panda presets → Tailwind and `@panda` styles → JSON → explicit `--config` → explicit options.
169
+ Use a JS/TS config for JavaScript-backed transforms.
170
+
171
+ Studio receives these entries through Panda's live design-system spec. Surface names and descriptions
172
+ are reported as layer styles; the hosted Studio controls their presentation. This doesn't add a custom
173
+ Surfaces tab or preview renderer. To try the included fixture from this repo:
174
+
175
+ ```sh
176
+ bun run build
177
+ node dist/cli.js studio --cwd test/fixtures/css-config --css app.css
178
+ ```
179
+
180
+ ## Editor support and checking
181
+
182
+ `pandatail check` uses the same CSS parser as build and Studio, and checks the resolved project:
183
+
184
+ ```sh
185
+ pandatail check --css src/app.css
186
+ pandatail check --shadcn --cwd packages/ui --warnings-as-errors
187
+ pandatail check --css src/app.css --json
188
+ ```
189
+
190
+ It reports malformed blocks, unsupported nesting, invalid recipe defaults, and duplicate options
191
+ with file and line/column ranges. It then checks named composition references (`layer-style`,
192
+ `text-style`, `animation-style`), explicit `token(path)` references against the merged theme, and
193
+ Panda's diagnostics for the scanned source files. It doesn't guess whether arbitrary CSS values,
194
+ `var()` calls or `token(path, fallback)` are mistakes. Use the CSS language server for ordinary CSS linting.
195
+ It writes no Panda artifacts, exits nonzero on errors (and on warnings with `--warnings-as-errors`),
196
+ and `--json` returns `{ files, diagnostics }` for CI or other tools. The full check loads the project's
197
+ Tailwind/Panda config and plugins just like build, so run it in trusted projects.
198
+
199
+ ### Zed + Tailwind IntelliSense
200
+
201
+ The **Pandatail companion** provides top-level `@panda` and kind completions, hover docs, and live
202
+ syntax diagnostics on unsaved buffers. It doesn't replace CSS or Tailwind IntelliSense and it doesn't
203
+ load imports, plugins, or project config. Use `check` for cross-file/theme-aware validation.
204
+
205
+ From a checkout, run `bun run build`, then use `zed: install dev extension` and select `editors/zed/`.
206
+ Building the dev extension requires Zed's Rust Wasm target (`wasm32-wasip2`). Add the companion to your
207
+ existing `languages.CSS.language_servers` list. For example, with Tailwind CSS mode:
208
+
209
+ ```json
210
+ {
211
+ "languages": {
212
+ "CSS": {
213
+ "language_servers": [
214
+ "tailwindcss-intellisense-css",
215
+ "pandatail-language-server",
216
+ "!vscode-css-language-server"
217
+ ]
218
+ }
219
+ },
220
+ "lsp": {
221
+ "pandatail-language-server": {
222
+ "binary": {
223
+ "path": "node",
224
+ "arguments": [
225
+ "/absolute/path/to/pandatail/dist/cli.js",
226
+ "lsp",
227
+ "--stdio"
228
+ ]
229
+ }
230
+ }
231
+ }
232
+ }
233
+ ```
234
+
235
+ If `pandatail` is already on Zed's PATH, omit the `binary` override. If Zed can't find `node`, use its
236
+ absolute path. The adapter is opt-in and does not install the CLI or alter editor settings.
237
+
238
+ ### CSS custom data
239
+
240
+ VS Code and other clients that forward [CSS custom data](https://github.com/microsoft/vscode-css-languageservice/blob/main/docs/customData.md)
241
+ can teach their usual CSS service the directive and property names without turning off unknown-at-rule
242
+ linting. For VS Code, point `css.customData` at the bundled file in workspace settings:
243
+
244
+ ```json
245
+ {
246
+ "css.customData": [
247
+ "node_modules/@dmisdm/pandatail/editors/pandatail.css-data.json"
248
+ ]
249
+ }
250
+ ```
251
+
252
+ Custom data alone documents names; it cannot parse `@panda recipe …` or check that `@defaults` values
253
+ are declared. In Zed, use the companion rather than adding this setting to Tailwind's language server.
254
+ The companion does not filter diagnostics from other active servers.
255
+
70
256
  ## Vite plugin
71
257
 
72
- Runs codegen and the stylesheet before your modules build, then watches CSS, config and source files during `vite dev`.
258
+ Runs the same project checks as `pandatail check` automatically, before codegen and CSS output.
259
+ Errors fail `vite build`; warnings are logged without blocking it. In `vite dev`, errors go to the
260
+ Vite overlay and Pandatail keeps the last good output. The dev server keeps watching and rebuilds
261
+ when you fix the file. No separate checker process is needed.
73
262
 
74
263
  ```ts
75
264
  // vite.config.ts
@@ -101,21 +290,25 @@ Options: everything `createPandatailProject` takes (`css`, `config`, `include`,
101
290
  | `@plugin` | loaded for token extraction; plugin-defined utilities are not Panda utilities |
102
291
  | `@source inline(...)`, complex `@custom-variant` blocks, `@utility` | warned about, not mapped |
103
292
 
104
- Anything CSS can't express (text styles, recipes, patterns, utilities) goes in an optional
105
- `panda.config.ts` passed with `--config`. It is merged after Tailwind's tokens, so it wins.
293
+ Panda-specific definitions can go in `@panda`, its referenced JSON config, or an optional
294
+ `panda.config.ts` passed with `--config`.
106
295
 
107
296
  ## Programmatic API
108
297
 
109
298
  ```ts
110
299
  import { createPandatailProject, buildProject } from "@dmisdm/pandatail";
111
300
 
112
- const project = await createPandatailProject({ css: "src/app.css", config: "panda.config.ts" });
301
+ const project = await createPandatailProject({
302
+ css: "src/app.css",
303
+ config: "panda.config.ts",
304
+ });
113
305
  const { cssPath, diagnostics } = buildProject(project);
114
306
  // project.compiler is a Panda compiler; project.warnings lists unmapped CSS.
115
307
  ```
116
308
 
117
309
  Prefer your own `panda.config.ts`? `tailwindPreset({ cssPath })` is async and returns a normal Panda preset
118
- (use top-level `await` in the config).
310
+ (use top-level `await` in the config). It includes the `@panda` style and recipe definitions; only
311
+ Pandatail's project loader uses the project-level `@panda config` JSON.
119
312
 
120
313
  ## Limitations
121
314
 
@@ -123,6 +316,13 @@ Prefer your own `panda.config.ts`? `tailwindPreset({ cssPath })` is async and re
123
316
  - `@theme` changes need a rebuild; `watch` reloads the whole project when the CSS or config changes.
124
317
  - Panda's cascade layers (`reset, base, tokens, recipes, utilities`) are separate from Tailwind's; check ordering if both emit a `utilities` layer.
125
318
 
319
+ ## Changes in 0.6.0
320
+
321
+ - `--shadcn` discovers the Tailwind entry stylesheet from `components.json`.
322
+ - Experimental `@panda` CSS supports recipes, text/layer/animation styles, and a JSON config reference.
323
+ - `pandatail check` validates the DSL and project references. Vite runs the checks automatically and reports errors through its dev overlay.
324
+ - The companion language server adds `@panda` completion, hover help, and live syntax diagnostics.
325
+
126
326
  ## Changes in 0.4.0
127
327
 
128
328
  Tailwind's Node adapter now resolves stylesheet imports and loads plugins and configs. This supports CSS-only package exports such as `tw-animate-css`. Add the `@tailwindcss/node` peer dependency at the same version as your Tailwind installation.
@@ -0,0 +1,14 @@
1
+ import { type Diagnostic } from "@pandacss/compiler-shared";
2
+ import { type PandatailOptions, type PandatailProject } from "./project";
3
+ export interface CheckResult {
4
+ /** Source files Panda scanned. CSS/config issues are also included in diagnostics. */
5
+ files: string[];
6
+ diagnostics: Diagnostic[];
7
+ }
8
+ /** Check an unsaved stylesheet without reading any project dependencies. */
9
+ export declare function checkPandaDocument(css: string, file: string): Diagnostic[];
10
+ /** Validate the resolved stylesheet and scan usages without generating artifacts. */
11
+ export declare function checkProject(options: PandatailOptions): Promise<CheckResult>;
12
+ /** Check the loaded compiler and leave its source usages ready for emission. */
13
+ export declare function checkLoadedProject(project: PandatailProject): CheckResult;
14
+ export declare function projectIssues(error: unknown, file?: string): Diagnostic[];