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

Commit f3c503e

Browse files
Suguru Hiraharacezaraugusto
Suguru Hirahara
authored andcommitted
Add browserButton_subtleItem and fix regressions
Closes #9072 Addresses #9071 Also: - Add lines in the same way as LESS files - Add comments for refenrence (We could remove them after refactoring work) - Fix regressions on browserButton_default - Add globalStyles.button.color to replace it with globalStyles.button.default.color - Fix a typo Auditors: Test Plan 1: (0. Take a screenshot of the buttons section on about:styles before testing the PR for later use) 1. Open about:styles 2. Click "buttons" 3. Take another screenshot of the section 4. Compare the two screenshots and make sure they look same Test Plan 2: 1. Open about:styles 2. Toggle developer tools 3. Make sure button's padding is set to '5px 16px' Test Plan 3: 1. Open downloadme.org 2. Click "Advanced" button 3. Make sure the button is not pushed down 4. Click "Hide advanced" button 5. Make sure the button does not move
1 parent ce6613c commit f3c503e

File tree

4 files changed

+72
-18
lines changed

4 files changed

+72
-18
lines changed

app/renderer/components/common/browserButton.js

+55-10
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ class BrowserButton extends ImmutableComponent {
1313
styles.browserButton,
1414
this.props.primaryColor && [styles.browserButton_default, styles.browserButton_primaryColor],
1515
this.props.secondaryColor && [styles.browserButton_default, styles.browserButton_secondaryColor],
16+
this.props.subtleItem && [styles.browserButton_default, styles.browserButton_subtleItem],
1617
this.props.extensionItem && styles.browserButton_extensionItem,
1718
this.props.groupedItem && styles.browserButton_groupedItem,
1819
this.props.notificationItem && styles.browserButton_notificationItem
1920
// TODO: These are other button styles app-wise
2021
// that needs to be refactored and included in this file
2122
// .............................................
22-
// this.props.smallItem && styles.browserButton_actionItem,
23+
// this.props.smallItem && styles.browserButton_smallItem,
2324
// this.props.actionItem && styles.browserButton_actionItem,
2425
// this.props.navItem && styles.browserButton_navItem,
2526
// this.props.panelItem && styles.browserButton_panelItem,
26-
// this.props.subtleItem && styles.browserButton_subtleItem
2727
]
2828
}
2929
render () {
@@ -46,18 +46,19 @@ class BrowserButton extends ImmutableComponent {
4646
}
4747
}
4848

49+
const buttonSize = '25px'
50+
4951
const styles = StyleSheet.create({
5052
browserButton: {
5153
margin: '0 3px',
5254
whiteSpace: 'nowrap',
5355
outline: 'none',
5456
cursor: 'default',
5557
display: 'inline-block',
56-
lineHeight: '25px',
57-
height: '25px',
58-
width: '25px',
58+
lineHeight: buttonSize,
59+
height: buttonSize,
60+
width: buttonSize,
5961
fontSize: '13px',
60-
color: globalStyles.button.default.color,
6162
borderRadius: '2px',
6263
textAlign: 'center',
6364
transition: '.1s opacity, .1s background',
@@ -68,49 +69,71 @@ const styles = StyleSheet.create({
6869
backgroundImage: 'none',
6970
backgroundColor: globalStyles.button.default.backgroundColor,
7071
border: 'none',
72+
73+
// cf: https://github.com/brave/browser-laptop/blob/548e11b1c889332fadb379237555625ad2a3c845/less/button.less#L49
74+
color: globalStyles.button.color,
75+
7176
':hover': {
7277
color: globalStyles.button.default.hoverColor
7378
}
7479
},
80+
7581
// applies for primary and white buttons
7682
browserButton_default: {
83+
// cf: https://github.com/brave/browser-laptop/blob/548e11b1c889332fadb379237555625ad2a3c845/less/button.less#L92
84+
color: globalStyles.button.default.color,
85+
7786
position: 'relative',
7887
boxShadow: globalStyles.button.default.boxShadow,
7988
cursor: 'pointer',
8089
lineHeight: 1.25,
8190
width: 'auto',
8291
height: 'auto',
83-
minWidth: '78px',
84-
fontSize: '13px',
85-
padding: '7px 20px',
92+
fontSize: globalStyles.spacing.defaultFontSize,
93+
94+
// cf: https://github.com/brave/browser-laptop/blob/548e11b1c889332fadb379237555625ad2a3c845/less/button.less#L94-L95
95+
paddingTop: '5px',
96+
paddingBottom: '5px',
97+
98+
// cf: https://github.com/brave/browser-laptop/blob/548e11b1c889332fadb379237555625ad2a3c845/less/button.less#L105-L106
99+
paddingRight: '16px',
100+
paddingLeft: '16px',
101+
102+
// cf: https://github.com/brave/browser-laptop/blob/548e11b1c889332fadb379237555625ad2a3c845/less/button.less#L98
103+
minWidth: `calc(${globalStyles.spacing.defaultFontSize} * 6)`, // issue #6384
104+
86105
':active': {
87106
// push the button down when active
88107
bottom: '-1px'
89108
}
90109
},
110+
91111
browserButton_primaryColor: {
92112
background: globalStyles.button.primary.background,
93113
borderLeft: '2px solid transparent',
94114
borderRight: '2px solid transparent',
95115
borderTop: `2px solid ${globalStyles.button.primary.gradientColor1}`,
96116
borderBottom: `2px solid ${globalStyles.button.primary.gradientColor2}`,
97-
color: globalStyles.button.primary.color,
98117
cursor: 'pointer',
118+
99119
':hover': {
100120
border: `2px solid ${globalStyles.button.primary.borderHoverColor}`,
101121
color: globalStyles.button.primary.hoverColor
102122
}
103123
},
124+
104125
browserButton_secondaryColor: {
105126
background: globalStyles.button.secondary.background,
106127
border: '1px solid white',
107128
color: globalStyles.button.secondary.color,
108129
cursor: 'pointer',
130+
109131
':hover': {
110132
border: `1px solid ${globalStyles.button.secondary.borderHoverColor}`,
111133
color: globalStyles.button.secondary.hoverColor
112134
}
113135
},
136+
114137
browserButton_extensionItem: {
115138
WebkitAppRegion: 'no-drag',
116139
backgroundSize: 'contain',
@@ -119,20 +142,42 @@ const styles = StyleSheet.create({
119142
opacity: '0.85',
120143
backgroundRepeat: 'no-repeat'
121144
},
145+
122146
browserButton_groupedItem: {
123147
// Legacy LESS inside ledger is too nested
124148
// and this style won't have effect without using !important
149+
//
125150
// TODO: remove !important and check advancedSettings.js
126151
// once preferences is fully refactored
127152
marginRight: '4px !important',
128153
marginLeft: '4px !important'
129154
},
155+
130156
browserButton_notificationItem: {
131157
fontSize: '13px',
132158
marginRight: '10px',
133159
padding: '2px 15px',
134160
textTransform: 'capitalize',
135161
width: 'auto'
162+
},
163+
164+
browserButton_subtleItem: {
165+
background: globalStyles.button.subtle.backgroundColor,
166+
167+
// cf: https://github.com/brave/browser-laptop/blob/548e11b1c889332fadb379237555625ad2a3c845/less/button.less#L152
168+
fontSize: '14px',
169+
170+
// Adding box-shadow:none to cancel the box-shadow specified on browserButton_default
171+
// On button.less, box-shadow is only speficied to .primaryButton and .whiteButton
172+
// cf:
173+
// https://github.com/brave/browser-laptop/blob/548e11b1c889332fadb379237555625ad2a3c845/less/button.less#L114
174+
// https://github.com/brave/browser-laptop/blob/548e11b1c889332fadb379237555625ad2a3c845/less/button.less#L137
175+
boxShadow: 'none',
176+
177+
// Cancel pushing down the button to make the button subtle
178+
':active': {
179+
bottom: 0
180+
}
136181
}
137182
})
138183

app/renderer/components/styles/global.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -252,30 +252,40 @@ const globalStyles = {
252252
animationFillMode: 'forwards'
253253
}
254254
},
255+
255256
button: {
257+
color: '#5a5a5a',
258+
256259
default: {
257-
color: '#5a5a5a',
260+
color: '#fff',
258261
backgroundColor: 'transparent',
259262
hoverColor: '#000',
260263
boxShadow: '0px 1px 5px -1px rgba(0, 0, 0, 0.5)'
261264
},
265+
262266
primary: {
263267
gradientColor1: '#FF7A1D',
264268
gradientColor2: '#ff5000',
265269
background: 'linear-gradient(#FF7A1D, #ff5000)',
266-
color: '#fff',
267270
hoverColor: '#fff',
268271
borderHoverColor: '#fff'
269272
},
273+
270274
secondary: {
271275
gradientColor1: '#fff',
272276
gradientColor2: '#ececec',
273277
background: 'linear-gradient(#fff, #ececec)',
274278
color: '#444',
275279
hoverColor: '#000',
276280
borderHoverColor: 'rgb(153, 153, 153)'
281+
},
282+
283+
subtle: {
284+
// cf: https://github.com/brave/browser-laptop/blob/548e11b1c889332fadb379237555625ad2a3c845/less/button.less#L151
285+
backgroundColor: '#ccc'
277286
}
278287
},
288+
279289
braveryPanel: {
280290
color: '#3b3b3b',
281291

js/about/safebrowsing.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
const React = require('react')
6-
const Button = require('../../app/renderer/components/common/button')
6+
const BrowserButton = require('../../app/renderer/components/common/browserButton')
77

88
const {StyleSheet, css} = require('aphrodite/no-important')
99

@@ -35,7 +35,7 @@ class SafebrowsingPage extends React.Component {
3535
{this.state.advanced
3636
? <section>
3737
<div className='buttons'>
38-
<Button className='subtleButton'
38+
<BrowserButton subtleItem
3939
l10nId='safebrowsingErrorHideAdvanced'
4040
testId='safebrowsingErrorHideAdvanced'
4141
onClick={this.onAdvancedToggle.bind(this)}
@@ -47,7 +47,7 @@ class SafebrowsingPage extends React.Component {
4747
</div>
4848
</section>
4949
: <section className='buttons'>
50-
<Button className='subtleButton'
50+
<BrowserButton subtleItem
5151
l10nId='safebrowsingErrorAdvanced'
5252
testId='safebrowsingErrorAdvanced'
5353
onClick={this.onAdvancedToggle.bind(this)}

js/about/styles.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,9 @@ class AboutStyle extends ImmutableComponent {
289289
onClick={'{this.onRemoveBookmark}'} />
290290
</Code></Pre>
291291

292-
<button data-l10n-id='subtleButton' className='browserButton subtleButton' onClick={this.onRemoveBookmark} />
292+
<BrowserButton subtleItem l10nId='subtleButton' onClick={this.onRemoveBookmark} />
293293
<Pre><Code>
294-
&lt;button data-l10n-id='cancel' className='browserButton subtleButton'{'\n'}
295-
onClick={'{this.onRemoveBookmark}'} />
294+
&lt;BrowserButton subtleItem l10nId='cancel' onClick={'{this.onRemoveBookmark}'} />
296295
</Code></Pre>
297296

298297
<BrowserButton primaryColor groupedItem l10nId='primaryButton' onClick={this.onRemoveBookmark} />

0 commit comments

Comments
 (0)