Skip to content

Commit 34a981f

Browse files
Antoine Makdessijaviereguiluz
Antoine Makdessi
authored andcommitted
Add a basic Symfony Stimulus demo
1 parent 77a47d3 commit 34a981f

35 files changed

+103
-9708
lines changed
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// A Stimulus JavaScript controller file
2+
// https://stimulus.hotwired.dev
3+
// @see templates/security/login.html.twig
4+
// More info on Symfony UX https://ux.symfony.com
5+
6+
import { Controller } from '@hotwired/stimulus';
7+
8+
/*
9+
* The following line makes this controller "lazy": it won't be downloaded until needed
10+
* See https://github.com/symfony/stimulus-bridge#lazy-controllers
11+
*/
12+
/* stimulusFetch: 'lazy' */
13+
export default class extends Controller {
14+
static targets = ['username', 'password']
15+
16+
// /!\ in a real application, the user/password should never be hardcoded /!\
17+
// but for the demo application, it's very convenient to do so
18+
19+
prefillJohnUser() {
20+
this.usernameTarget.value = 'john_user'
21+
this.passwordTarget.value = 'kitten'
22+
}
23+
24+
prefillJaneAdmin() {
25+
this.usernameTarget.value = 'jane_admin'
26+
this.passwordTarget.value = 'kitten'
27+
}
28+
29+
togglePasswordInputType() {
30+
if ('password' === this.passwordTarget.type) {
31+
this.passwordTarget.type = 'text'
32+
} else {
33+
this.passwordTarget.type = 'password'
34+
}
35+
}
36+
}

assets/login.js

-11
This file was deleted.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"devDependencies": {
33
"@fortawesome/fontawesome-free": "^5.8.1",
4-
"@symfony/stimulus-bridge": "^2.0.0",
5-
"@symfony/webpack-encore": "^1.0.0",
4+
"@hotwired/stimulus": "^3.0",
5+
"@symfony/stimulus-bridge": "^3.0",
6+
"@symfony/webpack-encore": "^1.7",
67
"bloodhound-js": "^1.2.3",
78
"bootstrap-sass": "^3.3.7",
89
"bootstrap-tagsinput": "^0.7.1",

public/build/169.14a1c34e.css

-9
This file was deleted.

public/build/169.60ab0201.js

-1
This file was deleted.

public/build/31.ccf7320d.js

-1
This file was deleted.

public/build/755.5a8586e9.js

-2
This file was deleted.

public/build/755.5a8586e9.js.LICENSE.txt

-24
This file was deleted.

public/build/760.0135f78c.js

-1
This file was deleted.

public/build/919.46a4b8c3.js

-2
This file was deleted.

public/build/919.46a4b8c3.js.LICENSE.txt

-29
This file was deleted.

0 commit comments

Comments
 (0)