Consolidate zxcvbn progress bars into a component and add dynamic colour
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
8a9502a8cb
commit
09a4af49f3
7 changed files with 89 additions and 25 deletions
|
@ -29,6 +29,7 @@ import SdkConfig from '../../../SdkConfig';
|
|||
import { SAFE_LOCALPART_REGEX } from '../../../Registration';
|
||||
import withValidation from '../elements/Validation';
|
||||
import {ValidatedServerConfig} from "../../../utils/AutoDiscoveryUtils";
|
||||
import ZxcvbnProgressBar from "../elements/ZxcvbnProgressBar";
|
||||
|
||||
const FIELD_EMAIL = 'field_email';
|
||||
const FIELD_PHONE_NUMBER = 'field_phone_number';
|
||||
|
@ -274,11 +275,7 @@ export default createReactClass({
|
|||
description: function() {
|
||||
const complexity = this.state.passwordComplexity;
|
||||
const score = complexity ? complexity.score : 0;
|
||||
return <progress
|
||||
className="mx_AuthBody_passwordScore"
|
||||
max={PASSWORD_MIN_SCORE}
|
||||
value={score}
|
||||
/>;
|
||||
return <ZxcvbnProgressBar value={score} className="mx_AuthBody_passwordScore" />;
|
||||
},
|
||||
rules: [
|
||||
{
|
||||
|
|
30
src/components/views/elements/ZxcvbnProgressBar.tsx
Normal file
30
src/components/views/elements/ZxcvbnProgressBar.tsx
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import classNames from "classnames";
|
||||
|
||||
interface IProps {
|
||||
value: 0 | 1 | 2 | 3 | 4;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const ZxcvbnProgressBar: React.FC<IProps> = ({value, className}) => {
|
||||
const classes = classNames("mx_ZxcvbnProgressBar", className);
|
||||
return <progress className={classes} max={4} value={value} />;
|
||||
};
|
||||
|
||||
export default ZxcvbnProgressBar;
|
Loading…
Add table
Add a link
Reference in a new issue