Skip to content

Commit 5fd2045

Browse files
committed
using stimulus_controller() everywhere
1 parent 57e0217 commit 5fd2045

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/LazyImage/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ page has been rendered:
3434
```twig
3535
<img
3636
src="{{ asset('image/small.png') }}"
37-
data-controller="symfony--ux-lazy-image--lazy-image"
37+
{{ stimulus_controller('symfony/ux-lazy-image/lazy-image') }}
3838
data-hd-src="{{ asset('image/large.png') }}"
3939
4040
{# Optional but avoids having a page jump when the image is loaded #}
@@ -43,13 +43,16 @@ page has been rendered:
4343
/>
4444
```
4545

46+
**Note** The `stimulus_controller()` function comes from
47+
[WebpackEncoreBundle v1.10](https://github.com/symfony/webpack-encore-bundle).
48+
4649
Instead of using a generated thumbnail that would exist on your filesystem, you can use
4750
the BlurHash algorithm to create a light, blurred, data-uri thumbnail of the image:
4851

4952
```twig
5053
<img
5154
src="{{ data_uri_thumbnail('public/image/large.png', 100, 75) }}"
52-
data-controller="symfony--ux-lazy-image--lazy-image"
55+
{{ stimulus_controller('symfony/ux-lazy-image/lazy-image') }}
5356
data-hd-src="{{ asset('image/large.png') }}"
5457
5558
{# Using BlurHash, the size is required #}
@@ -104,7 +107,10 @@ Then in your template, add your controller to the HTML attribute:
104107
```twig
105108
<img
106109
src="{{ data_uri_thumbnail('public/image/large.png', 100, 75) }}"
107-
data-controller="mylazyimage symfony--ux-lazy-image--lazy-image"
110+
{{ stimulus_controller({
111+
mylazyimage: {},
112+
'symfony/ux-lazy-image/lazy-image: {}
113+
}) }}
108114
data-hd-src="{{ asset('image/large.png') }}"
109115
110116
{# Using BlurHash, the size is required #}

src/Swup/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The main usage of Symfony UX Swup is to use its Stimulus controller to initializ
3939
<head>
4040
<title>Swup</title>
4141
</head>
42-
<body data-controller="symfony--ux-swup--swup">
42+
<body {{ stimulus_controller('symfony/ux-swup/swup') }}>
4343
{# ... #}
4444
4545
<main id="swup">
@@ -53,6 +53,9 @@ The main usage of Symfony UX Swup is to use its Stimulus controller to initializ
5353
</html>
5454
```
5555

56+
**Note** The `stimulus_controller()` function comes from
57+
[WebpackEncoreBundle v1.10](https://github.com/symfony/webpack-encore-bundle).
58+
5659
That's it! Swup now reacts to a link click and run the default fade-in transition.
5760

5861
By default, Swup will use the `#swup` selector as a container, meaning it will only swap
@@ -65,7 +68,7 @@ additional containers, for instance to have a navigation menu that updates when
6568
<title>Swup</title>
6669
</head>
6770
<body
68-
data-controller="symfony--ux-swup--swup"
71+
{{ stimulus_controller('symfony/ux-swup/swup') }}
6972
data-containers="#swup #nav" {# list of selectors separated by spaces #}
7073
>
7174
{# ... #}
@@ -93,7 +96,7 @@ You can configure several other options using data-attributes on the `body` tag:
9396
<title>Swup</title>
9497
</head>
9598
<body
96-
data-controller="symfony--ux-swup--swup"
99+
{{ stimulus_controller('symfony/ux-swup/swup') }}
97100
data-containers="#swup #nav"
98101
data-theme="slide" {# or "fade", the default #}
99102
data-debug="data-debug" {# add this attribute to enable debug #}
@@ -139,7 +142,10 @@ Then in your template, add your controller to the HTML attribute:
139142
<head>
140143
<title>Swup</title>
141144
</head>
142-
<body data-controller="myswup symfony--ux-swup--swup">
145+
<body {{ stimulus_controller({
146+
myswup: {},
147+
'symfony/ux-swup/swup: {}
148+
})>
143149
{# ... #}
144150
</body>
145151
</html>

0 commit comments

Comments
 (0)