forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Implement password eye icon for reset password screen (#553)
Co-authored-by: Anas Hameed <[email protected]>
- Loading branch information
1 parent
d27a93b
commit 9fa09ef
Showing
1 changed file
with
46 additions
and
17 deletions.
There are no files selected for viewing
63 changes: 46 additions & 17 deletions
63
lms/static/js/student_account/components/PasswordResetInput.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |