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

Commit fc34971

Browse files
author
Suguru Hirahara
committed
Refactor loginRequired.js with Aphrodite and commonForm
- textbox and textbox__outlineable were copied from textbox.js to commonStyles.js Since FormTextbox cannot be used for the input elements, I copied the styles applied for that element and applied to them. See: #7164 (comment) The labels and input forms were grouped and placed with display:flex and justify-content:space-between. Also the elements inside each wrapper were aligned equally to make the length of the input forms always equal (l10n friendly). Also colons in the label were removed to make the style consistent. Closes #8009 Addresses #8010 Auditors: Test Plan: 1. Visit http://browserspy.dk/password.php 2. Click "password-ok.php" link 3. Make sure you can log in successfully with the given credential 4. Change the lang setting on about:preferences 5. Try the same steps above and make sure the length of the input forms is equal
1 parent 715a1b6 commit fc34971

File tree

3 files changed

+97
-22
lines changed

3 files changed

+97
-22
lines changed

app/extensions/brave/locales/en-US/app.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ moreBookmarks=More bookmarks…
8080
fullScreenModeWarning={{host}} entered full screen mode, press ESC to exit.
8181
braveMenuTotalReplacements=Total Replacements: {{count}}
8282
basicAuthRequired=Authentication Required
83-
basicAuthUsernameLabel=Username:
84-
basicAuthPasswordLabel=Password:
83+
basicAuthUsernameLabel=Username
84+
basicAuthPasswordLabel=Password
8585
basicAuthMessage={{host}} requires a username and password.
8686
crashScreenHeader=Something went wrong =(
8787
crashScreenText=An error occurred while displaying this webpage. To continue, reload or navigate to another page.

app/renderer/components/styles/commonStyles.js

+14
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ const styles = StyleSheet.create({
2121
width: '100%'
2222
},
2323

24+
// Textbox -- copied from textbox.js
25+
textbox: {
26+
boxSizing: 'border-box',
27+
width: 'auto'
28+
},
29+
textbox__outlineable: {
30+
':focus': {
31+
outlineColor: globalStyles.color.statsBlue,
32+
outlineOffset: '-4px',
33+
outlineStyle: 'solid',
34+
outlineWidth: '1px'
35+
}
36+
},
37+
2438
// Dialogs
2539
flyoutDialog: {
2640
background: globalStyles.color.toolbarBackground,

js/components/loginRequired.js

+81-20
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ const appActions = require('../actions/appActions')
1010
const KeyCodes = require('../../app/common/constants/keyCodes')
1111
const urlResolve = require('url').resolve
1212

13+
const {
14+
CommonForm,
15+
CommonFormSection,
16+
CommonFormTitle,
17+
CommonFormButtonWrapper
18+
} = require('../../app/renderer/components/commonForm')
19+
20+
const {StyleSheet, css} = require('aphrodite/no-important')
21+
const globalStyles = require('../../app/renderer/components/styles/global')
22+
const commonStyles = require('../../app/renderer/components/styles/commonStyles')
23+
1324
class LoginRequired extends React.Component {
1425
constructor () {
1526
super()
@@ -74,31 +85,81 @@ class LoginRequired extends React.Component {
7485
host: urlResolve(this.detail.getIn(['request', 'url']), '/')
7586
}
7687
return <Dialog onHide={this.onClose} isClickDismiss>
77-
<div className='genericForm' onClick={this.onClick.bind(this)}>
78-
<h2 data-l10n-id='basicAuthRequired' />
79-
<div className='genericFormSubtitle' data-l10n-id='basicAuthMessage' data-l10n-args={JSON.stringify(l10nArgs)} />
80-
<div className='genericFormTable'>
81-
<div id='loginUsername' className='formRow'>
82-
<label data-l10n-id='basicAuthUsernameLabel' htmlFor='loginUsername' />
83-
<input spellCheck='false' onKeyDown={this.onKeyDown} onChange={this.onUsernameChange} value={this.state.username} ref={(loginUsername) => { this.loginUsername = loginUsername }} />
84-
</div>
85-
{
86-
!this.isFolder
87-
? <div id='loginPassword' className='formRow'>
88-
<label data-l10n-id='basicAuthPasswordLabel' htmlFor='loginPassword' />
89-
<input spellCheck='false' type='password' onKeyDown={this.onKeyDown} onChange={this.onPasswordChange} value={this.state.password} />
88+
<CommonForm onClick={this.onClick.bind(this)}>
89+
<CommonFormTitle data-l10n-id='basicAuthRequired' />
90+
<CommonFormSection data-l10n-id='basicAuthMessage' data-l10n-args={JSON.stringify(l10nArgs)} />
91+
<CommonFormSection>
92+
<div className={css(styles.sectionWrapper)}>
93+
<div data-test-id='loginLabel' className={css(styles.inputWrapper, styles.inputWrapper__label)}>
94+
<label data-l10n-id='basicAuthUsernameLabel' htmlFor='loginUsername' />
95+
<label className={css(styles.input__bottomRow)} data-l10n-id='basicAuthPasswordLabel' htmlFor='loginPassword' />
9096
</div>
91-
: null
92-
}
93-
<div className='formRow'>
94-
<Button l10nId='cancel' className='whiteButton' onClick={this.onClose} />
95-
<Button l10nId='ok' className='primaryButton' onClick={this.onSave.bind(this)} />
97+
{
98+
!this.isFolder
99+
? <div id='loginInput' className={css(styles.inputWrapper, styles.inputWrapper__input)}>
100+
<input className={css(
101+
commonStyles.formControl,
102+
commonStyles.textbox,
103+
commonStyles.textbox__outlineable,
104+
styles.input__box
105+
)}
106+
spellCheck='false'
107+
onKeyDown={this.onKeyDown}
108+
onChange={this.onUsernameChange}
109+
value={this.state.username}
110+
ref={(loginUsername) => { this.loginUsername = loginUsername }}
111+
/>
112+
<input className={css(
113+
commonStyles.formControl,
114+
commonStyles.textbox,
115+
commonStyles.textbox__outlineable,
116+
styles.input__box,
117+
styles.input__bottomRow
118+
)}
119+
spellCheck='false'
120+
type='password'
121+
onKeyDown={this.onKeyDown}
122+
onChange={this.onPasswordChange}
123+
value={this.state.password}
124+
/>
125+
</div>
126+
: null
127+
}
96128
</div>
97-
</div>
98-
</div>
129+
</CommonFormSection>
130+
<CommonFormButtonWrapper>
131+
<Button l10nId='cancel' className='whiteButton' onClick={this.onClose} />
132+
<Button l10nId='ok' className='primaryButton' onClick={this.onSave.bind(this)} />
133+
</CommonFormButtonWrapper>
134+
</CommonForm>
99135
</Dialog>
100136
}
101137
}
102138

103139
LoginRequired.propTypes = { frameProps: PropTypes.object }
140+
141+
const styles = StyleSheet.create({
142+
sectionWrapper: {
143+
display: 'flex',
144+
justifyContent: 'space-between'
145+
},
146+
inputWrapper: {
147+
display: 'flex',
148+
flexFlow: 'column',
149+
justifyContent: 'space-around'
150+
},
151+
inputWrapper__label: {
152+
marginRight: `calc(${globalStyles.spacing.dialogInsideMargin} / 2)`
153+
},
154+
inputWrapper__input: {
155+
flexGrow: 1
156+
},
157+
input__bottomRow: {
158+
marginTop: `calc(${globalStyles.spacing.dialogInsideMargin} / 3)`
159+
},
160+
input__box: {
161+
fontSize: globalStyles.fontSize.flyoutDialog
162+
}
163+
})
164+
104165
module.exports = LoginRequired

0 commit comments

Comments
 (0)