PasswordStrength.tsx 744 B

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