Skip to content

Commit 03c3f9b

Browse files
committed
feature #2814 [Swup] Deprecate the package (Kocal)
This PR was merged into the 2.x branch. Discussion ---------- [Swup] Deprecate the package | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | Docs? | no <!-- required for new features --> | Issues | Fix #2733 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Update/add documentation as required (we can help!) - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Made In Cursor™ 🤓 Commits ------- 475da05 [Swup] Deprecate the package
2 parents 95cc203 + 475da05 commit 03c3f9b

File tree

6 files changed

+125
-0
lines changed

6 files changed

+125
-0
lines changed

src/Swup/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 2.27.0
4+
5+
- Deprecate the package
6+
37
## 2.13.2
48

59
- Revert "Change JavaScript package to `type: module`"

src/Swup/README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,113 @@
11
# Symfony UX Swup
22

3+
> [!WARNING]
4+
> **Deprecated**: This package has been **deprecated** in 2.x and will be removed in the next major version.
5+
6+
We
7+
To keep the same functionality in your Symfony application, follow these migration steps:
8+
9+
1. Install the `swup` library and its plugins:
10+
11+
```bash
12+
# If using Symfony AssetMapper:
13+
php bin/console importmap:require swup @swup/fade-theme @swup/slide-theme @swup/forms-plugin @swup/debug-plugin
14+
15+
# If using NPM (e.g.: with Webpack Encore):
16+
npm install swup @swup/fade-theme @swup/slide-theme @swup/forms-plugin @swup/debug-plugin
17+
```
18+
19+
2. Add the following code to your app:
20+
21+
<details><summary><code>assets/controllers/swup_controller.js</code></summary>
22+
23+
```javascript
24+
import { Controller } from '@hotwired/stimulus';
25+
import Swup from 'swup';
26+
import SwupFadeTheme from '@swup/fade-theme';
27+
import SwupSlideTheme from '@swup/slide-theme';
28+
import SwupFormsPlugin from '@swup/forms-plugin';
29+
import SwupDebugPlugin from '@swup/debug-plugin';
30+
31+
export default class extends Controller {
32+
static values = {
33+
containers: Array,
34+
mainElement: String,
35+
animateHistoryBrowsing: Boolean,
36+
animationSelector: String,
37+
cache: Boolean,
38+
linkSelector: String,
39+
theme: String,
40+
debug: Boolean,
41+
};
42+
43+
connect() {
44+
const dataContainers = this.containersValue;
45+
const mainElement = this.mainElementValue || dataContainers[0] || '#swup';
46+
const allElements = [mainElement].concat(dataContainers);
47+
const containersList = allElements.filter((item, index) => {
48+
return allElements.indexOf(item) === index;
49+
});
50+
51+
const options = {
52+
containers: containersList,
53+
plugins: [
54+
'slide' === this.themeValue
55+
? new SwupSlideTheme({ mainElement: mainElement })
56+
: new SwupFadeTheme({ mainElement: mainElement }),
57+
new SwupFormsPlugin(),
58+
],
59+
};
60+
61+
if (this.hasMainElementValue) {
62+
options.mainElement = this.mainElementValue;
63+
}
64+
65+
if (this.hasAnimateHistoryBrowsingValue) {
66+
options.animateHistoryBrowsing = this.animateHistoryBrowsingValue;
67+
}
68+
if (this.hasAnimationSelectorValue) {
69+
options.animationSelector = this.animationSelectorValue;
70+
}
71+
if (this.hasCacheValue) {
72+
options.cache = this.cacheValue;
73+
}
74+
if (this.hasLinkSelectorValue) {
75+
options.linkSelector = this.linkSelectorValue;
76+
}
77+
if (this.debugValue) {
78+
options.plugins.push(new SwupDebugPlugin());
79+
}
80+
81+
this.dispatchEvent('pre-connect', { options });
82+
const swup = new Swup(options);
83+
this.dispatchEvent('connect', { swup, options });
84+
}
85+
86+
dispatchEvent(name, payload) {
87+
this.dispatch(name, { detail: payload, prefix: 'swup' });
88+
}
89+
}
90+
```
91+
92+
</details>
93+
94+
3. Replace the `symfony--ux-swup` occurrences in your templates with `swup`, for example:
95+
96+
```diff
97+
-<body {{ stimulus_controller('symfony/ux-swup/swup') }}>
98+
+<body {{ stimulus_controller('swup') }}>
99+
```
100+
101+
4. Remove `symfony/ux-swup` from your dependencies:
102+
103+
```bash
104+
composer remove symfony/ux-swup
105+
```
106+
107+
You're done!
108+
109+
---
110+
3111
Symfony UX Swup is a Symfony bundle integrating [Swup](https://swup.js.org/) in
4112
Symfony applications. It is part of [the Symfony UX initiative](https://ux.symfony.com/).
5113

src/Swup/doc/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Symfony UX Swup
22
===============
33

4+
.. warning::
5+
6+
**Deprecated: This package has been deprecated in 2.x and will be removed in the next major version.**
7+
8+
To keep the same functionality in your Symfony application, please follow the migration steps
9+
from the `Symfony UX Swup README.md`_.
10+
411
Symfony UX Swup is a Symfony bundle integrating `Swup`_ in
512
Symfony applications. It is part of `the Symfony UX initiative`_.
613

@@ -207,3 +214,4 @@ https://symfony.com/doc/current/contributing/code/bc.html
207214
.. _`Swup Options`: https://swup.js.org/options
208215
.. _StimulusBundle configured in your app: https://symfony.com/bundles/StimulusBundle/current/index.html
209216
.. _`@symfony/ux-swup npm package`: https://www.npmjs.com/package/@symfony/ux-swup
217+
.. _`Symfony UX Swup README.md`: https://github.com/symfony/ux/tree/2.x/src/Swup/README.md

src/Swup/src/DependencyInjection/SwupExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
1717
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
1818

19+
trigger_deprecation('symfony/ux-swup', '2.27.0', 'The package is deprecated and will be removed in 3.0. Follow the migration steps in https://github.com/symfony/ux/tree/2.x/src/Swup to keep using Swup in your Symfony application.');
20+
1921
/**
2022
* @internal
2123
*/

src/Swup/src/SwupBundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use Symfony\Component\HttpKernel\Bundle\Bundle;
1515

16+
trigger_deprecation('symfony/ux-swup', '2.27.0', 'The package is deprecated and will be removed in 3.0. Follow the migration steps in https://github.com/symfony/ux/tree/2.x/src/Swup to keep using Swup in your Symfony application.');
17+
1618
/**
1719
* @final
1820
*/

ux.symfony.com/tests/baseline-ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
%Since symfony/ux-typed 2\.27\.0: The package is deprecated and will be removed in 3\.0\.%
22
%Since symfony/ux-lazy-image 2\.27\.0: The package is deprecated and will be removed in 3\.0\.%
3+
%Since symfony/ux-swup 2\.27\.0: The package is deprecated and will be removed in 3\.0\.%

0 commit comments

Comments
 (0)