@windi-ui/core 0.7.1 → 0.8.0-beta.1

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,198 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/windi-ui/windi-ui/main/docs/public/logo-lockup.svg" alt="WindiUI" width="292">
3
+ </p>
4
+
5
+ # WindiUI
6
+
7
+ 🚧 under development 🚧
8
+
9
+ WindiUI is a modern, modular, and customizable UI component library designed to work seamlessly with Tailwind CSS. It provides developers with a set of reusable components and utilities to build beautiful and consistent user interfaces efficiently.
10
+
11
+ ## Features
12
+
13
+ - **Core Components**: A collection of essential UI components such as buttons, badges, and cards.
14
+ - **Tailwind Integration**: Utilities and themes tailored for Tailwind CSS.
15
+ - **Customizable**: Easily extend and modify components to fit your design system.
16
+ - **Extensible**: Build your own components and variants with advanced utilities.
17
+ - **Dark mode**: Automatically detect your dark mode config and apply appropriate style.
18
+
19
+ ## Getting Started
20
+
21
+ ### Prerequisites
22
+
23
+ - Node.js (v22 or higher)
24
+ - Tailwind v3/v4
25
+
26
+ ### Installation
27
+
28
+ ```bash
29
+ npm install -D @windi-ui/tailwind
30
+ ```
31
+
32
+ On Tailwind v4, load it from your stylesheet:
33
+
34
+ ```css
35
+ @import "tailwindcss";
36
+ @plugin "@windi-ui/tailwind";
37
+ ```
38
+
39
+ Options go in the `@plugin` block, in a `windiui.config.ts` config file that exports them with `defineConfig`, or in
40
+ a `windiui.plugin.ts` plugin module that exports `windiui({ ... })` and is loaded with `@plugin "./windiui.plugin.ts"`;
41
+ see [Installation](https://windi-ui.github.io/windi-ui/guide/installation) and [Config file and plugin module](https://windi-ui.github.io/windi-ui/reference/config-file).
42
+
43
+ On Tailwind v3, add the plugin to your `tailwind.config.ts` / `tailwind.config.js` file:
44
+
45
+ ```ts
46
+ import type { Config } from 'tailwindcss';
47
+ import windiui from '@windi-ui/tailwind';
48
+
49
+ export default {
50
+ // ...
51
+ plugins: [
52
+ windiui()
53
+ ],
54
+ } satisfies Config;
55
+ ```
56
+
57
+ ### Usage
58
+
59
+ #### Colors
60
+
61
+ WindiUI automatically detect all the colors in your theme and make them available to be used with components and utility classes.
62
+
63
+ First you choose the color you want with `c-*` (e.g. `c-blue`, ...), then apply it with Tailwind class (e.g. `bg-c-800`, ...)
64
+
65
+ ```html
66
+ <div class="c-blue bg-c-800/50 text-c-300 border border-c-500 p-5">Hello World</div>
67
+ ```
68
+
69
+ #### Variants
70
+
71
+ Make your component more flexible by styling it with variant utilities classes, use (`bg-v`, `text-v`, `border-v`, ...) to apply the colors, then use `v-*` to change the style, WindiUI has the following built-in variants styles: `v-default`, `v-solid`, `v-outline`, `v-light`.
72
+
73
+ ```html
74
+ <span class="inline-block c-red v-solid bg-v-soft/60 text-v border border-v py-1 px-2 rounded">Test</span>
75
+ ```
76
+
77
+ #### Components
78
+
79
+ WindiUI comes with a few built-in components (e.g. `btn`, `badge`, ... more to come) that can be styled with `c-*`, `v-*` utilities, some components also support `s-*` utility to control its size.
80
+
81
+ ```html
82
+ <button class="btn v-light c-blue s-lg">
83
+ Primary
84
+ <span class="badge v-solid c-red leading-none rounded-full absolute top-0 start-full -translate-1/2">32</span>
85
+ </button>
86
+ ```
87
+
88
+ You can find more code examples in the [playground](https://github.com/windi-ui/windi-ui/blob/main/playground/vue-tailwindv4/src/App.vue).
89
+
90
+ #### Class names built at runtime
91
+
92
+ Tailwind only emits the classes it finds in your source. A class built at runtime, such as `c-${color}` from a
93
+ component prop, has to be safelisted.
94
+
95
+ On Tailwind v4, add one line to the stylesheet. `safelistSource()` returns the string for your config:
96
+
97
+ ```css
98
+ @source inline("{c-{accent,accent-accent,accent-blue,accent-default,accent-red,blue,default,red},v-{default,light,outline,solid},s-{default,lg,sm,xl,xs}}");
99
+ ```
100
+
101
+ ```ts
102
+ import { safelistSource } from '@windi-ui/tailwind';
103
+
104
+ safelistSource({}, { palettes: ['blue', 'red'] }); // the string above; without `palettes`, every palette of the default theme
105
+ ```
106
+
107
+ On Tailwind v3, `windiui({ safelist: true })` emits every `c-*`, `v-*` and `s-*` class.
108
+
109
+ See [the `safelist` option](https://windi-ui.github.io/windi-ui/reference/options#safelist) for the details.
110
+
111
+ ## Upgrading from 0.7
112
+
113
+ See [Changes in 0.8](https://windi-ui.github.io/windi-ui/changes-0.8). The one thing to check: 0.8 no longer sets the default variant on every
114
+ element with a `*` rule (the new `variantScope` option, default `'element'`). `btn`, `badge` and the `bg-v`,
115
+ `text-v`, `border-v` utilities look the same, but your own CSS that reads a variant variable directly, such as
116
+ `background: var(--wui-v-bg)`, on an element without a `v-*` class no longer gets a value. Either set
117
+ `windiui({ variantScope: 'universal' })` to keep the 0.7 output, or give the rule a variant with
118
+ `@apply v-default v-scope`. A rule that uses `@apply v-*` should also apply `v-scope`, so its children do not
119
+ inherit the variant.
120
+
121
+ ## Documentation
122
+
123
+ The full guide and reference are on [the docs site](https://windi-ui.github.io/windi-ui/guide/introduction), a VitePress site
124
+ in `docs/` with live examples.
125
+ Run it locally with `pnpm build && pnpm docs:dev`.
126
+
127
+ ## Contributing
128
+
129
+ Contributions are welcome! Please submit issues or pull requests.
130
+
131
+ 1. Clone the repository:
132
+
133
+ ```bash
134
+ git clone https://github.com/windi-ui/windi-ui.git
135
+ cd windi-ui
136
+ ```
137
+
138
+ 2. Install dependencies:
139
+
140
+ ```bash
141
+ pnpm install
142
+ ```
143
+
144
+ 3. Start the development server for the playground:
145
+
146
+ ```bash
147
+ pnpm dev
148
+ # or for Tailwind v4
149
+ pnpm devv4
150
+ ```
151
+
152
+ The playgrounds use the built packages. To rebuild them on change, run `pnpm watch` in a second terminal.
153
+
154
+ ### Tests
155
+
156
+ ```bash
157
+ pnpm build # the tests load the built packages
158
+ pnpm test # run once
159
+ pnpm test -u # rewrite the snapshots after an intended change in the output
160
+ ```
161
+
162
+ The tests are in `test/` and run on Vitest.
163
+
164
+ - **Snapshots.** `test/__snapshots__/<fixture>/*.css` hold the CSS the plugin emits on each supported Tailwind:
165
+ `tw3` (3.4, through PostCSS), `tw4.1` (the oldest supported v4, pinned below 4.1.17, where `@variant dark` is
166
+ not expanded yet) and `tw4` (the current v4), both through Tailwind's `compile()`. Each is a package in
167
+ `test/fixtures/` that pins its Tailwind version.
168
+ A change in the output fails the test; if the change is intended, run `pnpm test -u` and commit the
169
+ snapshot diff with the code, so the review shows what changed for users.
170
+ - **Browser.** `test/browser.test.ts` checks what a snapshot cannot: how the CSS cascades and inherits.
171
+ It drives the Chrome or Edge already installed on the machine, and is skipped locally if there is neither.
172
+ - A test file works with one fixture only, because the helper that loads a fixture changes the working directory.
173
+
174
+ ### Project Structure
175
+
176
+ The repository is organized as a monorepo with the following packages:
177
+
178
+ #### Packages
179
+
180
+ - **`windiui-core`**: Contains the core components and utilities.
181
+ - **`windiui-tailwind`**: Tailwind CSS-specific utilities and themes.
182
+
183
+ #### Playgrounds
184
+
185
+ - **`vue-tailwind`**: A Vue 3 project showcasing WindiUI with Tailwind CSS v3.
186
+ - **`vue-tailwindv4`**: Another Vue 3 project demonstrating WindiUI with Tailwind CSS v4.
187
+
188
+ #### Tests
189
+
190
+ - **`test`**: The test harness, with one fixture package per supported Tailwind version in `test/fixtures`.
191
+
192
+ #### Docs
193
+
194
+ - **`docs`**: The VitePress documentation site (`pnpm docs:dev`, `pnpm docs:build`, `pnpm docs:preview`). It loads the built packages, so run `pnpm build` first.
195
+
196
+ ## License
197
+
198
+ 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 { _ as IComponent, g as ComponentBuilderContext, h as ComponentBuilder } from "./vars-BQT8iude.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-DKL2Gqrn.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";