Skip to content

Commit d1d82de

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

18 files changed

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

assets/login.js

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

0 commit comments

Comments
 (0)