PasswordStrength.tsx 891 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import React from 'react';
  2. import { react2AngularDirective } from 'app/core/utils/react2angular';
  3. export interface IProps {
  4. password: string;
  5. }
  6. export class PasswordStrength extends React.Component<IProps, any> {
  7. constructor(props) {
  8. super(props);
  9. }
  10. render() {
  11. let strengthText = "strength: strong like a bull.";
  12. let strengthClass = "password-strength-good";
  13. if (this.props.password.length <= 8) {
  14. strengthText = "strength: you can do better.";
  15. strengthClass = "password-strength-ok";
  16. }
  17. if (this.props.password.length < 4) {
  18. strengthText = "strength: weak sauce.";
  19. strengthClass = "password-strength-bad";
  20. }
  21. return (
  22. <div className={`password-strength small ${strengthClass}`}>
  23. <em>{strengthText}</em>
  24. </div>
  25. );
  26. }
  27. }
  28. react2AngularDirective('passwordStrength', PasswordStrength, ['password']);