-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathpassword-meter.vue
65 lines (55 loc) · 1.19 KB
/
password-meter.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<script lang="ts">
import { checkStrength, scorePassword } from './logic'
export default {
name: 'PasswordMeter',
props: {
password: String
},
emits: ['score'],
computed: {
passwordClass(): object | null {
if (!this.password) {
return null
}
const strength = checkStrength(this.password)
const score = scorePassword(this.password)
this.$emit('score', { score, strength })
return {
[strength]: true,
scored: true
}
}
}
}
</script>
<template>
<div class="po-password-strength-bar" :class="passwordClass" />
</template>
<style>
.po-password-strength-bar {
border-radius: 2px;
transition: all 0.2s linear;
height: 5px;
margin-top: 8px;
}
.po-password-strength-bar.risky {
background-color: #f95e68;
width: 10%;
}
.po-password-strength-bar.guessable {
background-color: #fb964d;
width: 32.5%;
}
.po-password-strength-bar.weak {
background-color: #fdd244;
width: 55%;
}
.po-password-strength-bar.safe {
background-color: #b0dc53;
width: 77.5%;
}
.po-password-strength-bar.secure {
background-color: #35cc62;
width: 100%;
}
</style>