Skip to content

Commit e7d8911

Browse files
committed
[Typed] Deprecate the package
1 parent 1d64fb3 commit e7d8911

File tree

5 files changed

+122
-0
lines changed

5 files changed

+122
-0
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: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,111 @@
11
# Symfony UX Typed
22

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

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
*/

0 commit comments

Comments
 (0)