grafana/public/app/core/components/PasswordStrength.tsx
Tobias Skarhed 8a99fa269d WIP Update tslint (#12922)
* Interface linting rule

* fix: changed model names in store files so that the interface names do not conflict with the model names
2018-08-24 16:48:47 +02:00

38 lines
801 B
TypeScript

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