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

Commit

Permalink
Merge pull request #9487 from brave/buttons/9486
Browse files Browse the repository at this point in the history
Normalize buttons in about:preferences
  • Loading branch information
cezaraugusto committed Jun 19, 2017
2 parents fab48e2 + 6f70a1c commit ddc30fd
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 88 deletions.
1 change: 1 addition & 0 deletions app/extensions/brave/locales/en-US/styles.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ actionButton=Action Button
subtleButton=Subtle Button
extensionItem=Extension Item
notificationItem=Notification Item
panelItem=Panel Item
7 changes: 6 additions & 1 deletion app/renderer/components/common/browserButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class BrowserButton extends ImmutableComponent {
this.props.groupedItem && styles.browserButton_groupedItem,
this.props.notificationItem && styles.browserButton_notificationItem,
this.props.iconOnly && styles.browserButton_iconOnly,
this.props.panelItem && styles.browserButton_panelItem,
// TODO: These are other button styles app-wise
// that needs to be refactored and included in this file
// .............................................
// this.props.navItem && styles.browserButton_navItem,
// this.props.panelItem && styles.browserButton_panelItem,

// note: this should be the last item so it can override other styles
this.props.disabled && styles.browserButton_disabled
Expand Down Expand Up @@ -170,6 +170,7 @@ const styles = StyleSheet.create({
border: '1px solid white',
color: globalStyles.button.secondary.color,
cursor: 'pointer',
fontWeight: 500,

':hover': {
border: `1px solid ${globalStyles.button.secondary.borderHoverColor}`,
Expand Down Expand Up @@ -235,6 +236,10 @@ const styles = StyleSheet.create({
background: globalStyles.button.action.backgroundColor
},

browserButton_panelItem: {
minWidth: '180px'
},

browserButton_iconOnly: {
display: 'flex',
justifyContent: 'center',
Expand Down
66 changes: 27 additions & 39 deletions app/renderer/components/preferences/payment/bitcoinDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const React = require('react')
const {StyleSheet, css} = require('aphrodite/no-important')

// components
const Button = require('../../common/button')
const BrowserButton = require('../../common/browserButton')
const cx = require('../../../../../js/lib/classSet')
const ModalOverlay = require('../../common/modalOverlay')
const ImmutableComponent = require('../../immutableComponent')
Expand Down Expand Up @@ -96,11 +96,9 @@ class BitcoinDashboard extends ImmutableComponent {
const buttonAttrs = {
l10nId: 'add',
testId: 'bitcoinPurchaseButton',
className: cx({
primaryButton: true,
[css(styles.panelButton)]: true,
disabled: disabled
})
primaryColor: true,
panelItem: true,
disabled: disabled
}
const hrefAttrs = {
href: this.props.ledgerData.get('buyURL'),
Expand All @@ -118,11 +116,11 @@ class BitcoinDashboard extends ImmutableComponent {
if (!disabled) {
buttonAttrs.onClick = this.props.showOverlay.bind(this)
}
return <Button {...buttonAttrs} />
return <BrowserButton {...buttonAttrs} />
}

return <a {...hrefAttrs}>
<Button {...buttonAttrs} />
<BrowserButton {...buttonAttrs} />
</a>
}

Expand Down Expand Up @@ -196,13 +194,11 @@ class BitcoinDashboard extends ImmutableComponent {
</div>
<div className={css(styles.panel__divider, styles.panel__divider_right)}>
<a target='_blank' href={url}>
{/* TODO: refactor button.js */}
<Button className={cx({
primaryButton: true,
[css(styles.panelButton)]: true
})}
<BrowserButton
primaryColor
panelItem
testId='exchangePanelButton'
label={name}
l10nId={name}
/>
</a>
</div>
Expand All @@ -223,11 +219,9 @@ class BitcoinDashboard extends ImmutableComponent {
</div>
<div className={css(styles.panel__divider, styles.panel__divider_right)}>
<a target='_blank' href='https://www.buybitcoinworldwide.com/'>
{/* TODO: refactor button.js */}
<Button className={cx({
primaryButton: true,
[css(styles.panelButton)]: true
})}
<BrowserButton
primaryColor
panelItem
testId='worldWidePanelButton'
label='buybitcoinworldwide.com'
/>
Expand Down Expand Up @@ -261,11 +255,9 @@ class BitcoinDashboard extends ImmutableComponent {
ledgerData.get('hasBitcoinHandler') && ledgerData.get('paymentURL')
? <div className={css(styles.panel__divider_right__bitcoinPanel__paymentURL)}>
<a href={ledgerData.get('paymentURL')} target='_blank'>
{/* TODO: refactor button.js */}
<Button className={cx({
primaryButton: true,
[css(styles.panelButton)]: true
})}
<BrowserButton
primaryColor
panelItem
l10nId='bitcoinVisitAccount'
testId='bitcoinVisitAccountButton'
/>
Expand All @@ -275,11 +267,9 @@ class BitcoinDashboard extends ImmutableComponent {
}
<div data-l10n-id='bitcoinPaymentURL' className={css(styles.panel__divider_right__bitcoinPanel__walletLabelText)} />
<div className={css(styles.panel__divider_right__bitcoinPanel__walletAddressText)}>{ledgerData.get('address')}</div>
{/* TODO: refactor button.js */}
<Button className={cx({
primaryButton: true,
[css(styles.panelButton)]: true
})}
<BrowserButton
primaryColor
panelItem
l10nId='copyToClipboard'
testId='copyToClipboardButton'
onClick={this.copyToClipboard.bind(this, ledgerData.get('address'))}
Expand Down Expand Up @@ -308,11 +298,9 @@ class BitcoinDashboard extends ImmutableComponent {
</div>
</div>
<div className={css(styles.panel__divider, styles.panel__divider_right)}>
{/* TODO: refactor button.js */}
<Button className={cx({
primaryButton: true,
[css(styles.panelButton)]: true
})}
<BrowserButton
primaryColor
panelItem
l10nId='displayQRCode'
testId='displayQRCode'
onClick={this.props.showQRcode.bind(this)}
Expand Down Expand Up @@ -449,10 +437,9 @@ class BitcoinDashboardFooter extends ImmutableComponent {
? this.coinbaseMessageWrapper
: null
}
<Button className={cx({
whiteButton: true,
[css(styles.dashboardFooter_coinbaseFooter__doneButton)]: this.coinbaseCountries
})}
<BrowserButton
secondaryColor
custom={this.coinbaseCountries && styles.dashboardFooter_coinbaseFooter__doneButton}
l10nId='done'
testId='panelDoneButton'
onClick={this.props.hideParentOverlay}
Expand Down Expand Up @@ -582,7 +569,8 @@ const styles = StyleSheet.create({
borderBottom: `3px solid ${globalStyles.color.modalLightGray}`
},
panel__smartphonePanel: {
padding: `${panelPadding} 0 ${panelPaddingBody}`
padding: `${panelPadding} 0 ${panelPaddingBody}`,
alignItems: 'center'
},

modalOverlay__qrcodeOverlay: {
Expand Down
5 changes: 2 additions & 3 deletions app/renderer/components/preferences/payment/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const {formattedTimeFromNow, formattedDateFromTimestamp} = require('../../../../
const appUrlUtil = require('../../../../../js/lib/appUrlUtil')

// components
const Button = require('../../common/button')
const BrowserButton = require('../../common/browserButton')
const ImmutableComponent = require('../../immutableComponent')

// style
Expand Down Expand Up @@ -117,8 +117,7 @@ class HistoryFooter extends ImmutableComponent {
<div className={css(styles.historyFooter__nextPayment)}>
<span data-l10n-id={l10nDataId} data-l10n-args={JSON.stringify(l10nDataArgs)} />
</div>
{/* TODO: refactor button.less */}
<Button className='primaryButton'
<BrowserButton primaryColor
l10nId='paymentHistoryOKText'
testId='paymentHistoryOKText'
onClick={this.props.hideOverlay.bind(this, 'paymentHistory')}
Expand Down
4 changes: 2 additions & 2 deletions app/renderer/components/styles/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ const globalStyles = {
gradientColor1: '#fff',
gradientColor2: '#ececec',
background: 'linear-gradient(#fff, #ececec)',
color: '#444',
hoverColor: '#000',
color: '#666',
hoverColor: '#444',
borderHoverColor: 'rgb(153, 153, 153)'
},

Expand Down
58 changes: 40 additions & 18 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {SettingsList, SettingItem, SettingCheckbox, SettingItemIcon} = require('.
const {SettingTextbox} = require('../../app/renderer/components/common/textbox')
const {SettingDropdown} = require('../../app/renderer/components/common/dropdown')
const {DefaultSectionTitle} = require('../../app/renderer/components/common/sectionTitle')
const Button = require('../../app/renderer/components/common/button')
const BrowserButton = require('../../app/renderer/components/common/browserButton')

// Tabs
const PaymentsTab = require('../../app/renderer/components/preferences/paymentsTab')
Expand Down Expand Up @@ -149,8 +149,11 @@ class GeneralTab extends ImmutableComponent {
const defaultBrowser = getSetting(settings.IS_DEFAULT_BROWSER, this.props.settings)
? <SettingItem dataL10nId='defaultBrowser' />
: <SettingItem dataL10nId='notDefaultBrowser' >
<Button l10nId='setAsDefault' className='primaryButton setAsDefaultButton'
onClick={this.setAsDefaultBrowser} />
<BrowserButton
primaryColor
l10nId='setAsDefault'
onClick={this.setAsDefaultBrowser}
/>
</SettingItem>

const defaultZoomSetting = getSetting(settings.DEFAULT_ZOOM_LEVEL, this.props.settings)
Expand Down Expand Up @@ -234,8 +237,11 @@ class GeneralTab extends ImmutableComponent {
</SettingDropdown>
</SettingItem>
<SettingItem dataL10nId='importBrowserData'>
<Button l10nId='importNow' className='primaryButton importNowButton'
onClick={this.importBrowserDataNow} />
<BrowserButton
primaryColor
l10nId='importNow'
onClick={this.importBrowserDataNow}
/>
</SettingItem>
{defaultBrowser}
<SettingItem>
Expand Down Expand Up @@ -547,10 +553,15 @@ class ShieldsTab extends ImmutableComponent {
<SettingCheckbox checked={this.props.braveryDefaults.get('safeBrowsing')} dataL10nId='safeBrowsing' onChange={this.onToggleSafeBrowsing} />
<SettingCheckbox checked={this.props.braveryDefaults.get('noScript')} dataL10nId='noScriptPref' onChange={this.onToggleNoScript} />
<SettingCheckbox dataL10nId='blockCanvasFingerprinting' prefKey={settings.BLOCK_CANVAS_FINGERPRINTING} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<Button l10nId='manageAdblockSettings' className='primaryButton manageAdblockSettings'
onClick={aboutActions.createTabRequested.bind(null, {
url: 'about:adblock'
})} />
{/* TODO: move this inline style to Aphrodite once refactored */}
<div style={{marginTop: '15px'}}>
<BrowserButton
primaryColor
l10nId='manageAdblockSettings'
onClick={aboutActions.createTabRequested.bind(null, {
url: 'about:adblock'
})} />
</div>
</SettingsList>
<DefaultSectionTitle data-l10n-id='shieldsPanelOptions' />
<SettingsList>
Expand Down Expand Up @@ -605,11 +616,15 @@ class SecurityTab extends ImmutableComponent {
<SettingCheckbox dataL10nId='autocompleteData' prefKey={settings.SHUTDOWN_CLEAR_AUTOCOMPLETE_DATA} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<SettingCheckbox dataL10nId='autofillData' prefKey={settings.SHUTDOWN_CLEAR_AUTOFILL_DATA} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<SettingCheckbox dataL10nId='savedSiteSettings' prefKey={settings.SHUTDOWN_CLEAR_SITE_SETTINGS} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<Button className='primaryButton'
l10nId='clearBrowsingDataNow'
testId='clearBrowsingDataButton'
onClick={this.clearBrowsingDataNow}
/>
{/* TODO: move this inline style to Aphrodite once refactored */}
<div style={{marginTop: '15px'}}>
<BrowserButton
primaryColor
l10nId='clearBrowsingDataNow'
testId='clearBrowsingDataButton'
onClick={this.clearBrowsingDataNow}
/>
</div>
</SettingsList>
<DefaultSectionTitle data-l10n-id='passwordsAndForms' />
<SettingsList>
Expand Down Expand Up @@ -646,10 +661,17 @@ class SecurityTab extends ImmutableComponent {
<DefaultSectionTitle data-l10n-id='autofillSettings' />
<SettingsList>
<SettingCheckbox dataL10nId='enableAutofill' prefKey={settings.AUTOFILL_ENABLED} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<Button l10nId='manageAutofillData' className='primaryButton manageAutofillDataButton'
onClick={aboutActions.createTabRequested.bind(null, {
url: 'about:autofill'
})} disabled={!getSetting(settings.AUTOFILL_ENABLED, this.props.settings)} />
{/* TODO: move this inline style to Aphrodite once refactored */}
<div style={{marginTop: '15px'}}>
<BrowserButton
primaryColor
l10nId='manageAutofillData'
disabled={!getSetting(settings.AUTOFILL_ENABLED, this.props.settings)}
onClick={aboutActions.createTabRequested.bind(null, {
url: 'about:autofill'
})}
/>
</div>
</SettingsList>
<DefaultSectionTitle data-l10n-id='fullscreenContent' />
<SettingsList>
Expand Down
7 changes: 7 additions & 0 deletions js/about/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ class AboutStyle extends ImmutableComponent {
&lt;BrowserButton iconOnly icon={'{'}globalStyles.appIcons.private{'}'} size='60px' color='red' />
</Code></Pre>

<BrowserButton groupedItem primaryColor panelItem l10nId='panelItem' onClick={this.copyToClipboard} />
<BrowserButton groupedItem primaryColor panelItem l10nId='panelItem' onClick={this.props.showQRcode} />
<Pre><Code>
&lt;BrowserButton groupedItem primaryColor panelItem l10nId='panelItem' onClick={'{this.copyToClipboard}'} />{'\n'}
&lt;BrowserButton groupedItem primaryColor panelItem l10nId='panelItem' onClick={'{this.props.showQRcode}'} />
</Code></Pre>

<GoTop />
</div>

Expand Down
25 changes: 0 additions & 25 deletions less/button.less
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,3 @@ span.buttonSeparator {
font-size: 14px;
}
}

// for about:preferences
.prefBody {
.settingsList > .settingItem + button,
.settingItem > span + button,
.paymentsContainer button:not(.close),
.syncContainer .browserButton {
font-size: 0.9rem;
padding: 8px 20px;
}

.settingsList > .settingItem + button,
.settingItem > span + button,
.paymentsContainer button:not(.close) {
margin: 0;
}

.settingsList > .settingItem + button {
margin-top: 20px;
}

.settingItem > span + button {
margin-top: 5px;
}
}

0 comments on commit ddc30fd

Please sign in to comment.