Skip to content

Commit 12c6d01

Browse files
committed
feat: Add props for the icon labels
FIXES #26
1 parent 23e5b37 commit 12c6d01

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ Interactive password strength meter based on [zxcvbn](https://github.com/dropbox
7474
### With custom input
7575

7676
```html
77-
7877
<template>
7978
<div>
8079
<input type="password" v-model="password">
@@ -113,6 +112,8 @@ Interactive password strength meter based on [zxcvbn](https://github.com/dropbox
113112
| strengthMeterFillClass | String | Password__strength-meter--fill | strength-meter class for individual data fills |
114113
| showStrengthMeter | Boolean | true | Hide the Strength Meter if you want to implement your own |
115114
| strengthMeterOnly | Boolean | false | Hides the built-in input if you want to implement your own |
115+
| labelHide | String | 'Hide Password' | Label for the hide icon
116+
| labelShow | String | 'Show Password' | Label for the show icon
116117

117118
## Events
118119

src/components/PasswordStrengthMeter.vue

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="Password">
33
<div
4-
v-if="!strengthMeterOnly"
4+
v-if="!strengthMeterOnly"
55
class="Password__group"
66
>
77
<input
@@ -34,11 +34,11 @@
3434
:aria-label="showPasswordLabel"
3535
@click.prevent="togglePassword()">
3636
<svg v-if="this.$data._showPassword" version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
37-
<title>Hide Password</title>
37+
<title>{{showPasswordLabel}}</title>
3838
<path d="M12 9c1.641 0 3 1.359 3 3s-1.359 3-3 3-3-1.359-3-3 1.359-3 3-3zM12 17.016c2.766 0 5.016-2.25 5.016-5.016s-2.25-5.016-5.016-5.016-5.016 2.25-5.016 5.016 2.25 5.016 5.016 5.016zM12 4.5c5.016 0 9.281 3.094 11.016 7.5-1.734 4.406-6 7.5-11.016 7.5s-9.281-3.094-11.016-7.5c1.734-4.406 6-7.5 11.016-7.5z"></path>
3939
</svg>
4040
<svg v-else version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
41-
<title>Show Password</title>
41+
<title>{{showPasswordLabel}}</title>
4242
<path d="M11.859 9h0.141c1.641 0 3 1.359 3 3v0.188zM7.547 9.797c-0.328 0.656-0.563 1.406-0.563 2.203 0 2.766 2.25 5.016 5.016 5.016 0.797 0 1.547-0.234 2.203-0.563l-1.547-1.547c-0.188 0.047-0.422 0.094-0.656 0.094-1.641 0-3-1.359-3-3 0-0.234 0.047-0.469 0.094-0.656zM2.016 4.266l1.266-1.266 17.719 17.719-1.266 1.266c-1.124-1.11-2.256-2.213-3.375-3.328-1.359 0.563-2.813 0.844-4.359 0.844-5.016 0-9.281-3.094-11.016-7.5 0.797-1.969 2.109-3.656 3.75-4.969-0.914-0.914-1.812-1.844-2.719-2.766zM12 6.984c-0.656 0-1.266 0.141-1.828 0.375l-2.156-2.156c1.219-0.469 2.578-0.703 3.984-0.703 5.016 0 9.234 3.094 10.969 7.5-0.75 1.875-1.922 3.469-3.422 4.734l-2.906-2.906c0.234-0.563 0.375-1.172 0.375-1.828 0-2.766-2.25-5.016-5.016-5.016z"></path>
4343
</svg>
4444
</button>
@@ -225,6 +225,20 @@
225225
strengthMeterFillClass: {
226226
type: String,
227227
default: 'Password__strength-meter--fill'
228+
},
229+
/**
230+
* Label for the show password icon
231+
*/
232+
labelShow: {
233+
type: String,
234+
default: 'Show Password'
235+
},
236+
/**
237+
* Label for the hide password icon
238+
*/
239+
labelHide: {
240+
type: String,
241+
default: 'Hide Password'
228242
}
229243
},
230244
data () {
@@ -294,7 +308,7 @@
294308
},
295309
296310
showPasswordLabel () {
297-
return this.$data._showPassword || this.showPassword ? 'Hide password' : 'Show password'
311+
return this.$data._showPassword || this.showPassword ? this.labelHide : this.labelShow
298312
}
299313
},
300314

0 commit comments

Comments
 (0)