Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 098f445

Browse files
Add textual button to show/hide credentials in credentials dialog
1 parent 6e07816 commit 098f445

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

lib/views/credential-dialog.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ export default class CredentialDialog extends React.Component {
2323

2424
constructor(props, context) {
2525
super(props, context);
26-
autobind(this, 'confirm', 'cancel', 'onUsernameChange', 'onPasswordChange', 'onRememberChange', 'focusFirstInput');
26+
autobind(this, 'confirm', 'cancel', 'onUsernameChange', 'onPasswordChange', 'onRememberChange',
27+
'focusFirstInput', 'toggleShowPassword');
2728

2829
this.state = {
2930
username: '',
3031
password: '',
3132
remember: false,
33+
showPassword: false,
3234
};
3335
}
3436

@@ -61,13 +63,16 @@ export default class CredentialDialog extends React.Component {
6163
<label className="github-DialogLabel">
6264
Password:
6365
<input
64-
type="password"
66+
type={this.state.showPassword ? 'text' : 'password'}
6567
ref={e => (this.passwordInput = e)}
6668
className="input-text github-CredentialDialog-Password"
6769
value={this.state.password}
6870
onChange={this.onPasswordChange}
6971
tabIndex="2"
7072
/>
73+
<button className="github-DialogLabelButton" onClick={this.toggleShowPassword}>
74+
{this.state.showPassword ? 'Hide' : 'Show'}
75+
</button>
7176
</label>
7277
</main>
7378
<footer className="github-DialogButtons">
@@ -122,4 +127,8 @@ export default class CredentialDialog extends React.Component {
122127
focusFirstInput() {
123128
(this.usernameInput || this.passwordInput).focus();
124129
}
130+
131+
toggleShowPassword() {
132+
this.setState({showPassword: !this.state.showPassword});
133+
}
125134
}

styles/dialog.less

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,22 @@
1919
&Label {
2020
flex: 1;
2121
margin: @github-dialog-spacing;
22+
position: relative;
2223
line-height: 2;
24+
25+
&Button {
26+
position: absolute;
27+
background: transparent;
28+
right: .2em;
29+
bottom: 0;
30+
border: none;
31+
color: #000;
32+
cursor: pointer;
33+
34+
&:hover {
35+
color: #888;
36+
}
37+
}
2338
}
2439

2540
&Buttons {

0 commit comments

Comments
 (0)