@poveste/plugin-tailwind 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 +28 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +721 -0
- package/package.json +45 -0
- package/src/index.spec.ts +41 -0
- package/src/index.ts +765 -0
- package/tsconfig.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @poveste/plugin-tailwind
|
|
2
|
+
|
|
3
|
+
Renders a project's Tailwind design system — colours, spacing, typography — as a
|
|
4
|
+
story in its book.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { HstTailwind } from '@poveste/plugin-tailwind'
|
|
8
|
+
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
plugins: [
|
|
11
|
+
HstTailwind(),
|
|
12
|
+
],
|
|
13
|
+
})
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The CSS entrypoint is found automatically: the plugin looks for the usual names
|
|
17
|
+
(`src/style.css`, `src/app.css`, `app/assets/css/main.css`, …) and takes the
|
|
18
|
+
first that is actually a Tailwind entrypoint — one importing `tailwindcss`, or
|
|
19
|
+
declaring `@theme`. Point it somewhere else with `HstTailwind({ cssFile })`.
|
|
20
|
+
|
|
21
|
+
Tailwind v4 only. The theme is read from CSS custom properties, which is where
|
|
22
|
+
v4 keeps it; a v3 project using `@tailwind base` has nothing for this to read.
|
|
23
|
+
|
|
24
|
+
Adding the plugin also adds a `Design System` group to the story tree.
|
|
25
|
+
|
|
26
|
+
> This used to be built into `poveste` and enabled by default, which meant a
|
|
27
|
+
> project that merely had a file named `src/app.css` got a design-system group
|
|
28
|
+
> and a story full of Tailwind's defaults it never asked for. It is opt-in now.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Plugin } from '@poveste/shared';
|
|
2
|
+
export interface TailwindTokensOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Path to the CSS entrypoint that imports Tailwind and declares `@theme`.
|
|
5
|
+
* Tailwind v4 is CSS-first, so the design tokens are read from CSS rather
|
|
6
|
+
* than from a JS config. Auto-detected when omitted.
|
|
7
|
+
*/
|
|
8
|
+
cssFile?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Whether a stylesheet is a Tailwind entrypoint, rather than merely a file with
|
|
12
|
+
* one of the names Tailwind entrypoints tend to have.
|
|
13
|
+
*
|
|
14
|
+
* Every name in `CSS_ENTRY_CANDIDATES` is an ordinary one — `src/app.css`,
|
|
15
|
+
* `styles.css` — so matching on the name alone hands the whole feature to
|
|
16
|
+
* projects that have never used Tailwind: a `Design System` group inserted into
|
|
17
|
+
* their tree, and a story rendering Tailwind's own defaults as if it were their
|
|
18
|
+
* design system.
|
|
19
|
+
*
|
|
20
|
+
* Both markers are Tailwind v4, which is what this plugin reads: the theme comes
|
|
21
|
+
* from CSS custom properties, so a v3 project using `@tailwind base` would be
|
|
22
|
+
* accepted here and then produce nothing.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isTailwindEntry(filePath: string): boolean;
|
|
25
|
+
export declare function HstTailwind(options?: TailwindTokensOptions): Plugin;
|
|
26
|
+
/** @deprecated Use `HstTailwind`. Kept for books that named the old builtin. */
|
|
27
|
+
export declare const tailwindTokens: typeof HstTailwind;
|