Skip to content

Commit e666d49

Browse files
author
Antoine Makdessi
committed
Add a basic Symfony Stimulus demo
1 parent 77a47d3 commit e666d49

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

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

assets/login.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)