stillwind 0.7.0 → 0.9.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 +193 -0
- package/css/builtin-variants/sw-conditional.css +10 -1
- package/css/builtin-variants/tw-relationship.css +4 -4
- package/css/builtins.css +1 -1
- package/dist/{class-object-D7ZGJOf_.d.ts → class-object-BaK8uudd.d.ts} +2 -2
- package/dist/class-object-DNcjzcfH.js +6 -0
- package/dist/{class-object-D24FFYqO.js.map → class-object-DNcjzcfH.js.map} +1 -1
- package/dist/{class-string-CQHnc9GN.d.ts → class-string-C5YFtXQn.d.ts} +2 -2
- package/dist/class-string-KnYInbiw.js +6 -0
- package/dist/{class-string-Db8-oI4q.js.map → class-string-KnYInbiw.js.map} +1 -1
- package/dist/{cva-BwX07CFw.js → formats-Ctf2WFc-.js} +87 -2
- package/dist/formats-Ctf2WFc-.js.map +1 -0
- package/dist/formats-aeLCNAXl.d.ts +73 -0
- package/dist/frameworks/alpine.d.ts +3 -3
- package/dist/frameworks/alpine.js +1 -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 +3 -3
- package/dist/frameworks/lit.js +1 -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 +3 -3
- package/dist/frameworks/vanilla.js +1 -1
- package/dist/frameworks/vue.d.ts +3 -3
- package/dist/frameworks/vue.js +1 -1
- package/dist/{index-RwVFpxhE.d.ts → index-DBpgaaD7.d.ts} +54 -5
- package/dist/macro/index.d.ts +2 -2
- package/dist/macro/index.js +1 -1
- package/dist/runtime/development.d.ts +47 -0
- package/dist/{development-J-JCSIm0.js → runtime/development.js} +41 -5
- package/dist/runtime/development.js.map +1 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +1 -0
- package/dist/{style-fTQbsVWZ.js → style-BE8vuLiO.js} +4 -1
- package/dist/style-BE8vuLiO.js.map +1 -0
- package/docs/at-rules/apply.md +5 -5
- package/docs/at-rules/custom-variant.md +12 -12
- package/docs/at-rules/index.md +19 -19
- package/docs/at-rules/plugin.md +7 -7
- package/docs/at-rules/registry-directives.md +9 -9
- package/docs/at-rules/slot.md +6 -6
- package/docs/at-rules/stillwind-css-template.md +7 -7
- package/docs/at-rules/stillwind-property.md +10 -10
- package/docs/at-rules/stillwind-registry.md +18 -18
- package/docs/at-rules/stillwind-require-properties.md +9 -9
- package/docs/at-rules/stillwind-slot.md +6 -6
- package/docs/at-rules/stillwind-undef-arbitrary-property.md +9 -9
- package/docs/at-rules/stillwind-undef-utility.md +10 -10
- package/docs/at-rules/stillwind-undef-variant.md +6 -6
- package/docs/at-rules/theme.md +23 -23
- package/docs/at-rules/utility.md +30 -30
- package/docs/at-rules/variant.md +6 -6
- package/docs/cli.md +11 -8
- package/docs/concepts/css-ordering.md +19 -19
- package/docs/concepts/how-styles-compile.md +17 -17
- package/docs/concepts/stylesheets.md +4 -4
- package/docs/configuration.md +34 -34
- package/docs/editors.md +9 -8
- package/docs/errors/SW01003.md +1 -1
- package/docs/errors/SW10001.md +1 -1
- package/docs/errors/SW10002.md +1 -1
- package/docs/errors/SW10004.md +7 -6
- package/docs/errors/SW10005.md +1 -1
- package/docs/errors/SW11001.md +1 -1
- package/docs/errors/SW11003.md +1 -1
- package/docs/errors/SW12001.md +2 -2
- package/docs/errors/SW12002.md +1 -1
- package/docs/errors/SW13001.md +1 -1
- package/docs/errors/SW13003.md +2 -2
- package/docs/errors/SW14001.md +1 -1
- package/docs/errors/SW14003.md +4 -4
- package/docs/errors/SW14004.md +2 -2
- package/docs/errors/SW14005.md +1 -1
- package/docs/errors/SW14006.md +1 -1
- package/docs/errors/SW14007.md +2 -2
- package/docs/errors/SW14008.md +1 -1
- package/docs/errors/SW30001.md +1 -1
- package/docs/errors/SW31001.md +1 -1
- package/docs/errors/SW31004.md +1 -1
- package/docs/errors/SW33005.md +1 -1
- package/docs/errors/SW34002.md +1 -1
- package/docs/errors/SW90001.md +1 -1
- package/docs/errors/SW90005.md +1 -1
- package/docs/errors/SW90006.md +1 -1
- package/docs/errors/index.md +72 -72
- package/docs/formatters.md +5 -5
- package/docs/guides/animations.md +7 -8
- package/docs/guides/design-systems.md +7 -7
- package/docs/guides/element-relationships.md +15 -19
- package/docs/guides/lint-adoption.md +5 -5
- package/docs/guides/migrating-from-css.md +11 -11
- package/docs/guides/migrating-from-tailwind.md +16 -16
- package/docs/guides/recommended-practices.md +18 -18
- package/docs/guides/responsive-styles.md +7 -7
- package/docs/guides/reusable-styles.md +10 -5
- package/docs/guides/runtime-conditions.md +6 -6
- package/docs/guides/style.md +42 -10
- package/docs/guides/tailwind-compatibility.md +23 -22
- package/docs/guides/view-transitions.md +9 -11
- package/docs/guides/web-components.md +4 -4
- package/docs/index.md +14 -12
- package/docs/integrations.md +3 -3
- package/docs/lints/ambiguous-style-base-order.md +4 -2
- package/docs/lints/bypassed-undefinition.md +3 -3
- package/docs/lints/clamped-value.md +1 -1
- package/docs/lints/conflicting-provider-properties.md +2 -2
- package/docs/lints/conflicting-utilities.md +45 -3
- package/docs/lints/document-scoped-selector.md +1 -1
- package/docs/lints/duplicate-definition.md +3 -3
- package/docs/lints/duplicate-utility.md +2 -2
- package/docs/lints/duplicate-view-transition-name.md +3 -3
- package/docs/lints/ignored-definition-condition.md +2 -2
- package/docs/lints/ignored-tailwind-feature.md +3 -3
- package/docs/lints/implicit-nesting-selector.md +2 -2
- package/docs/lints/incompatible-property-value.md +3 -3
- package/docs/lints/incompatible-theme-value.md +1 -1
- package/docs/lints/index.md +74 -73
- package/docs/lints/ineffective-anchor-scope.md +2 -2
- package/docs/lints/interfering-imported-style-base.md +22 -4
- package/docs/lints/invalid-animation-option.md +3 -3
- package/docs/lints/invalid-css-directive.md +3 -3
- package/docs/lints/invalid-css-import.md +2 -2
- package/docs/lints/invalid-css-input.md +4 -4
- package/docs/lints/invalid-cva-config.md +2 -2
- package/docs/lints/invalid-cva-input.md +4 -4
- package/docs/lints/invalid-keyframes-definition.md +2 -2
- package/docs/lints/invalid-keyframes-use.md +2 -2
- package/docs/lints/invalid-keyframes-variant.md +4 -4
- package/docs/lints/invalid-lint-suppression.md +3 -3
- package/docs/lints/invalid-marker-use.md +2 -2
- package/docs/lints/invalid-media-query.md +4 -4
- package/docs/lints/invalid-ref-input.md +4 -4
- package/docs/lints/invalid-rule-group-input.md +2 -2
- package/docs/lints/invalid-runtime-condition.md +3 -3
- package/docs/lints/invalid-stored-variant.md +52 -0
- package/docs/lints/invalid-style-composition.md +2 -2
- package/docs/lints/invalid-style-input.md +2 -2
- package/docs/lints/invalid-theme-reference.md +3 -3
- package/docs/lints/invalid-utility.md +3 -3
- package/docs/lints/invalid-variant.md +2 -2
- package/docs/lints/invalid-view-transition-definition.md +2 -2
- package/docs/lints/invalid-view-transition-use.md +2 -2
- package/docs/lints/invalid-view-transition-variant.md +3 -3
- package/docs/lints/mismatched-framework-import.md +3 -3
- package/docs/lints/missing-document-target.md +2 -2
- package/docs/lints/missing-ref-attachment.md +4 -4
- package/docs/lints/missing-view-transition-name.md +3 -3
- package/docs/lints/mutating-macro-argument.md +2 -2
- package/docs/lints/no-arbitrary-breakpoints.md +2 -2
- package/docs/lints/no-arbitrary-colors.md +2 -2
- package/docs/lints/no-arbitrary-spacing.md +1 -1
- package/docs/lints/no-class-property.md +3 -3
- package/docs/lints/no-important.md +2 -2
- package/docs/lints/no-restricted-declarations.md +1 -1
- package/docs/lints/no-restricted-length-units.md +1 -1
- package/docs/lints/no-restricted-theme-tokens.md +1 -1
- package/docs/lints/no-restricted-utilities.md +2 -2
- package/docs/lints/prefer-canonical-utilities.md +2 -2
- package/docs/lints/prefer-direct-styling.md +3 -3
- package/docs/lints/prefer-logical-properties.md +3 -3
- package/docs/lints/prefer-sorted-utilities.md +2 -2
- package/docs/lints/prefer-typed-relationships.md +3 -3
- package/docs/lints/prefer-typed-variables.md +1 -1
- package/docs/lints/prefer-variant-directive.md +3 -3
- package/docs/lints/redundant-variant.md +2 -2
- package/docs/lints/repeated-nesting-selector.md +2 -2
- package/docs/lints/runtime-condition-requires-css-if.md +3 -3
- package/docs/lints/split-view-transition-class.md +3 -3
- package/docs/lints/suspending-macro-argument.md +2 -2
- package/docs/lints/unknown-utility.md +4 -4
- package/docs/lints/unknown-variant.md +2 -2
- package/docs/lints/unmatched-host-selector.md +2 -2
- package/docs/lints/unsatisfiable-variants.md +1 -1
- package/docs/lints/unused-lint-suppression.md +1 -1
- package/docs/lints/unverified-style-base.md +2 -2
- package/docs/macros/anchor-scope.md +13 -13
- package/docs/macros/css.md +7 -7
- package/docs/macros/cva.md +17 -16
- package/docs/macros/index.md +10 -9
- package/docs/macros/keyframes.md +9 -9
- package/docs/macros/media.md +2 -2
- package/docs/macros/ref/as-anchor.md +11 -11
- package/docs/macros/ref/as-container.md +8 -8
- package/docs/macros/ref/at.md +10 -10
- package/docs/macros/ref/condition.md +9 -8
- package/docs/macros/ref/in.md +11 -11
- package/docs/macros/ref/index.md +17 -16
- package/docs/macros/ref/position-anchor.md +9 -9
- package/docs/macros/style.md +53 -27
- package/docs/macros/view-transition.md +17 -17
- package/docs/macros/when.md +129 -0
- package/docs/plugins/iconify.md +5 -5
- package/docs/plugins/index.md +4 -4
- package/docs/utilities-and-variants.md +6 -6
- package/docs/why.md +13 -15
- package/package.json +14 -28
- package/dist/class-object-D24FFYqO.js +0 -6
- package/dist/class-string-Db8-oI4q.js +0 -6
- package/dist/cva-BwX07CFw.js.map +0 -1
- package/dist/cva-DSpDNBYi.d.ts +0 -9
- package/dist/development-DttPQc71.d.ts +0 -27
- package/dist/development-J-JCSIm0.js.map +0 -1
- package/dist/runtime/class-name-object-development.d.ts +0 -10
- package/dist/runtime/class-name-object-development.js +0 -18
- package/dist/runtime/class-name-object-development.js.map +0 -1
- package/dist/runtime/class-name-object.d.ts +0 -16
- package/dist/runtime/class-name-object.js +0 -31
- package/dist/runtime/class-name-object.js.map +0 -1
- package/dist/runtime/class-object-development.d.ts +0 -10
- package/dist/runtime/class-object-development.js +0 -18
- package/dist/runtime/class-object-development.js.map +0 -1
- package/dist/runtime/class-object.d.ts +0 -16
- package/dist/runtime/class-object.js +0 -31
- package/dist/runtime/class-object.js.map +0 -1
- package/dist/runtime/class-string-development.d.ts +0 -10
- package/dist/runtime/class-string-development.js +0 -18
- package/dist/runtime/class-string-development.js.map +0 -1
- package/dist/runtime/class-string.d.ts +0 -16
- package/dist/runtime/class-string.js +0 -31
- package/dist/runtime/class-string.js.map +0 -1
- package/dist/shared-B9IQXU6P.d.ts +0 -32
- package/dist/style-fTQbsVWZ.js.map +0 -1
package/docs/macros/index.md
CHANGED
|
@@ -11,14 +11,15 @@ and it shows the generated JavaScript and CSS for its examples.
|
|
|
11
11
|
|
|
12
12
|
| Macro | Use it to | Guide |
|
|
13
13
|
| -------------------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
14
|
-
| [`style()`](style
|
|
15
|
-
| [`style.ref()`](ref
|
|
16
|
-
| [`style.anchorScope()`](anchor-scope
|
|
17
|
-
| [`style.keyframes()`](keyframes
|
|
18
|
-
| [`style.viewTransition()`](view-transition
|
|
19
|
-
| [`style.
|
|
20
|
-
| [`style.
|
|
21
|
-
| [`style.
|
|
14
|
+
| [`style()`](https://stillwind.dev/docs/macros/style) | Style an element | [The basics of style()](https://stillwind.dev/docs/guides/style) |
|
|
15
|
+
| [`style.ref()`](https://stillwind.dev/docs/macros/ref) | Style an element from another element's state, size, or position | [Element relationships](https://stillwind.dev/docs/guides/element-relationships) |
|
|
16
|
+
| [`style.anchorScope()`](https://stillwind.dev/docs/macros/anchor-scope) | Limit where an anchor name is visible | [Element relationships](https://stillwind.dev/docs/guides/element-relationships) |
|
|
17
|
+
| [`style.keyframes()`](https://stillwind.dev/docs/macros/keyframes) | Define an animation in a component | [Animations](https://stillwind.dev/docs/guides/animations) |
|
|
18
|
+
| [`style.viewTransition()`](https://stillwind.dev/docs/macros/view-transition) | Style view transition snapshots and name each item | [View transitions](https://stillwind.dev/docs/guides/view-transitions) |
|
|
19
|
+
| [`style.when()`](https://stillwind.dev/docs/macros/when) | Reuse a variant sequence, such as a ref condition | [Element relationships](https://stillwind.dev/docs/guides/element-relationships) |
|
|
20
|
+
| [`style.media()`](https://stillwind.dev/docs/macros/media) | Use a named breakpoint as a media query in JavaScript | [Responsive styles](https://stillwind.dev/docs/guides/responsive-styles) |
|
|
21
|
+
| [`style.css()`](https://stillwind.dev/docs/macros/css) | Compile utilities into a CSS string for a shadow root | [Web Components](https://stillwind.dev/docs/guides/web-components) |
|
|
22
|
+
| [`style.cva()`](https://stillwind.dev/docs/macros/cva) | Migrate components that use `cva` | [Migrating from Tailwind CSS](https://stillwind.dev/docs/guides/migrating-from-tailwind) |
|
|
22
23
|
|
|
23
24
|
Import the macros from the entrypoint of your framework, such as
|
|
24
25
|
`stillwind/react`. The examples on these pages use React.
|
|
@@ -26,5 +27,5 @@ Import the macros from the entrypoint of your framework, such as
|
|
|
26
27
|
Each example shows the source, the compiled code, and the CSS that it adds to
|
|
27
28
|
the stylesheet. In development, Stillwind also adds checks that report invalid
|
|
28
29
|
values at runtime. The compiled code on these pages leaves them out.
|
|
29
|
-
[How styles compile](
|
|
30
|
+
[How styles compile](https://stillwind.dev/docs/concepts/how-styles-compile) explains the generated code in
|
|
30
31
|
general.
|
package/docs/macros/keyframes.md
CHANGED
|
@@ -6,7 +6,7 @@ description: "Define keyframes in a component, and apply them with animation opt
|
|
|
6
6
|
# style.keyframes()
|
|
7
7
|
|
|
8
8
|
`style.keyframes(definition)` defines an animation. Calling the result inside
|
|
9
|
-
[`style()`](style
|
|
9
|
+
[`style()`](https://stillwind.dev/docs/macros/style) applies the animation, and its argument sets
|
|
10
10
|
the animation's options. The compiler generates a unique animation name.
|
|
11
11
|
|
|
12
12
|
## Example
|
|
@@ -27,14 +27,14 @@ export const props = style(fade("duration-300 ease-in-out"));
|
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
29
|
const fade = undefined;
|
|
30
|
-
export const props = {className:"
|
|
30
|
+
export const props = {className:"sw_tcsva"};
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
### Generated CSS
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
```css
|
|
37
|
-
@keyframes sw-kf-
|
|
37
|
+
@keyframes sw-kf-zylc1 {
|
|
38
38
|
from {
|
|
39
39
|
opacity: 0;
|
|
40
40
|
}
|
|
@@ -44,8 +44,8 @@ export const props = {className:"sw_4y7y6"};
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
.
|
|
48
|
-
animation-name: sw-kf-
|
|
47
|
+
.sw_tcsva {
|
|
48
|
+
animation-name: sw-kf-zylc1;
|
|
49
49
|
animation-duration: .3s;
|
|
50
50
|
animation-timing-function: var(--ease-in-out);
|
|
51
51
|
}
|
|
@@ -78,10 +78,10 @@ The argument is a string literal of animation options. Timing utilities set
|
|
|
78
78
|
animation properties here: `duration-300` sets `animation-duration`, not
|
|
79
79
|
`transition-duration`. A utility that is not an animation option, such as
|
|
80
80
|
`p-4`, produces no CSS, and
|
|
81
|
-
[invalid-animation-option](
|
|
81
|
+
[invalid-animation-option](https://stillwind.dev/docs/lints/invalid-animation-option) reports it.
|
|
82
82
|
|
|
83
83
|
Write the call directly in `style()`. Storing `fade("duration-300")` in a
|
|
84
|
-
variable causes [SW10004](
|
|
84
|
+
variable causes [SW10004](https://stillwind.dev/docs/errors/SW10004).
|
|
85
85
|
|
|
86
86
|
To turn the animation on or off by condition, put the call under a variant, such
|
|
87
87
|
as `{ "motion-safe:": fade("duration-300") }`.
|
|
@@ -94,6 +94,6 @@ The compiler writes every
|
|
|
94
94
|
[`@keyframes`](https://developer.mozilla.org/docs/Web/CSS/Reference/At-rules/@keyframes)
|
|
95
95
|
rule that the calls need, together with the theme values that the frames use.
|
|
96
96
|
|
|
97
|
-
See [Animations](
|
|
98
|
-
[invalid-keyframes-variant](
|
|
97
|
+
See [Animations](https://stillwind.dev/docs/guides/animations) for task-based examples, and
|
|
98
|
+
[invalid-keyframes-variant](https://stillwind.dev/docs/lints/invalid-keyframes-variant) for
|
|
99
99
|
unsupported variants.
|
package/docs/macros/media.md
CHANGED
|
@@ -48,7 +48,7 @@ It contains one or more variants. The final colon is optional.
|
|
|
48
48
|
Only variants that are media conditions are accepted. `hover` and other element
|
|
49
49
|
states, `supports-*`, and container queries are not media conditions. An
|
|
50
50
|
argument that is not a media condition is left out, and
|
|
51
|
-
[invalid-media-query](
|
|
51
|
+
[invalid-media-query](https://stillwind.dev/docs/lints/invalid-media-query) reports it. When no
|
|
52
52
|
argument remains, the result is `not all`.
|
|
53
53
|
|
|
54
54
|
Write `style.media()` outside other Stillwind calls.
|
|
@@ -63,4 +63,4 @@ time the module compiles.
|
|
|
63
63
|
|
|
64
64
|
`matchMedia()` is a browser API. Call it on the client, and remove its
|
|
65
65
|
listeners when their component unmounts. See
|
|
66
|
-
[Responsive styles](
|
|
66
|
+
[Responsive styles](https://stillwind.dev/docs/guides/responsive-styles).
|
|
@@ -8,7 +8,7 @@ description: "Make the element that has a ref a named anchor for CSS anchor posi
|
|
|
8
8
|
`trigger.asAnchor(scope?)` sets
|
|
9
9
|
[`anchor-name`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/anchor-name)
|
|
10
10
|
on the element. Position another element against it with
|
|
11
|
-
[`trigger.positionAnchor()`](position-anchor
|
|
11
|
+
[`trigger.positionAnchor()`](https://stillwind.dev/docs/macros/ref/position-anchor).
|
|
12
12
|
|
|
13
13
|
## Example
|
|
14
14
|
|
|
@@ -26,20 +26,20 @@ export const popover = style("absolute", trigger.positionAnchor(), "top-[anchor(
|
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
28
|
const trigger = undefined;
|
|
29
|
-
export const button = {className:"
|
|
30
|
-
export const popover = {className:"
|
|
29
|
+
export const button = {className:"sw_6x3gz sw_trigger_xnhw0"};
|
|
30
|
+
export const popover = {className:"sw_e3wyz"};
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
### Generated CSS
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
```css
|
|
37
|
-
.
|
|
38
|
-
anchor-name: --sw-a-trigger-
|
|
37
|
+
.sw_6x3gz:where(.sw_trigger_xnhw0) {
|
|
38
|
+
anchor-name: --sw-a-trigger-xnhw0;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
.
|
|
42
|
-
position-anchor: --sw-a-trigger-
|
|
41
|
+
.sw_e3wyz {
|
|
42
|
+
position-anchor: --sw-a-trigger-xnhw0;
|
|
43
43
|
position: absolute;
|
|
44
44
|
top: anchor(bottom);
|
|
45
45
|
}
|
|
@@ -60,16 +60,16 @@ on the element:
|
|
|
60
60
|
|
|
61
61
|
Write the array directly in the call. The array includes the `trigger` ref only
|
|
62
62
|
when you list it. An empty array sets nothing, and
|
|
63
|
-
[ineffective-anchor-scope](
|
|
63
|
+
[ineffective-anchor-scope](https://stillwind.dev/docs/lints/ineffective-anchor-scope) reports it.
|
|
64
64
|
|
|
65
65
|
## Behavior
|
|
66
66
|
|
|
67
67
|
Pass `trigger` and `trigger.asAnchor()` in the same
|
|
68
|
-
[`style()`](
|
|
68
|
+
[`style()`](https://stillwind.dev/docs/macros/style) call. The anchor name applies only to an
|
|
69
69
|
element that has the ref, and
|
|
70
|
-
[missing-ref-attachment](
|
|
70
|
+
[missing-ref-attachment](https://stillwind.dev/docs/lints/missing-ref-attachment) reports a call
|
|
71
71
|
without it.
|
|
72
72
|
|
|
73
73
|
To limit the anchor name from an ancestor instead, use
|
|
74
|
-
[`style.anchorScope()`](
|
|
74
|
+
[`style.anchorScope()`](https://stillwind.dev/docs/macros/anchor-scope). Stillwind generates CSS
|
|
75
75
|
only, so check that the browsers you support implement anchor positioning.
|
|
@@ -10,7 +10,7 @@ description: "Make the element that has a ref a named container for ref.at() que
|
|
|
10
10
|
on the element, and it sets
|
|
11
11
|
[`container-type`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/container-type)
|
|
12
12
|
when you pass a type. Query the container with
|
|
13
|
-
[`card.at()`](at
|
|
13
|
+
[`card.at()`](https://stillwind.dev/docs/macros/ref/at).
|
|
14
14
|
|
|
15
15
|
## Example
|
|
16
16
|
|
|
@@ -27,19 +27,19 @@ export const container = style(card, card.asContainer("inline-size"), "p-4");
|
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
29
|
const card = undefined;
|
|
30
|
-
export const container = {className:"
|
|
30
|
+
export const container = {className:"sw_9kism sw_card_nudp9"};
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
### Generated CSS
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
```css
|
|
37
|
-
.
|
|
37
|
+
.sw_9kism {
|
|
38
38
|
padding: calc(var(--spacing) * 4);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
.
|
|
42
|
-
container-name: sw-c-card-
|
|
41
|
+
.sw_9kism:where(.sw_card_nudp9) {
|
|
42
|
+
container-name: sw-c-card-nudp9;
|
|
43
43
|
container-type: inline-size;
|
|
44
44
|
}
|
|
45
45
|
```
|
|
@@ -57,11 +57,11 @@ its value. A type stored in a variable is not accepted.
|
|
|
57
57
|
|
|
58
58
|
## Behavior
|
|
59
59
|
|
|
60
|
-
Pass `card` and `card.asContainer()` in the same [`style()`](
|
|
60
|
+
Pass `card` and `card.asContainer()` in the same [`style()`](https://stillwind.dev/docs/macros/style)
|
|
61
61
|
call. The container declarations apply only to an element that has the ref, and
|
|
62
|
-
[missing-ref-attachment](
|
|
62
|
+
[missing-ref-attachment](https://stillwind.dev/docs/lints/missing-ref-attachment) reports a call
|
|
63
63
|
without it.
|
|
64
64
|
|
|
65
65
|
When another rule on the element also sets `container-name` or `container-type`,
|
|
66
|
-
[conflicting-provider-properties](
|
|
66
|
+
[conflicting-provider-properties](https://stillwind.dev/docs/lints/conflicting-provider-properties)
|
|
67
67
|
reports it.
|
package/docs/macros/ref/at.md
CHANGED
|
@@ -8,7 +8,7 @@ description: "Style an element with a container query on the element that has a
|
|
|
8
8
|
`card.at(query?)` creates
|
|
9
9
|
[a container query](https://developer.mozilla.org/docs/Web/CSS/Guides/Containment/Container_queries)
|
|
10
10
|
on the container that the `card` ref names. Make that element a container with
|
|
11
|
-
[`card.asContainer()`](as-container
|
|
11
|
+
[`card.asContainer()`](https://stillwind.dev/docs/macros/ref/as-container).
|
|
12
12
|
|
|
13
13
|
## Example
|
|
14
14
|
|
|
@@ -26,21 +26,21 @@ export const child = style({ [card.at("width >= 40rem")]: "grid-cols-2" });
|
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
28
|
const card = undefined;
|
|
29
|
-
export const container = {className:"
|
|
30
|
-
export const child = {className:"
|
|
29
|
+
export const container = {className:"sw_osnwd sw_card_nudp9"};
|
|
30
|
+
export const child = {className:"sw_hzszw"};
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
### Generated CSS
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
```css
|
|
37
|
-
.
|
|
38
|
-
container-name: sw-c-card-
|
|
37
|
+
.sw_osnwd:where(.sw_card_nudp9) {
|
|
38
|
+
container-name: sw-c-card-nudp9;
|
|
39
39
|
container-type: inline-size;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
@container sw-c-card-
|
|
43
|
-
.
|
|
42
|
+
@container sw-c-card-nudp9 (width >= 40rem) {
|
|
43
|
+
.sw_hzszw {
|
|
44
44
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -62,8 +62,8 @@ Leave out the outer parentheses.
|
|
|
62
62
|
Without a query, the condition matches whenever the styled element is inside a
|
|
63
63
|
container with the name.
|
|
64
64
|
|
|
65
|
-
Write the call directly as a computed key in [`style()`](
|
|
66
|
-
|
|
65
|
+
Write the call directly as a computed key in [`style()`](https://stillwind.dev/docs/macros/style).
|
|
66
|
+
To use it in several places, store it with [`style.when()`](https://stillwind.dev/docs/macros/when).
|
|
67
67
|
|
|
68
|
-
See [Element relationships](
|
|
68
|
+
See [Element relationships](https://stillwind.dev/docs/guides/element-relationships#react-to-a-containers-size)
|
|
69
69
|
for a task-based example.
|
|
@@ -25,21 +25,21 @@ export const title = style({ [card("hover")]: "text-blue-600" });
|
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
27
|
const card = undefined;
|
|
28
|
-
export const container = {className:"
|
|
29
|
-
export const title = {className:"
|
|
28
|
+
export const container = {className:"sw_gky8e sw_card_nudp9"};
|
|
29
|
+
export const title = {className:"sw_0m922"};
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
### Generated CSS
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
```css
|
|
36
|
-
.
|
|
36
|
+
.sw_gky8e {
|
|
37
37
|
padding: calc(var(--spacing) * 4);
|
|
38
38
|
border-radius: var(--radius-lg);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
@media (hover: hover) {
|
|
42
|
-
.
|
|
42
|
+
.sw_0m922:is(:where(.sw_card_nudp9):hover *) {
|
|
43
43
|
color: var(--color-blue-600);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -59,7 +59,7 @@ The final colon is optional.
|
|
|
59
59
|
|
|
60
60
|
## Where to write it
|
|
61
61
|
|
|
62
|
-
Write the condition as a computed key of an object in [`style()`](
|
|
62
|
+
Write the condition as a computed key of an object in [`style()`](https://stillwind.dev/docs/macros/style):
|
|
63
63
|
|
|
64
64
|
```ts
|
|
65
65
|
style({ [card("hover")]: "text-blue-600" });
|
|
@@ -72,15 +72,16 @@ You can also write it as a variant segment inside a utility template, followed b
|
|
|
72
72
|
style(`${card("hover")}:text-blue-600`);
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
To use the same condition in several places, store it with
|
|
76
|
+
[`style.when()`](https://stillwind.dev/docs/macros/when).
|
|
76
77
|
|
|
77
78
|
## Behavior
|
|
78
79
|
|
|
79
80
|
The ref element must be an ancestor of the styled element. To match a sibling or
|
|
80
|
-
another element inside a shared ancestor, add [`.in()`](in
|
|
81
|
+
another element inside a shared ancestor, add [`.in()`](https://stillwind.dev/docs/macros/ref/in).
|
|
81
82
|
|
|
82
83
|
The condition only selects elements. It does not attach the ref, so attach it with
|
|
83
84
|
`style(card)` on the ancestor.
|
|
84
85
|
|
|
85
|
-
See [Element relationships](
|
|
86
|
+
See [Element relationships](https://stillwind.dev/docs/guides/element-relationships#react-to-a-parents-state)
|
|
86
87
|
for a task-based example.
|
package/docs/macros/ref/in.md
CHANGED
|
@@ -28,27 +28,27 @@ export const text = style({ [trigger("hover").in(card)]: "text-blue-600" });
|
|
|
28
28
|
```ts
|
|
29
29
|
const card = undefined;
|
|
30
30
|
const trigger = undefined;
|
|
31
|
-
export const container = {className:"
|
|
32
|
-
export const button = {className:"
|
|
33
|
-
export const text = {className:"
|
|
31
|
+
export const container = {className:"sw_dsyoo sw_card_nudp9"};
|
|
32
|
+
export const button = {className:"sw_zycpr sw_trigger_xnhw0"};
|
|
33
|
+
export const text = {className:"sw_hfcxb"};
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
### Generated CSS
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
```css
|
|
40
|
-
.
|
|
40
|
+
.sw_dsyoo {
|
|
41
41
|
padding: calc(var(--spacing) * 4);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.
|
|
44
|
+
.sw_zycpr {
|
|
45
45
|
padding-inline: calc(var(--spacing) * 4);
|
|
46
46
|
padding-block: calc(var(--spacing) * 2);
|
|
47
47
|
border-radius: var(--radius-md);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
@media (hover: hover) {
|
|
51
|
-
.
|
|
51
|
+
.sw_hfcxb:is(:where(.sw_card_nudp9):has(:where(.sw_trigger_xnhw0):hover) *) {
|
|
52
52
|
color: var(--color-blue-600);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -56,7 +56,7 @@ export const text = {className:"sw_yz349"};
|
|
|
56
56
|
|
|
57
57
|
## Inputs
|
|
58
58
|
|
|
59
|
-
The receiver is a [ref condition](condition
|
|
59
|
+
The receiver is a [ref condition](https://stillwind.dev/docs/macros/ref/condition), such as
|
|
60
60
|
`trigger("hover")` or `trigger()`. The argument is one of these:
|
|
61
61
|
|
|
62
62
|
| Argument | The scope element |
|
|
@@ -64,7 +64,7 @@ The receiver is a [ref condition](condition.md), such as
|
|
|
64
64
|
| `card` | Has the `card` ref |
|
|
65
65
|
| `card("focus-within")` | Has the `card` ref and matches the variants |
|
|
66
66
|
|
|
67
|
-
The argument cannot use `.in()` or [`.at()`](at
|
|
67
|
+
The argument cannot use `.in()` or [`.at()`](https://stillwind.dev/docs/macros/ref/at) itself.
|
|
68
68
|
|
|
69
69
|
## Behavior
|
|
70
70
|
|
|
@@ -74,8 +74,8 @@ styled element itself.
|
|
|
74
74
|
Calling `.in()` more than once adds each scope as another condition, and every
|
|
75
75
|
condition must match.
|
|
76
76
|
|
|
77
|
-
Write the whole chain directly as a computed key in [`style()`](
|
|
78
|
-
|
|
77
|
+
Write the whole chain directly as a computed key in [`style()`](https://stillwind.dev/docs/macros/style).
|
|
78
|
+
To use it in several places, store it with [`style.when()`](https://stillwind.dev/docs/macros/when).
|
|
79
79
|
|
|
80
|
-
See [Element relationships](
|
|
80
|
+
See [Element relationships](https://stillwind.dev/docs/guides/element-relationships#react-to-a-siblings-state)
|
|
81
81
|
for a task-based example.
|
package/docs/macros/ref/index.md
CHANGED
|
@@ -28,27 +28,27 @@ export const child = style({
|
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
30
|
const card = undefined;
|
|
31
|
-
export const container = {className:"
|
|
32
|
-
export const child = {className:"
|
|
31
|
+
export const container = {className:"sw_osnwd sw_card_nudp9"};
|
|
32
|
+
export const child = {className:"sw_duzby"};
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### Generated CSS
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
```css
|
|
39
|
-
.
|
|
40
|
-
container-name: sw-c-card-
|
|
39
|
+
.sw_osnwd:where(.sw_card_nudp9) {
|
|
40
|
+
container-name: sw-c-card-nudp9;
|
|
41
41
|
container-type: inline-size;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
@container sw-c-card-
|
|
45
|
-
.
|
|
44
|
+
@container sw-c-card-nudp9 (width >= 40rem) {
|
|
45
|
+
.sw_duzby {
|
|
46
46
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
@media (hover: hover) {
|
|
51
|
-
.
|
|
51
|
+
.sw_duzby:is(:where(.sw_card_nudp9):hover *) {
|
|
52
52
|
color: var(--color-blue-600);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -92,16 +92,17 @@ nearest one.
|
|
|
92
92
|
|
|
93
93
|
| Method | Where to write it | Effect |
|
|
94
94
|
| ---------------------------------------------------------- | ------------------------------------------ | ------------------------------------------------------ |
|
|
95
|
-
| `ref` | A [`style()`](
|
|
96
|
-
| [`ref()`](condition
|
|
97
|
-
| [`ref().in()`](in
|
|
98
|
-
| [`ref.at()`](at
|
|
99
|
-
| [`ref.asContainer()`](as-container
|
|
100
|
-
| [`ref.asAnchor()`](as-anchor
|
|
101
|
-
| [`ref.positionAnchor()`](position-anchor
|
|
95
|
+
| `ref` | A [`style()`](https://stillwind.dev/docs/macros/style) argument | Attaches the ref to the element |
|
|
96
|
+
| [`ref()`](https://stillwind.dev/docs/macros/ref/condition) | A computed key in `style()` | Matches inside the ref element, optionally in a state |
|
|
97
|
+
| [`ref().in()`](https://stillwind.dev/docs/macros/ref/in) | After a ref condition | Matches inside a shared ancestor, such as for siblings |
|
|
98
|
+
| [`ref.at()`](https://stillwind.dev/docs/macros/ref/at) | A computed key in `style()` | Matches a container query on the ref element |
|
|
99
|
+
| [`ref.asContainer()`](https://stillwind.dev/docs/macros/ref/as-container) | A `style()` argument | Makes the ref element a named container |
|
|
100
|
+
| [`ref.asAnchor()`](https://stillwind.dev/docs/macros/ref/as-anchor) | A `style()` argument | Makes the ref element a named anchor |
|
|
101
|
+
| [`ref.positionAnchor()`](https://stillwind.dev/docs/macros/ref/position-anchor) | A `style()` argument | Positions the styled element against the anchor |
|
|
102
102
|
|
|
103
103
|
Write each method call directly in `style()`. You cannot store the result of a
|
|
104
|
-
method call in a variable and use it later.
|
|
104
|
+
method call in a variable and use it later. To reuse a ref condition or a
|
|
105
|
+
container query, store it with [`style.when()`](https://stillwind.dev/docs/macros/when).
|
|
105
106
|
|
|
106
107
|
## Generated code
|
|
107
108
|
|
|
@@ -111,5 +112,5 @@ call chooses among several refs at runtime, the generated code keeps the fields
|
|
|
111
112
|
that the choice needs. The compiled code reads those fields directly. In
|
|
112
113
|
development, Stillwind checks them first. The code does not watch the DOM.
|
|
113
114
|
|
|
114
|
-
See [Element relationships](
|
|
115
|
+
See [Element relationships](https://stillwind.dev/docs/guides/element-relationships) for task-based
|
|
115
116
|
examples.
|
|
@@ -31,20 +31,20 @@ export const popover = style(
|
|
|
31
31
|
|
|
32
32
|
```ts
|
|
33
33
|
const trigger = undefined;
|
|
34
|
-
export const button = {className:"
|
|
35
|
-
export const popover = {className:"
|
|
34
|
+
export const button = {className:"sw_6x3gz sw_trigger_xnhw0"};
|
|
35
|
+
export const popover = {className:"sw_6gq48"};
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
### Generated CSS
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
```css
|
|
42
|
-
.
|
|
43
|
-
anchor-name: --sw-a-trigger-
|
|
42
|
+
.sw_6x3gz:where(.sw_trigger_xnhw0) {
|
|
43
|
+
anchor-name: --sw-a-trigger-xnhw0;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
.
|
|
47
|
-
position-anchor: --sw-a-trigger-
|
|
46
|
+
.sw_6gq48 {
|
|
47
|
+
position-anchor: --sw-a-trigger-xnhw0;
|
|
48
48
|
position: absolute;
|
|
49
49
|
top: anchor(bottom);
|
|
50
50
|
left: anchor(left);
|
|
@@ -58,10 +58,10 @@ export const popover = {className:"sw_fu7et"};
|
|
|
58
58
|
## Behavior
|
|
59
59
|
|
|
60
60
|
The styled element does not need the `trigger` ref. The anchor element needs it,
|
|
61
|
-
together with [`trigger.asAnchor()`](as-anchor
|
|
61
|
+
together with [`trigger.asAnchor()`](https://stillwind.dev/docs/macros/ref/as-anchor).
|
|
62
62
|
|
|
63
|
-
Write the call directly in [`style()`](
|
|
63
|
+
Write the call directly in [`style()`](https://stillwind.dev/docs/macros/style). You cannot store it
|
|
64
64
|
in a variable and use it later.
|
|
65
65
|
|
|
66
|
-
See [Element relationships](
|
|
66
|
+
See [Element relationships](https://stillwind.dev/docs/guides/element-relationships#position-an-element-at-an-anchor)
|
|
67
67
|
for a complete example with an anchor scope.
|