stillwind 0.12.0 → 0.14.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/CHANGELOG.md +76 -0
- package/README.md +1 -1
- package/css/builtin-utilities/tw-borders.css +59 -59
- package/css/builtin-utilities/tw-effects.css +53 -53
- package/css/builtin-utilities/tw-typography.css +13 -13
- package/dist/class-object-C87DR3v2.js +6 -0
- package/dist/class-object-C87DR3v2.js.map +1 -0
- package/dist/class-object-CR0QHoF9.d.ts +10 -0
- package/dist/{class-string-DQmH4PZX.d.ts → class-string-BlClX8JK.d.ts} +2 -2
- package/dist/class-string-CiNTVHYm.js +6 -0
- package/dist/{class-string-CrQnTRvI.js.map → class-string-CiNTVHYm.js.map} +1 -1
- package/dist/{formats-Ctf2WFc-.js → formats-DP9B9SG6.js} +228 -113
- package/dist/formats-DP9B9SG6.js.map +1 -0
- package/dist/{formats-aeLCNAXl.d.ts → formats-NBNjMP5R.d.ts} +34 -12
- package/dist/frameworks/alpine.d.ts +5 -3
- package/dist/frameworks/alpine.js +3 -1
- package/dist/frameworks/alpine.js.map +1 -1
- package/dist/frameworks/astro.d.ts +3 -3
- package/dist/frameworks/astro.js +1 -1
- package/dist/frameworks/lit.d.ts +5 -3
- package/dist/frameworks/lit.js +3 -1
- package/dist/frameworks/lit.js.map +1 -1
- package/dist/frameworks/preact.d.ts +3 -3
- package/dist/frameworks/preact.js +1 -1
- package/dist/frameworks/qwik.d.ts +3 -3
- package/dist/frameworks/qwik.js +1 -1
- package/dist/frameworks/react.d.ts +2 -2
- package/dist/frameworks/react.js +1 -1
- package/dist/frameworks/solid.d.ts +3 -3
- package/dist/frameworks/solid.js +1 -1
- package/dist/frameworks/svelte.d.ts +3 -3
- package/dist/frameworks/svelte.js +1 -1
- package/dist/frameworks/vanilla.d.ts +5 -3
- package/dist/frameworks/vanilla.js +6 -1
- package/dist/frameworks/vanilla.js.map +1 -0
- package/dist/frameworks/vue.d.ts +3 -3
- package/dist/frameworks/vue.js +1 -1
- package/dist/{index-uw1R9t_P.d.ts → index-DpaDcczW.d.ts} +150 -50
- package/dist/macro/index.d.ts +2 -2
- package/dist/macro/index.js +1 -1
- package/dist/runtime/development.d.ts +16 -8
- package/dist/runtime/development.js +57 -21
- package/dist/runtime/development.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -2
- package/dist/runtime/index.js +1 -1
- package/dist/{style-Bzuux32Y.js → style-dMBm8aX_.js} +6 -3
- package/dist/style-dMBm8aX_.js.map +1 -0
- package/docs/at-rules/apply.md +1 -1
- package/docs/at-rules/custom-variant.md +1 -1
- package/docs/at-rules/slot.md +1 -1
- package/docs/at-rules/stillwind-property.md +1 -1
- package/docs/at-rules/stillwind-registry.md +7 -7
- package/docs/at-rules/stillwind-require-properties.md +1 -1
- package/docs/at-rules/stillwind-undef-arbitrary-property.md +1 -1
- package/docs/at-rules/stillwind-undef-utility.md +1 -1
- package/docs/at-rules/stillwind-undef-variant.md +1 -1
- package/docs/at-rules/theme.md +5 -5
- package/docs/at-rules/utility.md +43 -4
- package/docs/at-rules/variant.md +1 -1
- package/docs/concepts/css-ordering.md +47 -7
- package/docs/concepts/how-styles-compile.md +8 -8
- package/docs/errors/SW10006.md +34 -0
- package/docs/errors/SW11001.md +4 -2
- package/docs/errors/index.md +1 -1
- package/docs/guides/migrating-from-tailwind.md +52 -9
- package/docs/guides/reusable-styles.md +2 -2
- package/docs/guides/style.md +1 -4
- package/docs/integrations.md +20 -1
- package/docs/lints/ambiguous-style-base-order.md +3 -1
- package/docs/lints/conflicting-provider-properties.md +3 -0
- package/docs/lints/conflicting-utilities.md +9 -0
- package/docs/lints/cyclic-style-order.md +68 -0
- package/docs/lints/index.md +14 -10
- package/docs/lints/interfering-imported-style-base.md +13 -22
- package/docs/lints/{invalid-cva-config.md → invalid-recipe-config.md} +8 -8
- package/docs/lints/{invalid-cva-input.md → invalid-recipe-input.md} +9 -9
- package/docs/lints/multiple-style-forwards.md +59 -0
- package/docs/lints/partial-utility-override.md +77 -0
- package/docs/lints/utility-class-selector.md +72 -0
- package/docs/llms.txt +8 -4
- package/docs/macros/index.md +1 -1
- package/docs/macros/recipe.md +246 -0
- package/docs/macros/style.md +62 -0
- package/docs/macros/when.md +1 -1
- package/package.json +7 -7
- package/skills/stillwind/SKILL.md +1 -1
- package/dist/class-object-CXvJOi2z.d.ts +0 -9
- package/dist/class-object-CzD1oMD_.js +0 -6
- package/dist/class-object-CzD1oMD_.js.map +0 -1
- package/dist/class-string-CrQnTRvI.js +0 -6
- package/dist/formats-Ctf2WFc-.js.map +0 -1
- package/dist/style-Bzuux32Y.js.map +0 -1
- package/docs/errors/SW11002.md +0 -65
- package/docs/macros/cva.md +0 -155
|
@@ -29,13 +29,13 @@ the base's CSS first.
|
|
|
29
29
|
Read the following table from top to bottom. Stillwind orders files first, then
|
|
30
30
|
calls within each file, then the rules that each call produces:
|
|
31
31
|
|
|
32
|
-
| Step | What Stillwind orders | Which CSS comes first
|
|
33
|
-
| ---- | ----------------------------------- |
|
|
34
|
-
| 1 | Different files | A file that defines a base comes before a file that uses it in `style(base, ...)`.
|
|
35
|
-
| 2 | `style()` calls in one file | The base's CSS comes before CSS added by `style(base, ...)`. Other calls follow the order in which they appear in the file.
|
|
36
|
-
| 3 | JavaScript conditions in one call | CSS without a JavaScript condition comes first. CSS for conditions follows in the order the conditions are written. If conditions are nested, CSS for the outer condition comes before CSS for the inner one.
|
|
37
|
-
| 4 | CSS variants on one generated class | Rules without variants come first. The stylesheet sets the order of variants, such as `hover:` before `disabled:` or `sm:` before `md:` in the default stylesheet.
|
|
38
|
-
| 5 | Utilities with the same variants | By default, utilities follow the order of their definitions in the stylesheet, regardless of their order in `style()`.
|
|
32
|
+
| Step | What Stillwind orders | Which CSS comes first |
|
|
33
|
+
| ---- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
34
|
+
| 1 | Different files | A file that defines a base comes before a file that uses it in `style(base, ...)`. A file that declares an imported value, such as a component, comes before the file that imports it. Other files use a stable order based on their paths. |
|
|
35
|
+
| 2 | `style()` calls in one file | The base's CSS comes before CSS added by `style(base, ...)`. Other calls follow the order in which they appear in the file. |
|
|
36
|
+
| 3 | JavaScript conditions in one call | CSS without a JavaScript condition comes first. CSS for conditions follows in the order the conditions are written. If conditions are nested, CSS for the outer condition comes before CSS for the inner one. |
|
|
37
|
+
| 4 | CSS variants on one generated class | Rules without variants come first. The stylesheet sets the order of variants, such as `hover:` before `disabled:` or `sm:` before `md:` in the default stylesheet. |
|
|
38
|
+
| 5 | Utilities with the same variants | By default, utilities follow the order of their definitions in the stylesheet, regardless of their order in `style()`. |
|
|
39
39
|
|
|
40
40
|
For example, the variant order in step 4 only applies to rules for the same
|
|
41
41
|
class. It does not move a rule ahead of CSS from an earlier file or call.
|
|
@@ -92,6 +92,46 @@ plain classes, and none of the declarations uses `!important`. The red rule wins
|
|
|
92
92
|
because it comes last. The same rule applies when you import `base` from another
|
|
93
93
|
file.
|
|
94
94
|
|
|
95
|
+
### Files that pass styles to components
|
|
96
|
+
|
|
97
|
+
When a file imports a value from another file and uses it, the file that
|
|
98
|
+
declares the value comes first. For a component, this lets the caller's
|
|
99
|
+
utilities win over the component's own utilities:
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
// src/App.tsx
|
|
103
|
+
import { Button } from "./components/ui/button";
|
|
104
|
+
|
|
105
|
+
<Button {...style("w-full")} />;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Here `src/components/ui/button.tsx` comes before `src/App.tsx`, although the
|
|
109
|
+
paths sort the other way. The import decides the order, so it does not matter
|
|
110
|
+
how the style reaches the component. The order is the same when the style is
|
|
111
|
+
stored in a variable first, or when it is passed to a child element that the
|
|
112
|
+
component renders, as with `asChild`.
|
|
113
|
+
|
|
114
|
+
Stillwind follows the imports that are read as values. It ignores type-only
|
|
115
|
+
imports, imports that the file does not use, and imports from packages. It
|
|
116
|
+
follows re-exports, such as an `index.ts` file that re-exports components, to
|
|
117
|
+
the file that declares the value. A namespace import, such as
|
|
118
|
+
`import * as ui from "./ui"`, orders the file after every file that `./ui`
|
|
119
|
+
re-exports. When the declaring file has no `style()` call, Stillwind follows
|
|
120
|
+
that file's imports instead. A file that imports `Wrapper`, which renders
|
|
121
|
+
`Button`, therefore comes after the file of `Button`. Imports in Vue, Svelte,
|
|
122
|
+
and Astro files work in the same way. Components that a framework imports
|
|
123
|
+
automatically, without an `import` declaration, do not order files.
|
|
124
|
+
|
|
125
|
+
This order only places CSS. The component still has to apply the props, for
|
|
126
|
+
example with [`style.forward()`](https://stillwind.dev/docs/macros/style#forward-props-to-a-components-element).
|
|
127
|
+
It does not add the component's CSS to a stylesheet that does not include the
|
|
128
|
+
component.
|
|
129
|
+
|
|
130
|
+
When two files import values from each other, directly or through other
|
|
131
|
+
files, both orders cannot hold. Stillwind keeps one of them. When the files
|
|
132
|
+
set the same property, [cyclic-style-order](https://stillwind.dev/docs/lints/cyclic-style-order)
|
|
133
|
+
reports the cycle.
|
|
134
|
+
|
|
95
135
|
### Within one call, conditional rules come last
|
|
96
136
|
|
|
97
137
|
In this call, the red utility has a JavaScript condition and the blue utility
|
|
@@ -97,14 +97,14 @@ custom property as an inline style.
|
|
|
97
97
|
The CSS for both classes is generated at build time. At runtime, the code only
|
|
98
98
|
chooses class names and sets property values.
|
|
99
99
|
|
|
100
|
-
| You write
|
|
101
|
-
|
|
|
102
|
-
| Static utilities and variants
|
|
103
|
-
| A condition, such as `active && "..."`
|
|
104
|
-
| A runtime custom property
|
|
105
|
-
| [`style.
|
|
106
|
-
| [`style.media()`](https://stillwind.dev/docs/macros/media)
|
|
107
|
-
| [`style.css()`](https://stillwind.dev/docs/macros/css)
|
|
100
|
+
| You write | JavaScript at runtime |
|
|
101
|
+
| --------------------------------------- | ------------------------------------------- |
|
|
102
|
+
| Static utilities and variants | A class name |
|
|
103
|
+
| A condition, such as `active && "..."` | A helper that joins class names |
|
|
104
|
+
| A runtime custom property | An inline `style` value |
|
|
105
|
+
| [`style.recipe()`](https://stillwind.dev/docs/macros/recipe) | A factory that selects compiled class names |
|
|
106
|
+
| [`style.media()`](https://stillwind.dev/docs/macros/media) | A string with the media query |
|
|
107
|
+
| [`style.css()`](https://stillwind.dev/docs/macros/css) | A CSS string that you place yourself |
|
|
108
108
|
|
|
109
109
|
Development builds import checked versions of the helpers from
|
|
110
110
|
`stillwind/runtime/development`. These versions report invalid values while you
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "SW10006: Unavailable style.forward()"
|
|
3
|
+
description: "style.forward() is used through an entrypoint that does not provide it."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SW10006: Unavailable style.forward()
|
|
7
|
+
|
|
8
|
+
This error occurs when the code calls `style.forward()` through the Lit,
|
|
9
|
+
Alpine, or vanilla entrypoint. These entrypoints have no component props to
|
|
10
|
+
forward, so they do not provide `style.forward()`.
|
|
11
|
+
|
|
12
|
+
## Reported
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { style } from "stillwind/vanilla";
|
|
16
|
+
|
|
17
|
+
export const props = (attributes: { class?: string }) => style("p-4", style.forward(attributes));
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
> SW10006: style.forward() is not available from `stillwind/vanilla`
|
|
21
|
+
|
|
22
|
+
## Fixed
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { style } from "stillwind/vanilla";
|
|
26
|
+
|
|
27
|
+
export const props = (attributes: { class?: string }) => style("p-4", { class: attributes.class });
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## How to fix
|
|
31
|
+
|
|
32
|
+
- Pass the received classes in a `class` field, as in `{ class: attributes.class }`.
|
|
33
|
+
A `class` field passes classes only. To set inline style values, use custom
|
|
34
|
+
properties such as `{ "--size": value }`.
|
package/docs/errors/SW11001.md
CHANGED
|
@@ -33,5 +33,7 @@ const second = style(base);
|
|
|
33
33
|
- If only one style extends the other, keep that dependency and remove the one
|
|
34
34
|
in the opposite direction.
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
Two modules that build styles on each other's bases compile when the styles
|
|
37
|
+
themselves do not form a cycle.
|
|
38
|
+
[cyclic-style-order](https://stillwind.dev/docs/lints/cyclic-style-order) reports such modules when
|
|
39
|
+
they set the same property.
|
package/docs/errors/index.md
CHANGED
|
@@ -36,8 +36,8 @@ The first digits of a code tell you what to do next:
|
|
|
36
36
|
- [SW10003](https://stillwind.dev/docs/errors/SW10003): Invalid Unicode string
|
|
37
37
|
- [SW10004](https://stillwind.dev/docs/errors/SW10004): Unconsumed macro use
|
|
38
38
|
- [SW10005](https://stillwind.dev/docs/errors/SW10005): Untransformed macro reference
|
|
39
|
+
- [SW10006](https://stillwind.dev/docs/errors/SW10006): Unavailable style.forward()
|
|
39
40
|
- [SW11001](https://stillwind.dev/docs/errors/SW11001): Style composition cycle
|
|
40
|
-
- [SW11002](https://stillwind.dev/docs/errors/SW11002): CSS module ordering cycle
|
|
41
41
|
- [SW11003](https://stillwind.dev/docs/errors/SW11003): Unavailable style base
|
|
42
42
|
- [SW12001](https://stillwind.dev/docs/errors/SW12001): Incompatible declaration assignment
|
|
43
43
|
- [SW12002](https://stillwind.dev/docs/errors/SW12002): Declaration identities unavailable
|
|
@@ -73,14 +73,15 @@ write a one-off codemod for your repository that converts them in one pass.
|
|
|
73
73
|
|
|
74
74
|
## Replace class helpers
|
|
75
75
|
|
|
76
|
-
[`style()`](https://stillwind.dev/docs/macros/style) and [`style.
|
|
76
|
+
[`style()`](https://stillwind.dev/docs/macros/style) and [`style.recipe()`](https://stillwind.dev/docs/macros/recipe) replace
|
|
77
77
|
the libraries that Tailwind projects use to build class strings:
|
|
78
78
|
|
|
79
|
-
| Library | Stillwind
|
|
80
|
-
| ------------------------------------------------------------------------------------------------- |
|
|
81
|
-
| [`clsx`](https://github.com/lukeed/clsx), [`classnames`](https://github.com/JedWatson/classnames) | `style()` with conditions
|
|
82
|
-
| [`tailwind-merge`](https://github.com/dcastil/tailwind-merge) | Compose a base with new utilities
|
|
83
|
-
| `cva` from [Class Variance Authority](https://cva.style/) | `style.
|
|
79
|
+
| Library | Stillwind |
|
|
80
|
+
| ------------------------------------------------------------------------------------------------- | -------------------------------------------- |
|
|
81
|
+
| [`clsx`](https://github.com/lukeed/clsx), [`classnames`](https://github.com/JedWatson/classnames) | `style()` with conditions |
|
|
82
|
+
| [`tailwind-merge`](https://github.com/dcastil/tailwind-merge) | Compose a base with new utilities |
|
|
83
|
+
| `cva` from [Class Variance Authority](https://cva.style/) | `style.recipe()` with the same configuration |
|
|
84
|
+
| `tv` from [tailwind-variants](https://www.tailwind-variants.org/) | `style.recipe()` with `slots` |
|
|
84
85
|
|
|
85
86
|
### clsx and classnames
|
|
86
87
|
|
|
@@ -110,15 +111,21 @@ competing declarations when the other cascade criteria, such as specificity
|
|
|
110
111
|
and importance, are equal. See [Override a style](https://stillwind.dev/docs/guides/style#override-a-style)
|
|
111
112
|
and [CSS ordering](https://stillwind.dev/docs/concepts/css-ordering).
|
|
112
113
|
|
|
114
|
+
`twMerge()` removes the overridden utility, but Stillwind keeps its CSS. When the
|
|
115
|
+
overriding utility sets fewer properties, the other properties keep their values.
|
|
116
|
+
For example, `text-[0.8rem]` over `text-sm` leaves the line height of `text-sm`.
|
|
117
|
+
[partial-utility-override](https://stillwind.dev/docs/lints/partial-utility-override) reports these
|
|
118
|
+
overrides in bases, conditions, and recipe options.
|
|
119
|
+
|
|
113
120
|
### cva
|
|
114
121
|
|
|
115
|
-
Replace `cva(` with `style.
|
|
122
|
+
Replace `cva(` with `style.recipe(`, and import `VariantProps` from your framework's
|
|
116
123
|
entrypoint:
|
|
117
124
|
|
|
118
125
|
```tsx
|
|
119
126
|
import { style, type VariantProps } from "stillwind/react";
|
|
120
127
|
|
|
121
|
-
const button = style.
|
|
128
|
+
const button = style.recipe("rounded-md px-4 py-2", {
|
|
122
129
|
variants: {
|
|
123
130
|
tone: {
|
|
124
131
|
neutral: "bg-gray-100",
|
|
@@ -138,9 +145,39 @@ export function Button({ tone }: VariantProps<typeof button>) {
|
|
|
138
145
|
`variants`, `defaultVariants`, and `compoundVariants` work as in
|
|
139
146
|
class-variance-authority. Write each option value as a plain utility string,
|
|
140
147
|
without `&&` or a ternary. The props that the factory returns cannot be passed
|
|
141
|
-
to `style()` as a base. The [`style.
|
|
148
|
+
to `style()` as a base. The [`style.recipe()` reference](https://stillwind.dev/docs/macros/recipe) lists
|
|
142
149
|
the other differences.
|
|
143
150
|
|
|
151
|
+
### tailwind-variants
|
|
152
|
+
|
|
153
|
+
Replace `tv({ base, ... })` with `style.recipe(base, { ... })`. Move `base` to the
|
|
154
|
+
first argument, and keep `slots`, `variants`, `defaultVariants`,
|
|
155
|
+
`compoundVariants`, and `compoundSlots`. Each slot function returns props
|
|
156
|
+
instead of a class string, so spread it onto the element:
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
import { style } from "stillwind/react";
|
|
160
|
+
|
|
161
|
+
const card = style.recipe("flex gap-2", {
|
|
162
|
+
slots: {
|
|
163
|
+
icon: "size-4",
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
export function Card() {
|
|
168
|
+
const { base, icon } = card();
|
|
169
|
+
return (
|
|
170
|
+
<div {...base()}>
|
|
171
|
+
<span {...icon()} />
|
|
172
|
+
</div>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`extend` and the `twMerge` options are not supported. Utilities do not need a
|
|
178
|
+
runtime merge, because the compiler's CSS order decides which declaration wins.
|
|
179
|
+
See [Slots](https://stillwind.dev/docs/macros/recipe#slots).
|
|
180
|
+
|
|
144
181
|
For new components, consider state variants and `data-*` attributes instead of
|
|
145
182
|
options. See [Reusable styles](https://stillwind.dev/docs/guides/reusable-styles).
|
|
146
183
|
|
|
@@ -199,6 +236,12 @@ with its modifier classes, such as `btn btn-outline` in daisyUI. The
|
|
|
199
236
|
[Plugins](https://stillwind.dev/docs/lints/conflicting-utilities#plugins) section of the rule page
|
|
200
237
|
lists a setting for each tested plugin that stops these reports.
|
|
201
238
|
|
|
239
|
+
Selectors that read utility names from the `class` attribute, such as
|
|
240
|
+
`[&_svg:not([class*='size-'])]:size-4` in shadcn/ui components, do not work, because
|
|
241
|
+
Stillwind writes generated class names. The
|
|
242
|
+
[utility-class-selector](https://stillwind.dev/docs/lints/utility-class-selector) lint rule reports them,
|
|
243
|
+
and `stillwind check --fix` rewrites the common default-size form.
|
|
244
|
+
|
|
202
245
|
### Compare computed styles
|
|
203
246
|
|
|
204
247
|
A successful build and clean CLI checks do not prove that the pages look the
|
|
@@ -109,7 +109,7 @@ set a custom property instead. See
|
|
|
109
109
|
|
|
110
110
|
## Migrate CVA components
|
|
111
111
|
|
|
112
|
-
`style.
|
|
112
|
+
`style.recipe()` accepts the configuration of `cva` from class-variance-authority.
|
|
113
113
|
Use it to migrate existing CVA components. See
|
|
114
114
|
[Replace class helpers](https://stillwind.dev/docs/guides/migrating-from-tailwind#replace-class-helpers)
|
|
115
|
-
and the [`style.
|
|
115
|
+
and the [`style.recipe()` reference](https://stillwind.dev/docs/macros/recipe).
|
package/docs/guides/style.md
CHANGED
|
@@ -146,10 +146,7 @@ export function DeleteButton() {
|
|
|
146
146
|
In this example, `dangerButton` has a red background because both background
|
|
147
147
|
rules use equally specific selectors. The order of the class names does not
|
|
148
148
|
affect the result. You can export a stored style and use it in other modules.
|
|
149
|
-
|
|
150
|
-
style, [interfering-imported-style-base](https://stillwind.dev/docs/lints/interfering-imported-style-base)
|
|
151
|
-
reports the call. Define the overriding style in the module that defines the
|
|
152
|
-
base, and import that style instead.
|
|
149
|
+
Utilities that another module adds to the imported style win in the same way.
|
|
153
150
|
|
|
154
151
|
The order of the arguments does not affect the result either.
|
|
155
152
|
`style("bg-red-600", button)` also produces a red background, and
|
package/docs/integrations.md
CHANGED
|
@@ -59,6 +59,23 @@ A component uses the entrypoint of its own framework. For example, a React
|
|
|
59
59
|
island inside an Astro page imports `stillwind/react`, Gatsby uses
|
|
60
60
|
`stillwind/react`, and Fresh 2 uses `stillwind/preact`.
|
|
61
61
|
|
|
62
|
+
### Install the component converters
|
|
63
|
+
|
|
64
|
+
Stillwind reads Vue, Svelte, and Astro components through converter packages.
|
|
65
|
+
These packages are optional peer dependencies, so package managers do not
|
|
66
|
+
install them automatically. Install the packages for each component format that
|
|
67
|
+
the application uses:
|
|
68
|
+
|
|
69
|
+
| Format | Packages |
|
|
70
|
+
| ------ | -------------------------------------------------------------- |
|
|
71
|
+
| Vue | `@vue/compiler-dom`, `@vue/compiler-sfc`, `@vue/language-core` |
|
|
72
|
+
| Svelte | `svelte`, `svelte2tsx` |
|
|
73
|
+
| Astro | `@astrojs/astro2tsx` |
|
|
74
|
+
|
|
75
|
+
For example, a Svelte application installs `svelte2tsx` as a development
|
|
76
|
+
dependency. If a package is missing, the build fails with an error such as
|
|
77
|
+
`Cannot find package 'svelte2tsx'`.
|
|
78
|
+
|
|
62
79
|
### Alpine
|
|
63
80
|
|
|
64
81
|
Register the `stillwind` plugin from `stillwind/alpine` before `Alpine.start()`,
|
|
@@ -409,7 +426,9 @@ every webpack stage:
|
|
|
409
426
|
import { StillwindPlugin } from "@stillwind/integration/webpack";
|
|
410
427
|
|
|
411
428
|
export function onCreateWebpackConfig({ actions, stage }) {
|
|
412
|
-
actions.setWebpackConfig({
|
|
429
|
+
actions.setWebpackConfig({
|
|
430
|
+
plugins: [new StillwindPlugin()],
|
|
431
|
+
});
|
|
413
432
|
if (stage === "develop") {
|
|
414
433
|
actions.setWebpackConfig({
|
|
415
434
|
optimization: {
|
|
@@ -37,7 +37,9 @@ export const props = style(second);
|
|
|
37
37
|
utilities always win.
|
|
38
38
|
- Or remove the property from one of the bases.
|
|
39
39
|
|
|
40
|
-
Bases that set different properties do not need this.
|
|
40
|
+
Bases that set different properties do not need this. The rule also does not
|
|
41
|
+
report a property that one base sets on top of a style that the other base is
|
|
42
|
+
built on, because that base wins.
|
|
41
43
|
|
|
42
44
|
## Rule settings
|
|
43
45
|
|
|
@@ -11,6 +11,9 @@ on the same element. For example, `asContainer("size")` sets
|
|
|
11
11
|
`container-type: size`, and `@container` sets it to `inline-size`. Only one
|
|
12
12
|
value takes effect, and the code does not show which.
|
|
13
13
|
|
|
14
|
+
The rule does not report a call that overrides a property of its base style.
|
|
15
|
+
The CSS of the call comes after the CSS of the base, so the call wins.
|
|
16
|
+
|
|
14
17
|
## Reported
|
|
15
18
|
|
|
16
19
|
```tsx
|
|
@@ -9,6 +9,15 @@ This rule reports two utilities that set the same CSS property under the same
|
|
|
9
9
|
conditions. Only one of them takes effect. The order of the generated CSS decides
|
|
10
10
|
which one, not the order in your code, so the code does not show the result.
|
|
11
11
|
|
|
12
|
+
The rule does not report a utility under a JavaScript condition that is written
|
|
13
|
+
after the other utility and under more conditions, as in
|
|
14
|
+
`style("p-2", wide && "p-4")`. Its CSS comes later, so it overrides the other
|
|
15
|
+
utility when the condition is true, as the code shows.
|
|
16
|
+
[partial-utility-override](https://stillwind.dev/docs/lints/partial-utility-override) checks such
|
|
17
|
+
overrides. When the utility under more conditions is written first, as in
|
|
18
|
+
`style(wide && "p-4", "p-2")`, the rule still reports the pair, because that
|
|
19
|
+
utility wins although `p-2` is written last.
|
|
20
|
+
|
|
12
21
|
## Reported
|
|
13
22
|
|
|
14
23
|
```tsx
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "cyclic-style-order"
|
|
3
|
+
description: "Reports files that import values from each other, so their CSS order cannot follow both."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cyclic-style-order
|
|
7
|
+
|
|
8
|
+
This rule reports a file whose CSS must come after another file's CSS, while
|
|
9
|
+
that file's CSS must also come after this file, directly or through other
|
|
10
|
+
files, and both files set the same property. A file must come after another
|
|
11
|
+
file when it imports and uses a value, such as a component or a base style,
|
|
12
|
+
that the other file declares. See
|
|
13
|
+
[CSS ordering](https://stillwind.dev/docs/concepts/css-ordering#files-that-pass-styles-to-components).
|
|
14
|
+
|
|
15
|
+
When the order forms a cycle, Stillwind keeps one of the orders, and the build
|
|
16
|
+
continues. The utilities that a caller passes to a component, or that a style
|
|
17
|
+
adds to its base, can then lose to the utilities of the other file.
|
|
18
|
+
|
|
19
|
+
The rule does not report a cycle between files that set different properties,
|
|
20
|
+
such as mutually recursive `Tree` and `TreeItem` components that set different
|
|
21
|
+
properties. The order between such files does not change any value.
|
|
22
|
+
|
|
23
|
+
## Reported
|
|
24
|
+
|
|
25
|
+
```tsx title="card.tsx"
|
|
26
|
+
import { style } from "stillwind/react";
|
|
27
|
+
import { Button } from "./button";
|
|
28
|
+
|
|
29
|
+
export function Card(props: CardProps) {
|
|
30
|
+
return (
|
|
31
|
+
<div {...style("rounded p-4", style.forward(props))}>
|
|
32
|
+
<Button {...style("w-full")} />
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```tsx title="button.tsx"
|
|
39
|
+
import { style } from "stillwind/react";
|
|
40
|
+
import { Card } from "./card";
|
|
41
|
+
|
|
42
|
+
export function Button(props: ButtonProps) {
|
|
43
|
+
return <Card {...style("p-2", style.forward(props))} />;
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`card.tsx` imports `Button`, and `button.tsx` imports `Card`. Both files set
|
|
48
|
+
`padding`.
|
|
49
|
+
|
|
50
|
+
## How to fix
|
|
51
|
+
|
|
52
|
+
- Move the shared parts to a file that neither file imports from, so that the
|
|
53
|
+
imports go in one direction.
|
|
54
|
+
- Or remove the property from the styles of one file.
|
|
55
|
+
- Or remove the import in one direction, for example by passing the component
|
|
56
|
+
as a prop or a slot.
|
|
57
|
+
|
|
58
|
+
## Rule settings
|
|
59
|
+
|
|
60
|
+
| Preset | Severity |
|
|
61
|
+
| --- | --- |
|
|
62
|
+
| `recommended` | warn |
|
|
63
|
+
| `strict` | deny |
|
|
64
|
+
| `stylistic` | off |
|
|
65
|
+
|
|
66
|
+
[Configure lint](https://stillwind.dev/docs/configuration#lint) to change the severity or options.
|
|
67
|
+
|
|
68
|
+
The CLI and the editor report this rule only when they analyze the whole project.
|
package/docs/lints/index.md
CHANGED
|
@@ -47,12 +47,12 @@ report never matches.
|
|
|
47
47
|
| ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- | ------- |
|
|
48
48
|
| [invalid-animation-option](https://stillwind.dev/docs/lints/invalid-animation-option) | A utility that is not an animation option, such as `p-4` | deny |
|
|
49
49
|
| [invalid-css-input](https://stillwind.dev/docs/lints/invalid-css-input) | A [`style.css()`](https://stillwind.dev/docs/macros/css) argument that is not a static utility | deny |
|
|
50
|
-
| [invalid-cva-config](https://stillwind.dev/docs/lints/invalid-cva-config) | An unknown or malformed field in a [`style.cva()`](https://stillwind.dev/docs/macros/cva) configuration | deny |
|
|
51
|
-
| [invalid-cva-input](https://stillwind.dev/docs/lints/invalid-cva-input) | `&&` or a ternary inside a `style.cva()` value | deny |
|
|
52
50
|
| [invalid-keyframes-definition](https://stillwind.dev/docs/lints/invalid-keyframes-definition) | A frame key that is not a keyframe position, such as `middle` | deny |
|
|
53
51
|
| [invalid-keyframes-use](https://stillwind.dev/docs/lints/invalid-keyframes-use) | An animation applied with an argument that is not an options string | deny |
|
|
54
52
|
| [invalid-keyframes-variant](https://stillwind.dev/docs/lints/invalid-keyframes-variant) | A selector or container variant around a keyframes definition | deny |
|
|
55
53
|
| [invalid-media-query](https://stillwind.dev/docs/lints/invalid-media-query) | A condition in [`style.media()`](https://stillwind.dev/docs/macros/media) that is not a media query, such as `hover` | deny |
|
|
54
|
+
| [invalid-recipe-config](https://stillwind.dev/docs/lints/invalid-recipe-config) | An unknown or malformed field in a [`style.recipe()`](https://stillwind.dev/docs/macros/recipe) configuration | deny |
|
|
55
|
+
| [invalid-recipe-input](https://stillwind.dev/docs/lints/invalid-recipe-input) | `&&` or a ternary inside a `style.recipe()` value | deny |
|
|
56
56
|
| [invalid-ref-input](https://stillwind.dev/docs/lints/invalid-ref-input) | A [`style.ref()`](https://stillwind.dev/docs/macros/ref) label or ref method argument that is not a literal | deny |
|
|
57
57
|
| [invalid-rule-group-input](https://stillwind.dev/docs/lints/invalid-rule-group-input) | A `class` field or ref inside a variant key of [`style()`](https://stillwind.dev/docs/macros/style) | deny |
|
|
58
58
|
| [invalid-runtime-condition](https://stillwind.dev/docs/lints/invalid-runtime-condition) | A runtime CSS condition that Stillwind cannot compile | deny |
|
|
@@ -75,14 +75,17 @@ report never matches.
|
|
|
75
75
|
|
|
76
76
|
## Conflicting or duplicated styles
|
|
77
77
|
|
|
78
|
-
| Rule | Reports
|
|
79
|
-
| ------------------------------------------------------------------------------ |
|
|
80
|
-
| [ambiguous-style-base-order](https://stillwind.dev/docs/lints/ambiguous-style-base-order) | Two base styles in one call that set the same property
|
|
81
|
-
| [conflicting-provider-properties](https://stillwind.dev/docs/lints/conflicting-provider-properties) | A container or anchor property that a ref method and a utility both set
|
|
82
|
-
| [conflicting-utilities](https://stillwind.dev/docs/lints/conflicting-utilities) | Utilities that set the same property, such as `p-2 p-4`
|
|
83
|
-
| [
|
|
84
|
-
| [
|
|
85
|
-
| [
|
|
78
|
+
| Rule | Reports | Default |
|
|
79
|
+
| ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | ------- |
|
|
80
|
+
| [ambiguous-style-base-order](https://stillwind.dev/docs/lints/ambiguous-style-base-order) | Two base styles in one call that set the same property | warn |
|
|
81
|
+
| [conflicting-provider-properties](https://stillwind.dev/docs/lints/conflicting-provider-properties) | A container or anchor property that a ref method and a utility both set | warn |
|
|
82
|
+
| [conflicting-utilities](https://stillwind.dev/docs/lints/conflicting-utilities) | Utilities that set the same property, such as `p-2 p-4` | warn |
|
|
83
|
+
| [cyclic-style-order](https://stillwind.dev/docs/lints/cyclic-style-order) | Files that pass styles to components of each other | warn |
|
|
84
|
+
| [duplicate-utility](https://stillwind.dev/docs/lints/duplicate-utility) | The same utility twice under the same conditions | warn |
|
|
85
|
+
| [interfering-imported-style-base](https://stillwind.dev/docs/lints/interfering-imported-style-base) | An imported base style that sets the same property as another style | warn |
|
|
86
|
+
| [multiple-style-forwards](https://stillwind.dev/docs/lints/multiple-style-forwards) | A `style()` call with more than one `style.forward()` argument | warn |
|
|
87
|
+
| [partial-utility-override](https://stillwind.dev/docs/lints/partial-utility-override) | An override that leaves properties of the overridden utility, such as the line height of `text-sm` | warn |
|
|
88
|
+
| [unverified-style-base](https://stillwind.dev/docs/lints/unverified-style-base) | A base style whose origin the CLI cannot determine from its type | warn |
|
|
86
89
|
|
|
87
90
|
## Styles that do not apply as written
|
|
88
91
|
|
|
@@ -99,6 +102,7 @@ report never matches.
|
|
|
99
102
|
| [split-view-transition-class](https://stillwind.dev/docs/lints/split-view-transition-class) | View transitions split across separate [`style()`](https://stillwind.dev/docs/macros/style) calls | warn |
|
|
100
103
|
| [unmatched-host-selector](https://stillwind.dev/docs/lints/unmatched-host-selector) | A variant that tests a shadow host through the elements around it | warn |
|
|
101
104
|
| [unsatisfiable-variants](https://stillwind.dev/docs/lints/unsatisfiable-variants) | Variants that can never match together, such as `portrait:landscape:` | warn |
|
|
105
|
+
| [utility-class-selector](https://stillwind.dev/docs/lints/utility-class-selector) | A selector that tests the class attribute for a utility name, such as `[class*='size-']` | warn |
|
|
102
106
|
|
|
103
107
|
## Stylesheet definitions
|
|
104
108
|
|
|
@@ -6,13 +6,11 @@ description: "Reports an imported base style that sets the same property as anot
|
|
|
6
6
|
# interfering-imported-style-base
|
|
7
7
|
|
|
8
8
|
This rule reports a base style from another module that sets the same property as
|
|
9
|
-
another base
|
|
10
|
-
|
|
9
|
+
another base in the call, when neither base is built on the other. The order of
|
|
10
|
+
the arguments does not decide which base wins.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- An imported base and a utility of the call set the same property. The utility of
|
|
15
|
-
the call wins, but the rule still reports the call.
|
|
12
|
+
A utility of the call can override an imported base. Its CSS always comes after
|
|
13
|
+
the CSS of the base, so the rule does not report it.
|
|
16
14
|
|
|
17
15
|
## Project files
|
|
18
16
|
|
|
@@ -20,7 +18,6 @@ reports both cases:
|
|
|
20
18
|
import { style } from "stillwind/react";
|
|
21
19
|
export const first = style("p-2");
|
|
22
20
|
export const second = style("p-4");
|
|
23
|
-
export const combined = style(first, "p-4");
|
|
24
21
|
```
|
|
25
22
|
|
|
26
23
|
## Reported
|
|
@@ -28,7 +25,6 @@ export const combined = style(first, "p-4");
|
|
|
28
25
|
```tsx
|
|
29
26
|
import { first, second } from "./bases";
|
|
30
27
|
export const props = style(first, second);
|
|
31
|
-
export const padded = style(first, "p-4");
|
|
32
28
|
```
|
|
33
29
|
|
|
34
30
|
> interfering-imported-style-base: the base in `bases.ts` overlaps these declarations: `padding`
|
|
@@ -37,30 +33,25 @@ export const padded = style(first, "p-4");
|
|
|
37
33
|
>
|
|
38
34
|
> reordering the style() arguments does not change which declaration wins
|
|
39
35
|
|
|
40
|
-
> interfering-imported-style-base: the base in `bases.ts` overlaps these declarations: `padding`
|
|
41
|
-
>
|
|
42
|
-
> Example:3:23
|
|
43
|
-
>
|
|
44
|
-
> reordering the style() arguments does not change which declaration wins
|
|
45
|
-
|
|
46
36
|
## Fixed
|
|
47
37
|
|
|
48
38
|
```tsx
|
|
49
|
-
import {
|
|
50
|
-
export const props = style(
|
|
39
|
+
import { first } from "./bases";
|
|
40
|
+
export const props = style(first, "p-4");
|
|
51
41
|
```
|
|
52
42
|
|
|
53
|
-
|
|
54
|
-
in the module that defines `first`.
|
|
43
|
+
The call sets `p-4` on top of `first`, so its padding always wins.
|
|
55
44
|
|
|
56
45
|
## How to fix
|
|
57
46
|
|
|
58
|
-
-
|
|
59
|
-
|
|
47
|
+
- Keep the base whose other properties you need, and write the overriding
|
|
48
|
+
utility in the call, as in the example.
|
|
49
|
+
- Or, in the module that defines the styles, build the overriding style on the
|
|
50
|
+
other one, such as `style(first, "p-4")`. Then import that style.
|
|
60
51
|
- Or remove the property from one of the styles.
|
|
61
52
|
|
|
62
|
-
Reordering the arguments does not fix it. `style(
|
|
63
|
-
|
|
53
|
+
Reordering the arguments does not fix it. `style(second, first)` produces the
|
|
54
|
+
same CSS and the same finding.
|
|
64
55
|
|
|
65
56
|
## Rule settings
|
|
66
57
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "invalid-
|
|
3
|
-
description: "Reports an unknown or malformed field in a style.
|
|
2
|
+
title: "invalid-recipe-config"
|
|
3
|
+
description: "Reports an unknown or malformed field in a style.recipe() configuration."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# invalid-
|
|
6
|
+
# invalid-recipe-config
|
|
7
7
|
|
|
8
|
-
This rule reports a `style.
|
|
8
|
+
This rule reports a `style.recipe()` configuration that the compiler cannot read,
|
|
9
9
|
such as an unknown field, a default for an option that does not exist, or a
|
|
10
10
|
configuration that is not written in the call. The factory ignores the invalid
|
|
11
11
|
part.
|
|
@@ -13,7 +13,7 @@ part.
|
|
|
13
13
|
## Reported
|
|
14
14
|
|
|
15
15
|
```tsx
|
|
16
|
-
style.
|
|
16
|
+
style.recipe("p-4", {
|
|
17
17
|
variant: {
|
|
18
18
|
size: {
|
|
19
19
|
small: "p-2",
|
|
@@ -22,14 +22,14 @@ style.cva("p-4", {
|
|
|
22
22
|
});
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
> invalid-
|
|
25
|
+
> invalid-recipe-config: invalid style.recipe() configuration: unknown configuration property
|
|
26
26
|
>
|
|
27
27
|
> Example:2:12
|
|
28
28
|
|
|
29
29
|
## Fixed
|
|
30
30
|
|
|
31
31
|
```tsx
|
|
32
|
-
style.
|
|
32
|
+
style.recipe("p-4", {
|
|
33
33
|
variants: {
|
|
34
34
|
size: {
|
|
35
35
|
small: "p-2",
|
|
@@ -45,7 +45,7 @@ style.cva("p-4", {
|
|
|
45
45
|
- In `defaultVariants` and `compoundVariants`, use only options and values that
|
|
46
46
|
`variants` declares.
|
|
47
47
|
|
|
48
|
-
See [`style.
|
|
48
|
+
See [`style.recipe()`](https://stillwind.dev/docs/macros/recipe#configuration).
|
|
49
49
|
|
|
50
50
|
## Rule settings
|
|
51
51
|
|