Skip to content

Commit c160eae

Browse files
committed
feature #2809 [Typed] Deprecate the package (Kocal)
This PR was merged into the 2.x branch. Discussion ---------- [Typed] 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 #2740 <!-- 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). --> Let's use this package as a reference, for the next packages deprecation PRs. Commits ------- 8e96fce [Typed] Deprecate the package
2 parents 1d64fb3 + 8e96fce commit c160eae

File tree

8 files changed

+138
-1
lines changed

8 files changed

+138
-1
lines changed

src/Typed/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/Typed/README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,121 @@
11
# Symfony UX Typed
22

3+
> [!WARNING]
4+
> **Deprecated**: This package has been **deprecated** in 2.x and will be removed in the next major version.
5+
6+
To keep the same functionality in your Symfony application, follow these migration steps:
7+
8+
1. Install the `typed.js` library:
9+
10+
```bash
11+
# If using Symfony AssetMapper:
12+
php bin/console importmap:require typed.js
13+
14+
# If using NPM (e.g.: with Webpack Encore):
15+
npm install typed.js
16+
```
17+
18+
2. Add the following code to your app:
19+
20+
<details><summary><code>assets/controllers/typed_controller.js</code></summary>
21+
22+
```javascript
23+
import { Controller } from '@hotwired/stimulus';
24+
import Typed from 'typed.js';
25+
26+
export default class extends Controller {
27+
static values = {
28+
strings: Array,
29+
typeSpeed: { type: Number, default: 30 },
30+
smartBackspace: { type: Boolean, default: true },
31+
startDelay: Number,
32+
backSpeed: Number,
33+
shuffle: Boolean,
34+
backDelay: { type: Number, default: 700 },
35+
fadeOut: Boolean,
36+
fadeOutClass: { type: String, default: 'typed-fade-out' },
37+
fadeOutDelay: { type: Number, default: 500 },
38+
loop: Boolean,
39+
loopCount: { type: Number, default: Number.POSITIVE_INFINITY },
40+
showCursor: { type: Boolean, default: true },
41+
cursorChar: { type: String, default: '.' },
42+
autoInsertCss: { type: Boolean, default: true },
43+
attr: String,
44+
bindInputFocusEvents: Boolean,
45+
contentType: { type: String, default: 'html' },
46+
};
47+
48+
connect() {
49+
const options = {
50+
strings: this.stringsValue,
51+
typeSpeed: this.typeSpeedValue,
52+
smartBackspace: this.smartBackspaceValue,
53+
startDelay: this.startDelayValue,
54+
backSpeed: this.backSpeedValue,
55+
shuffle: this.shuffleValue,
56+
backDelay: this.backDelayValue,
57+
fadeOut: this.fadeOutValue,
58+
fadeOutClass: this.fadeOutClassValue,
59+
fadeOutDelay: this.fadeOutDelayValue,
60+
loop: this.loopValue,
61+
loopCount: this.loopCountValue,
62+
showCursor: this.showCursorValue,
63+
cursorChar: this.cursorCharValue,
64+
autoInsertCss: this.autoInsertCssValue,
65+
attr: this.attrValue,
66+
bindInputFocusEvents: this.bindInputFocusEventsValue,
67+
contentType: this.contentTypeValue,
68+
};
69+
70+
this.dispatchEvent('pre-connect', { options });
71+
const typed = new Typed(this.element, options);
72+
this.dispatchEvent('connect', { typed, options });
73+
}
74+
75+
dispatchEvent(name, payload) {
76+
this.dispatch(name, { detail: payload, prefix: 'typed' });
77+
}
78+
}
79+
```
80+
81+
</details>
82+
83+
3. Replace the `symfony--ux-typed` occurrences in your templates with `typed`, for example:
84+
85+
```diff
86+
{% set strings = [
87+
'I ❤️ Symfony UX!',
88+
'Symfony UX Typed loves to type',
89+
'Symfony UX Typed and backspace',
90+
'Control the speed',
91+
'Control the cursor',
92+
'Control your destiny!!!',
93+
'Control your destiny... sort of',
94+
] %}
95+
<span
96+
- data-controller="symfony--ux-typed"
97+
- data-symfony--ux-typed-loop-value="true"
98+
- data-symfony--ux-typed-show-cursor-value="true"
99+
- data-symfony--ux-typed-cursor-char-value="✨"
100+
- data-symfony--ux-typed-strings-value="{{ strings|json_encode|e('html_attr') }}"
101+
+ data-controller="typed"
102+
+ data-typed-loop-value="true"
103+
+ data-typed-show-cursor-value="true"
104+
+ data-typed-cursor-char-value="✨"
105+
+ data-typed-strings-value="{{ strings|json_encode|e('html_attr') }}"
106+
></span>
107+
```
108+
109+
4. Remove `symfony/ux-typed` from your dependencies:
110+
111+
```bash
112+
composer remove symfony/ux-typed
113+
```
114+
115+
You're done!
116+
117+
---
118+
3119
Symfony UX Typed is a Symfony bundle integrating [Typed](https://github.com/mattboldt/typed.js/blob/master/README.md) in
4120
Symfony applications. It is part of [the Symfony UX initiative](https://ux.symfony.com/).
5121

src/Typed/composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
"Symfony\\UX\\Typed\\": "src/"
2323
}
2424
},
25+
"require": {
26+
"php": ">=8.1",
27+
"symfony/deprecation-contracts": "^2.5|^3"
28+
},
2529
"conflict": {
2630
"symfony/flex": "<1.13"
2731
},

src/Typed/doc/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Symfony UX Typed
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 Typed README.md`_.
10+
411
Symfony UX Typed is a Symfony bundle integrating `Typed`_ in
512
Symfony applications. It is part of `the Symfony UX initiative`_.
613

@@ -156,3 +163,4 @@ https://symfony.com/doc/current/contributing/code/bc.html
156163
.. _`typed library`: https://github.com/mattboldt/typed.js/blob/master/README.md
157164
.. _StimulusBundle configured in your app: https://symfony.com/bundles/StimulusBundle/current/index.html
158165
.. _`@symfony/ux-typed npm package`: https://www.npmjs.com/package/@symfony/ux-typed
166+
.. _`Symfony UX Typed README.md`: https://github.com/symfony/ux/tree/2.x/src/Typed

src/Typed/src/DependencyInjection/TypedExtension.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-typed', '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/Typed to keep using Typed in your Symfony application.');
20+
1921
/**
2022
* @internal
2123
*/

src/Typed/src/TypedBundle.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-typed', '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/Typed to keep using Typed in your Symfony application.');
17+
1618
/**
1719
* @final
1820
*/

ux.symfony.com/phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<server name="SHELL_VERBOSITY" value="-1" />
1616
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
1717
<server name="SYMFONY_PHPUNIT_VERSION" value="9.6" />
18-
<server name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0&amp;quiet[]=indirect"/>
18+
<server name="SYMFONY_DEPRECATIONS_HELPER" value="ignoreFile=./tests/baseline-ignore&amp;max[self]=0&amp;max[direct]=0&amp;quiet[]=indirect"/>
1919
</php>
2020

2121
<testsuites>

ux.symfony.com/tests/baseline-ignore

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

0 commit comments

Comments
 (0)