Skip to content

Commit

Permalink
Feat: Implement password eye icon for reset password screen (#553)
Browse files Browse the repository at this point in the history
Co-authored-by: Anas Hameed <[email protected]>
  • Loading branch information
Anas-hameed and Anas-hmeed authored Jul 3, 2024
1 parent d27a93b commit 9fa09ef
Showing 1 changed file with 46 additions and 17 deletions.
63 changes: 46 additions & 17 deletions lms/static/js/student_account/components/PasswordResetInput.jsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,56 @@
/* globals gettext */

import PropTypes from 'prop-types';
import React from 'react';
import PropTypes from "prop-types";
import React from "react";

import { InputText } from '@edx/paragon/static';
import { InputText } from "@edx/paragon/static";

function PasswordResetInput(props) {
return (
<div className="form-field">
<InputText
id={props.name}
type="password"
themes={['danger']}
dangerIconDescription={gettext('Error: ')}
required
{...props}
/>
</div>
);
class PasswordResetInput extends React.Component {
constructor(props) {
super(props);
this.state = {
inputType: "password",
};
this.setInputType = this.setInputType.bind(this);
}

setInputType() {
if (this.state.inputType === "password") {
this.setState({
inputType: "text",
});
} else {
this.setState({ inputType: "password" });
}
}

render() {
return (
<div className="form-field" style={{ position: "relative" }}>
<InputText
id={this.props.name}
type={this.state.inputType}
themes={["danger"]}
dangerIconDescription={gettext("Error: ")}
required
{...this.props}
/>
<span
style={{
position: "absolute",
right: "10px",
top: `${this.props.isValid ? "45%" : "35%"}`,
}}
onClick={this.setInputType}
className={`fa fa-fw field-icon ${this.state.inputType === "password" ? "fa-eye" : "fa-eye-slash"}`}
></span>
</div>
);
}
}

PasswordResetInput.propTypes = {
name: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
};

export default PasswordResetInput;

0 comments on commit 9fa09ef

Please sign in to comment.