Skip to content

Commit 104b290

Browse files
author
Damien Carrier
committed
Add default value to controller.ts and fix doc reviews
1 parent 6f2810c commit 104b290

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

src/TogglePassword/assets/src/controller.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export default class extends Controller<HTMLInputElement> {
1919
declare readonly buttonClassesValue: Array<string>;
2020

2121
static values = {
22-
visibleLabel: String,
23-
visibleIcon: String,
24-
hiddenLabel: String,
25-
hiddenIcon: String,
22+
visibleLabel: { type: String, default: 'Show' },
23+
visibleIcon: { type: String, default: 'Default' },
24+
hiddenLabel: { type: String, default: 'Hide' },
25+
hiddenIcon: { type: String, default: 'Default' },
2626
buttonClasses: Array,
2727
};
2828

src/TogglePassword/doc/index.rst

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -262,29 +262,23 @@ Then in your form, add your controller as an HTML attribute::
262262
Usage without Symfony Forms
263263
---------------------------
264264

265-
You can also use the TogglePassword with native HTML inputs.
266-
It requires a little bit more work but it's still possible.
267-
Here is an example::
265+
You can also use the TogglePassword with native HTML inputs:
266+
267+
.. code-block:: html+twig
268268

269269
// ...
270270

271-
<label for="password">Password</label>
272-
<input
273-
id="password"
274-
name="password"
275-
type="password"
276-
autocomplete="current-password"
277-
required
278-
placeholder="Password"
279-
{{ stimulus_controller('@symfony/ux-toggle-password--toggle-password', {
280-
visibleIcon: 'Default', // Here you can pass an SVG tag or a string. Default is the value for the default svg
281-
visibleLabel: 'Show', // This field is optional
282-
hiddenIcon: 'Default', // Here you can pass an SVG tag or a string. Default is the value for the default svg
283-
hiddenLabel: 'Hide', // This field is optional
284-
buttonClasses: ['toggle-password-button'], // Here you can add as many classes as you wish. You will need at least to add the "toggle-password-button" class
285-
}
286-
) }}
287-
>
271+
<div class="toggle-password-container"> // Add "toggle-password-container" or a class that applies position: relative to this container.
272+
<label for="password">Password</label>
273+
<input
274+
id="password"
275+
name="password"
276+
type="password"
277+
{{ stimulus_controller('symfony/ux-toggle-password/toggle-password', {
278+
buttonClasses: ['toggle-password-button'], // Add as many classes as you wish. "toggle-password-button" is needed to activate the default CSS.
279+
}) }}
280+
>
281+
</div>
288282

289283
// ...
290284

0 commit comments

Comments
 (0)