grafana/public/app/core/components/PasswordStrength.tsx

41 lines
806 B
TypeScript
Raw Normal View History

2017-09-28 03:37:33 -05:00
import React from 'react';
2017-09-21 06:32:57 -05:00
export interface IProps {
password: string;
}
export class PasswordStrength extends React.Component<IProps, any> {
constructor(props) {
super(props);
}
render() {
const { password } = this.props;
2017-09-21 06:32:57 -05:00
let strengthText = "strength: strong like a bull.";
let strengthClass = "password-strength-good";
if (!password) {
return null;
}
if (password.length <= 8) {
2017-09-21 06:32:57 -05:00
strengthText = "strength: you can do better.";
strengthClass = "password-strength-ok";
}
if (password.length < 4) {
strengthText = "strength: weak sauce.";
strengthClass = "password-strength-bad";
}
2017-09-21 06:32:57 -05:00
return (
<div className={`password-strength small ${strengthClass}`}>
<em>{strengthText}</em>
</div>
);
}
}
2017-09-28 03:37:33 -05:00