@dmisdm/pandatail 0.2.0 → 0.4.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
@@ -1,113 +1,120 @@
1
- # pandatail
1
+ # @dmisdm/pandatail
2
2
 
3
- A **PandaCSS preset** that mirrors every token in your Tailwind v4
4
- `@theme { … }` block into typed Panda style props.
3
+ Use your Tailwind v4 stylesheet as the **only** config for [Panda CSS](https://panda-css.com).
5
4
 
6
- ## Install
5
+ `@theme` becomes Panda tokens (still pointing at Tailwind's CSS variables, so both engines agree),
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
8
 
9
+ ```css
10
+ /* src/app.css */
11
+ @import "tailwindcss";
12
+ @source "../ui";
13
+ @source not "../ui/legacy.tsx";
14
+ @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; }
8
17
  ```
9
- npm install -D @dmisdm/pandatail
18
+
19
+ ```tsx
20
+ import { css } from "./styled-system/css";
21
+ css({ bg: "brand.500", rounded: "pill", _hocus: { p: 2 }, _dark: { bg: "blue.900" } });
10
22
  ```
11
23
 
12
- Then install Panda itself if you don't have it:
24
+ ## Requirements
25
+
26
+ Panda v2 (ESM, Node >= 22) and Tailwind v4.
13
27
 
14
28
  ```sh
15
- npm install -D @pandacss/dev
16
- npx panda init --postcss
29
+ npm i -D @dmisdm/pandatail @pandacss/dev @pandacss/compiler @pandacss/config \
30
+ @pandacss/preset-base @pandacss/compiler-shared tailwindcss @tailwindcss/node
17
31
  ```
18
32
 
19
- - Tailwind owns the values; Panda owns the typed API. There is **no value
20
- duplication** — every Panda token resolves to `var(--<tailwind-name>)`.
21
- - Default Tailwind palettes (`blue.500`, `mauve.300`, …) and your custom
22
- `@theme` additions (`brand.500`, `--radius-pill`, …) are typed
23
- automatically.
24
- - Tailwind utilities and Panda style props coexist in the same JSX. Refactor
25
- one side at a time.
33
+ Keep `@tailwindcss/node` on the same version as `tailwindcss` and your Tailwind
34
+ build plugin (such as `@tailwindcss/vite`). Pandatail uses Tailwind's Node adapter to resolve CSS imports and
35
+ load plugins, then reads the resolved theme before Tailwind emits CSS.
26
36
 
27
- ```tsx
28
- // CSS — your @theme block is the single source of truth
29
- @import "tailwindcss";
30
- @theme {
31
- --color-brand-500: oklch(0.62 0.21 260);
32
- --radius-pill: 999px;
33
- }
34
-
35
- // TSX — Panda autocomplete & TS errors against the same tokens
36
- <tw.span bg="brand.500" rounded="pill" px={3} py={1} color="white">
37
- New release
38
- </tw.span>
37
+ ## CLI
38
+
39
+ ```sh
40
+ pandatail build --css src/app.css # codegen + stylesheet (default)
41
+ pandatail codegen --css src/app.css # styled-system/ only
42
+ pandatail cssgen --css src/app.css -o out.css # stylesheet only
43
+ pandatail watch --css src/app.css # rebuild on change
39
44
  ```
40
45
 
41
- Tailwind v4 (`tailwindcss@^4`) is a peer dependency and is loaded from your
42
- existing setup — the preset doesn't require its own copy.
46
+ | Option | Meaning |
47
+ | --- | --- |
48
+ | `-c, --css` | Tailwind entry stylesheet (required) |
49
+ | `-o, --out` | Output CSS file (default `<outdir>/styles.css`) |
50
+ | `--config` | Optional `panda.config.ts`, merged on top |
51
+ | `--outdir` | Codegen dir (default `styled-system`; keep the last segment `styled-system` or set `importMap` in your config) |
52
+ | `-i, --include` | Source glob, repeatable. Replaces the defaults |
53
+ | `--cwd` | Project root |
54
+
55
+ Import the generated `styled-system/styles.css` after Tailwind's CSS.
43
56
 
44
- ## Configure
57
+ ## Vite plugin
58
+
59
+ Runs codegen and the stylesheet before your modules build, then watches CSS, config and source files during `vite dev`.
45
60
 
46
61
  ```ts
47
- // panda.config.ts
48
- import { defineConfig } from "@pandacss/dev";
49
- import { tailwindPresetSync } from "@dmisdm/pandatail";
50
-
51
- export default defineConfig({
52
- preflight: false, // Tailwind already ships preflight
53
- jsxFramework: "react",
54
- presets: [
55
- "@pandacss/preset-base",
56
- tailwindPresetSync({ cssPath: "./src/tailwind.css" }),
62
+ // vite.config.ts
63
+ import { pandatail } from "@dmisdm/pandatail/vite";
64
+
65
+ export default {
66
+ plugins: [
67
+ pandatail({
68
+ css: "src/app.css",
69
+ jsxStyleProps: "all", // <Box bg="brand.500" p="4" />
70
+ jsxFramework: "react",
71
+ }),
57
72
  ],
58
- include: ["./src/**/*.{ts,tsx}"],
59
- outdir: "styled-system",
60
- });
73
+ };
61
74
  ```
62
75
 
63
- Then:
76
+ Options: everything `createPandatailProject` takes (`css`, `config`, `include`, `exclude`, `outdir`, `jsxFramework`,
77
+ `jsxStyleProps`, `preflight`, `importMap`, `prefix`, `hash`, `minify`), plus `outfile` and `verbose`. Explicit options win over a
78
+ `config` file. Import `styled-system/styles.css` after Tailwind's CSS. A change to the entry CSS or config reloads the project and the page.
64
79
 
65
- ```sh
66
- npx panda codegen
67
- ```
80
+ ## What maps, and what doesn't
68
81
 
69
- ## How it works
82
+ | Tailwind | Panda |
83
+ | --- | --- |
84
+ | `@theme` | `theme.tokens` + `breakpoints`, as `var(--…)` references |
85
+ | `@source "x"` / `@source not "x"` | `include` / `exclude` |
86
+ | `@custom-variant n (sel);` | `conditions.extend.n` |
87
+ | `@custom-variant n { &:hover, &:focus { @slot } }` | same (single selector or at-rule wrapping one `@slot`) |
88
+ | `@plugin` | loaded for token extraction; plugin-defined utilities are not Panda utilities |
89
+ | `@source inline(...)`, complex `@custom-variant` blocks, `@utility` | warned about, not mapped |
70
90
 
71
- The preset reads your Tailwind entry CSS, finds every `--*` token inside
72
- `@theme { … }` blocks (including the ones Tailwind itself ships in
73
- `tailwindcss/theme.css`), and registers each one as a Panda token whose value
74
- is a `var()` reference back to the CSS variable.
91
+ Anything CSS can't express (text styles, recipes, patterns, utilities) goes in an optional
92
+ `panda.config.ts` passed with `--config`. It is merged after Tailwind's tokens, so it wins.
75
93
 
76
- Namespaces map to Panda categories:
94
+ ## Programmatic API
77
95
 
78
- | Tailwind namespace | Panda category |
79
- | ------------------ | ----------------------------------- |
80
- | `--color-*` | `colors` |
81
- | `--spacing-*` | `spacing` + `sizes` |
82
- | `--radius-*` | `radii` |
83
- | `--shadow-*` | `shadows` |
84
- | `--text-*` | `fontSizes` |
85
- | `--font-*` | `fonts` |
86
- | `--font-weight-*` | `fontWeights` |
87
- | `--leading-*` | `lineHeights` |
88
- | `--tracking-*` | `letterSpacings` |
89
- | `--breakpoint-*` | `theme.breakpoints` (media queries) |
90
- | `--container-*` | `sizes` |
96
+ ```ts
97
+ import { createPandatailProject, buildProject } from "@dmisdm/pandatail";
91
98
 
92
- Tailwind derives numeric scales (`p-4`, `leading-6`) from the single
93
- `--spacing` token; the preset synthesises those steps into Panda's
94
- `spacing`, `sizes`, and `lineHeights` categories so the typed APIs match
95
- Tailwind's coverage.
99
+ const project = await createPandatailProject({ css: "src/app.css", config: "panda.config.ts" });
100
+ const { cssPath, diagnostics } = buildProject(project);
101
+ // project.compiler is a Panda compiler; project.warnings lists unmapped CSS.
102
+ ```
96
103
 
97
- ## API
104
+ Prefer your own `panda.config.ts`? `tailwindPreset({ cssPath })` is async and returns a normal Panda preset
105
+ (use top-level `await` in the config).
98
106
 
99
- ```ts
100
- import {
101
- tailwindPreset, // async — uses Tailwind's design-system loader
102
- tailwindPresetSync, // sync — call from panda.config.ts (recommended)
103
- extractTokens,
104
- extractTokensSync,
105
- } from "@dmisdm/pandatail";
106
- ```
107
+ ## Limitations
108
+
109
+ - No PostCSS plugin yet; use the Vite plugin or the CLI (`watch` for dev).
110
+ - `@theme` changes need a rebuild; `watch` reloads the whole project when the CSS or config changes.
111
+ - Panda's cascade layers (`reset, base, tokens, recipes, utilities`) are separate from Tailwind's; check ordering if both emit a `utilities` layer.
112
+
113
+ ## Changes in 0.4.0
107
114
 
108
- Use `tailwindPresetSync` in `panda.config.ts` — Panda bundles configs to CJS
109
- and rejects top-level `await`.
115
+ 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.
110
116
 
111
- ## License
117
+ ## Changes in 0.3.0
112
118
 
113
- MIT
119
+ Breaking: sync API (`tailwindPresetSync`) and the demo site removed; Panda peers are `^2.0.0`.
120
+ Added: config-less compiler (`createPandatailProject`) and the `pandatail` CLI.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};