@windi-ui/core 0.7.1 → 0.8.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 ADDED
@@ -0,0 +1,229 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/windi-ui/windi-ui/main/docs/public/logo-lockup-npm.svg" alt="WindiUI" width="306">
3
+ </p>
4
+
5
+ # WindiUI
6
+
7
+ 🚧 under development 🚧
8
+
9
+ WindiUI is a Tailwind CSS plugin that adds three axes to your classes: a color (`c-*`), a variant (`v-*`) and a size
10
+ (`s-*`). Each one is a class that sets CSS variables, so `btn c-blue v-solid s-lg` is a large, solid, blue button, and
11
+ the same `btn` takes every palette of your theme, in light and dark mode.
12
+
13
+ **[Documentation](https://windi-ui.github.io/windi-ui/guide/introduction)** ·
14
+ [Installation](https://windi-ui.github.io/windi-ui/guide/installation) ·
15
+ [Options](https://windi-ui.github.io/windi-ui/reference/options) ·
16
+ [Builder API](https://windi-ui.github.io/windi-ui/reference/builder) ·
17
+ [Changes in 0.8](https://windi-ui.github.io/windi-ui/changes-0.8)
18
+
19
+ ## Features
20
+
21
+ - **Three axes.** `c-*` picks one of your palettes, `v-*` a variant and `s-*` a size. They combine freely, and colors
22
+ and sizes inherit down the tree.
23
+ - **Calibrated variants.** `default`, `solid`, `outline` and `light` pick shades of the 11-shade palette for the
24
+ background, border and text, with soft, muted and accent levels, a hover state and dark values. A variant can use
25
+ other shades for some colors, such as a darker `solid` yellow.
26
+ - **Presets.** `nuxt-ui` adds `soft`, `subtle`, `ghost` and `link`, with text that passes a contrast of 4.5:1.
27
+ - **Components and utilities.** `btn`, `badge`, `bg-v`, `text-v`, `border-v`, and `apply-v` for your own CSS.
28
+ - **Builder API.** Add, replace, change or remove colors, variants, sizes and components.
29
+ - **Runtime palettes.** A color given by CSS variables follows a theme set at runtime.
30
+ - **Dark mode.** Follows the dark variant of your Tailwind setup, with nothing to configure.
31
+ - **Tailwind v3 and v4**, with the same class names.
32
+
33
+ ## Getting Started
34
+
35
+ ### Prerequisites
36
+
37
+ - Node.js 22 or higher, or 22.12 or higher to load a
38
+ [config file](https://windi-ui.github.io/windi-ui/reference/config-file). The tests run on Node.js 26.
39
+ - Tailwind CSS v3.3 or higher, or v4. The tests run on Tailwind CSS 3.4, 4.1.16 and the current 4.3.
40
+
41
+ ### Installation
42
+
43
+ ```bash
44
+ npm install -D @windi-ui/tailwind
45
+ ```
46
+
47
+ On Tailwind v4, load it from your stylesheet:
48
+
49
+ ```css
50
+ @import "tailwindcss";
51
+ @plugin "@windi-ui/tailwind";
52
+ ```
53
+
54
+ On Tailwind v3, add it to the plugins of your Tailwind config:
55
+
56
+ ```ts
57
+ import type { Config } from 'tailwindcss';
58
+ import windiui from '@windi-ui/tailwind';
59
+
60
+ export default {
61
+ content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
62
+ plugins: [windiui()],
63
+ } satisfies Config;
64
+ ```
65
+
66
+ Options go in the `@plugin` block, in a `windiui.config.ts` config file, or in a plugin module; see
67
+ [Installation](https://windi-ui.github.io/windi-ui/guide/installation) and
68
+ [Options](https://windi-ui.github.io/windi-ui/reference/options).
69
+
70
+ ### Usage
71
+
72
+ ```html
73
+ <button class="btn c-blue v-solid">Save</button>
74
+ <button class="btn c-red v-outline s-sm">Delete</button>
75
+ <button class="btn c-blue v-light s-lg">Inbox <span class="badge c-red v-solid">3</span></button>
76
+ <div class="c-green v-light bg-v text-v border border-v-muted rounded p-4">A box painted by its variant</div>
77
+ <div class="c-amber bg-c-100 text-c-800 p-4">Shades of the current color</div>
78
+ ```
79
+
80
+ A plugin module configures WindiUI with the builder API. This one adds the `nuxt-ui` variants, gives `solid` a darker
81
+ background with yellow, and adds a `c-primary` color whose shades are CSS variables set at runtime:
82
+
83
+ ```ts
84
+ // windiui.plugin.ts
85
+ import windiui from '@windi-ui/tailwind';
86
+
87
+ export default windiui({
88
+ presets: ['nuxt-ui'],
89
+ build: (builder) => builder
90
+ .overrideVariant('solid', 'yellow', { bg: '700', pseudos: { ':hover': { bg: '800' } } })
91
+ .addColor('primary', { vars: '--ui-color-primary' }),
92
+ });
93
+ ```
94
+
95
+ ```css
96
+ @import "tailwindcss";
97
+ @plugin "./windiui.plugin.ts";
98
+ ```
99
+
100
+ ```html
101
+ <button class="btn c-yellow v-solid">Solid yellow, on shade 700</button>
102
+ <button class="btn c-primary v-soft">Soft, in the runtime color</button>
103
+ ```
104
+
105
+ The [guide](https://windi-ui.github.io/windi-ui/guide/introduction) covers each part, with live examples. The
106
+ [playground](https://github.com/windi-ui/windi-ui/blob/main/playground/vue-tailwindv4/src/App.vue) has more.
107
+
108
+ #### Variants and sizes in your own CSS
109
+
110
+ `apply-v` paints the background, border and text from the current variant, at rest and on hover, as `btn` does. A
111
+ list in brackets chooses the properties and the states. The `s-*` classes set size variables that a control of your
112
+ own can read:
113
+
114
+ ```css
115
+ @import "tailwindcss";
116
+ @plugin "@windi-ui/tailwind";
117
+
118
+ .card-action { @apply apply-v; } /* bg, border, text + :hover */
119
+ .tab { @apply apply-v-[bg,text,hover,focus-visible]; } /* chosen properties and states */
120
+ .my-input { /* as tall as a btn of the same size */
121
+ padding: calc(var(--wui-s-spacing-1\.5) - 1px) calc(var(--wui-s-spacing-3) - 1px);
122
+ border: 1px solid;
123
+ font-size: var(--wui-s-text);
124
+ line-height: var(--wui-s-line-height);
125
+ }
126
+ ```
127
+
128
+ | Size variable | Meaning |
129
+ | --- | --- |
130
+ | `--wui-s-spacing-1`, `-1\.5`, `-2`, `-3`, `-4` | Spacing slots |
131
+ | `--wui-s-text`, `--wui-s-line-height` | Font size and line height |
132
+ | `--wui-s-<key>` | A key of your own on a size, such as `height` for an app that wants a fixed control height |
133
+
134
+ The `variantUtilities` option adds color utilities painted from a variant, such as `bg-yellow` with the `solid`
135
+ background of yellow, overrides and dark values included. See
136
+ [Utilities](https://windi-ui.github.io/windi-ui/guide/utilities) and
137
+ [Sizes](https://windi-ui.github.io/windi-ui/guide/sizes).
138
+
139
+ ## Upgrading from 0.7
140
+
141
+ See [Changes in 0.8](https://windi-ui.github.io/windi-ui/changes-0.8#upgrading-from-0-7). The one thing to check: 0.8
142
+ no longer sets the default variant on every element with a `*` rule (the new `variantScope` option, default
143
+ `'element'`). `btn`, `badge` and the `bg-v`, `text-v`, `border-v` utilities look the same, but your own CSS that
144
+ reads a variant variable directly, such as `background: var(--wui-v-bg)`, on an element without a `v-*` class no
145
+ longer gets a value. Either set `windiui({ variantScope: 'universal' })` to keep the 0.7 output, or give the rule a
146
+ variant with `@apply v-default v-scope`. A rule that uses `@apply v-*` should also apply `v-scope`, so its children
147
+ do not inherit the variant.
148
+
149
+ ## Documentation
150
+
151
+ The full guide and reference are on [the docs site](https://windi-ui.github.io/windi-ui/guide/introduction), a VitePress site
152
+ in `docs/` with live examples.
153
+ Run it locally with `pnpm build && pnpm docs:dev`.
154
+
155
+ ## Contributing
156
+
157
+ Contributions are welcome! Please submit issues or pull requests.
158
+
159
+ 1. Clone the repository:
160
+
161
+ ```bash
162
+ git clone https://github.com/windi-ui/windi-ui.git
163
+ cd windi-ui
164
+ ```
165
+
166
+ 2. Install dependencies:
167
+
168
+ ```bash
169
+ pnpm install
170
+ ```
171
+
172
+ 3. Start the development server for the playground:
173
+
174
+ ```bash
175
+ pnpm dev
176
+ # or for Tailwind v4
177
+ pnpm devv4
178
+ ```
179
+
180
+ The playgrounds use the built packages. To rebuild them on change, run `pnpm watch` in a second terminal.
181
+
182
+ ### Tests
183
+
184
+ ```bash
185
+ pnpm build # the tests load the built packages
186
+ pnpm test # run once
187
+ pnpm test -u # rewrite the snapshots after an intended change in the output
188
+ ```
189
+
190
+ The tests are in `test/` and run on Vitest.
191
+
192
+ - **Snapshots.** `test/__snapshots__/<fixture>/*.css` hold the CSS the plugin emits on each supported Tailwind:
193
+ `tw3` (3.4, through PostCSS), `tw4.1` (the oldest supported v4, pinned below 4.1.17, where `@variant dark` is
194
+ not expanded yet) and `tw4` (the current v4), both through Tailwind's `compile()`. Each is a package in
195
+ `test/fixtures/` that pins its Tailwind version.
196
+ A change in the output fails the test; if the change is intended, run `pnpm test -u` and commit the
197
+ snapshot diff with the code, so the review shows what changed for users.
198
+ - **Browser.** `test/browser.test.ts` checks what a snapshot cannot: how the CSS cascades and inherits.
199
+ It drives the Chrome or Edge already installed on the machine, and is skipped locally if there is neither.
200
+ - **README.** `test/readme.ts` compiles every TypeScript sample of this file on each fixture and every CSS sample
201
+ on the Tailwind v4 ones, and checks that the classes of its HTML samples exist. Keep the samples compilable when
202
+ you change them.
203
+ - A test file works with one fixture only, because the helper that loads a fixture changes the working directory.
204
+
205
+ ### Project Structure
206
+
207
+ The repository is organized as a monorepo with the following packages:
208
+
209
+ #### Packages
210
+
211
+ - **`windiui-core`**: Contains the core components and utilities.
212
+ - **`windiui-tailwind`**: Tailwind CSS-specific utilities and themes.
213
+
214
+ #### Playgrounds
215
+
216
+ - **`vue-tailwind`**: A Vue 3 project showcasing WindiUI with Tailwind CSS v3.
217
+ - **`vue-tailwindv4`**: Another Vue 3 project demonstrating WindiUI with Tailwind CSS v4.
218
+
219
+ #### Tests
220
+
221
+ - **`test`**: The test harness, with one fixture package per supported Tailwind version in `test/fixtures`.
222
+
223
+ #### Docs
224
+
225
+ - **`docs`**: The VitePress documentation site (`pnpm docs:dev`, `pnpm docs:build`, `pnpm docs:preview`). It loads the built packages, so run `pnpm build` first.
226
+
227
+ ## License
228
+
229
+ This project is licensed under the MIT License. See the [LICENSE](https://github.com/windi-ui/windi-ui/blob/main/LICENSE) file for details.
@@ -0,0 +1,54 @@
1
+ // src/components/common.ts
2
+ function defineComponent(component) {
3
+ return typeof component === "function" ? component : () => component;
4
+ }
5
+ // src/components/button/index.ts
6
+ var button_default = defineComponent(({ vars }) => {
7
+ return {
8
+ name: "btn",
9
+ applyVariant: true,
10
+ applyVariantPseudos: [":hover"],
11
+ style: {
12
+ position: "relative",
13
+ display: "inline-flex",
14
+ alignItems: "baseline",
15
+ justifyContent: "center",
16
+ padding: `calc(${vars.size("spacing-1.5")} - 1px) calc(${vars.size("spacing-3")} - 1px)`,
17
+ borderRadius: "0.375rem",
18
+ borderWidth: "1px",
19
+ fontSize: vars.size("text"),
20
+ lineHeight: vars.size("line-height"),
21
+ fontWeight: "600",
22
+ textDecoration: "none",
23
+ verticalAlign: "middle",
24
+ userSelect: "none"
25
+ },
26
+ pseudos: {
27
+ ":hover": {},
28
+ ":disabled": {}
29
+ }
30
+ };
31
+ });
32
+ // src/components/badge/index.ts
33
+ var badge_default = defineComponent(({ vars, colors }) => {
34
+ return {
35
+ name: "badge",
36
+ applyVariant: ["text", "bg"],
37
+ style: {
38
+ display: "inline-flex",
39
+ alignItems: "center",
40
+ padding: "calc(1em / 3) calc(2em / 3)",
41
+ borderRadius: "0.375rem",
42
+ outlineStyle: "solid",
43
+ outlineWidth: "1px",
44
+ outlineOffset: "-1px",
45
+ outlineColor: colors.toValue(vars.variant("border"), .65),
46
+ fontSize: "0.75em",
47
+ fontWeight: "500",
48
+ lineHeight: "calc(1 / .75)",
49
+ whiteSpace: "nowrap",
50
+ verticalAlign: "baseline"
51
+ }
52
+ };
53
+ });
54
+ export { button_default as n, defineComponent as r, badge_default as t };
@@ -0,0 +1,71 @@
1
+ // src/components/common.ts
2
+ function defineComponent(component) {
3
+ return typeof component === "function" ? component : () => component;
4
+ }
5
+ // src/components/button/index.ts
6
+ var button_default = defineComponent(({ vars }) => {
7
+ return {
8
+ name: "btn",
9
+ applyVariant: true,
10
+ applyVariantPseudos: [":hover"],
11
+ style: {
12
+ position: "relative",
13
+ display: "inline-flex",
14
+ alignItems: "baseline",
15
+ justifyContent: "center",
16
+ padding: `calc(${vars.size("spacing-1.5")} - 1px) calc(${vars.size("spacing-3")} - 1px)`,
17
+ borderRadius: "0.375rem",
18
+ borderWidth: "1px",
19
+ fontSize: vars.size("text"),
20
+ lineHeight: vars.size("line-height"),
21
+ fontWeight: "600",
22
+ textDecoration: "none",
23
+ verticalAlign: "middle",
24
+ userSelect: "none"
25
+ },
26
+ pseudos: {
27
+ ":hover": {},
28
+ ":disabled": {}
29
+ }
30
+ };
31
+ });
32
+ // src/components/badge/index.ts
33
+ var badge_default = defineComponent(({ vars, colors }) => {
34
+ return {
35
+ name: "badge",
36
+ applyVariant: ["text", "bg"],
37
+ style: {
38
+ display: "inline-flex",
39
+ alignItems: "center",
40
+ padding: "calc(1em / 3) calc(2em / 3)",
41
+ borderRadius: "0.375rem",
42
+ outlineStyle: "solid",
43
+ outlineWidth: "1px",
44
+ outlineOffset: "-1px",
45
+ outlineColor: colors.toValue(vars.variant("border"), .65),
46
+ fontSize: "0.75em",
47
+ fontWeight: "500",
48
+ lineHeight: "calc(1 / .75)",
49
+ whiteSpace: "nowrap",
50
+ verticalAlign: "baseline"
51
+ }
52
+ };
53
+ });
54
+ Object.defineProperty(exports, "badge_default", {
55
+ enumerable: true,
56
+ get: function() {
57
+ return badge_default;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "button_default", {
61
+ enumerable: true,
62
+ get: function() {
63
+ return button_default;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "defineComponent", {
67
+ enumerable: true,
68
+ get: function() {
69
+ return defineComponent;
70
+ }
71
+ });
@@ -1,58 +1,5 @@
1
- 'use strict';
2
-
3
- function defineComponent(component) {
4
- return typeof component === "function" ? component : () => component;
5
- }
6
-
7
- const button = defineComponent(({ vars }) => {
8
- return {
9
- name: "btn",
10
- applyVariant: true,
11
- applyVariantPseudos: [":hover"],
12
- style: {
13
- position: "relative",
14
- display: "inline-flex",
15
- alignItems: "baseline",
16
- justifyContent: "center",
17
- padding: `calc(${vars.size("spacing-1.5")} - 1px) calc(${vars.size("spacing-3")} - 1px)`,
18
- borderRadius: "0.375rem",
19
- borderWidth: "1px",
20
- fontSize: vars.size("text"),
21
- lineHeight: vars.size("line-height"),
22
- fontWeight: "600",
23
- textDecoration: "none",
24
- verticalAlign: "middle",
25
- userSelect: "none"
26
- },
27
- pseudos: {
28
- ":hover": {},
29
- ":disabled": {}
30
- }
31
- };
32
- });
33
-
34
- const badge = defineComponent(({ vars, colors }) => {
35
- return {
36
- name: "badge",
37
- applyVariant: ["text", "bg"],
38
- style: {
39
- display: "inline-flex",
40
- alignItems: "center",
41
- padding: "calc(1em / 3) calc(2em / 3)",
42
- borderRadius: "0.375rem",
43
- outlineStyle: "solid",
44
- outlineWidth: "1px",
45
- outlineOffset: "-1px",
46
- outlineColor: colors.toValue(vars.variant("border"), 0.65),
47
- fontSize: "0.75em",
48
- fontWeight: "500",
49
- lineHeight: "calc(1 / .75)",
50
- whiteSpace: "nowrap",
51
- verticalAlign: "baseline"
52
- }
53
- };
54
- });
55
-
56
- exports.badge = badge;
57
- exports.button = button;
58
- exports.defineComponent = defineComponent;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_badge = require("./badge-DP_7SF0i.cjs");
3
+ exports.badge = require_badge.badge_default;
4
+ exports.button = require_badge.button_default;
5
+ exports.defineComponent = require_badge.defineComponent;
@@ -1,11 +1,5 @@
1
- import { I as IComponent, j as ComponentBuilder } from './shared/core.BBBw5V2R.cjs';
2
- export { C as ComponentBuilderContext } from './shared/core.BBBw5V2R.cjs';
3
- import 'csstype';
4
-
5
- declare function defineComponent(component: IComponent | ComponentBuilder): ComponentBuilder;
6
-
1
+ import { C as ComponentBuilderContext, S as ComponentBuilder, w as IComponent } from "./vars-D-T56h9H.cjs";
2
+ export declare function defineComponent(component: IComponent | ComponentBuilder): ComponentBuilder;
7
3
  declare const _default$1: ComponentBuilder;
8
-
9
4
  declare const _default: ComponentBuilder;
10
-
11
- export { ComponentBuilder, IComponent, _default as badge, _default$1 as button, defineComponent };
5
+ export { ComponentBuilder, ComponentBuilderContext, IComponent, _default as badge, _default$1 as button };
@@ -1,11 +1,5 @@
1
- import { I as IComponent, j as ComponentBuilder } from './shared/core.BBBw5V2R.mjs';
2
- export { C as ComponentBuilderContext } from './shared/core.BBBw5V2R.mjs';
3
- import 'csstype';
4
-
5
- declare function defineComponent(component: IComponent | ComponentBuilder): ComponentBuilder;
6
-
1
+ import { n as ComponentBuilderContext, r as IComponent, t as ComponentBuilder } from "./types-7pMUZGLb.mjs";
2
+ export declare function defineComponent(component: IComponent | ComponentBuilder): ComponentBuilder;
7
3
  declare const _default$1: ComponentBuilder;
8
-
9
4
  declare const _default: ComponentBuilder;
10
-
11
- export { ComponentBuilder, IComponent, _default as badge, _default$1 as button, defineComponent };
5
+ export { ComponentBuilder, ComponentBuilderContext, IComponent, _default as badge, _default$1 as button };
@@ -1,54 +1 @@
1
- function defineComponent(component) {
2
- return typeof component === "function" ? component : () => component;
3
- }
4
-
5
- const button = defineComponent(({ vars }) => {
6
- return {
7
- name: "btn",
8
- applyVariant: true,
9
- applyVariantPseudos: [":hover"],
10
- style: {
11
- position: "relative",
12
- display: "inline-flex",
13
- alignItems: "baseline",
14
- justifyContent: "center",
15
- padding: `calc(${vars.size("spacing-1.5")} - 1px) calc(${vars.size("spacing-3")} - 1px)`,
16
- borderRadius: "0.375rem",
17
- borderWidth: "1px",
18
- fontSize: vars.size("text"),
19
- lineHeight: vars.size("line-height"),
20
- fontWeight: "600",
21
- textDecoration: "none",
22
- verticalAlign: "middle",
23
- userSelect: "none"
24
- },
25
- pseudos: {
26
- ":hover": {},
27
- ":disabled": {}
28
- }
29
- };
30
- });
31
-
32
- const badge = defineComponent(({ vars, colors }) => {
33
- return {
34
- name: "badge",
35
- applyVariant: ["text", "bg"],
36
- style: {
37
- display: "inline-flex",
38
- alignItems: "center",
39
- padding: "calc(1em / 3) calc(2em / 3)",
40
- borderRadius: "0.375rem",
41
- outlineStyle: "solid",
42
- outlineWidth: "1px",
43
- outlineOffset: "-1px",
44
- outlineColor: colors.toValue(vars.variant("border"), 0.65),
45
- fontSize: "0.75em",
46
- fontWeight: "500",
47
- lineHeight: "calc(1 / .75)",
48
- whiteSpace: "nowrap",
49
- verticalAlign: "baseline"
50
- }
51
- };
52
- });
53
-
54
- export { badge, button, defineComponent };
1
+ export { t as badge, n as button, r as defineComponent } from "./badge-B-3Z5qKd.mjs";