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

Create <TextArea> and <DefaultTextArea> with Aphrodite #7165

Merged
merged 1 commit into from
Feb 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/renderer/components/styles/commonStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const styles = StyleSheet.create({
boxSizing: 'border-box',
display: 'block',
color: globalStyles.color.darkGray,
fontSize: '14.5px',
fontSize: globalStyles.spacing.textAreaFontSize,
height: '2.25em',
outline: 'none',
padding: '0.4em',
Expand Down
1 change: 1 addition & 0 deletions app/renderer/components/styles/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const globalStyles = {
defaultSpacing: '12px',
defaultFontSize: '13px',
contextMenuFontSize: '14px',
textAreaFontSize: '14.5px',
dragSpacing: '50px',
switchHeight: '16px',
switchWidth: '45px',
Expand Down
42 changes: 36 additions & 6 deletions app/renderer/components/textbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {StyleSheet, css} = require('aphrodite')
const globalStyles = require('./styles/global')
const commonStyles = require('./styles/commonStyles')

// Textbox
class Textbox extends ImmutableComponent {
render () {
const className = css(
Expand Down Expand Up @@ -40,35 +41,64 @@ class RecoveryKeyTextbox extends ImmutableComponent {
}
}

// TextArea
class TextArea extends ImmutableComponent {
render () {
const className = css(
styles.textArea,
this.props['data-isDefault'] && styles.isDefault
)

return <textarea className={className} {...this.props} />
}
}

class DefaultTextArea extends ImmutableComponent {
render () {
return <TextArea data-isDefault='true' {...this.props} />
}
}

const styles = StyleSheet.create({
'textbox': {
// Textbox
textbox: {
boxSizing: 'border-box',
width: 'auto'
},
'outlineable': {
outlineable: {
':focus': {
outlineColor: globalStyles.color.statsBlue,
outlineOffset: '-4px',
outlineStyle: 'solid',
outlineWidth: '1px'
}
},
'isSettings': {
isSettings: {
width: '280px'
},
'readOnly': {
readOnly: {
background: globalStyles.color.veryLightGray,
boxShadow: 'none',
outline: 'none'
},
'recoveryKeys': {
recoveryKeys: {
marginBottom: '20px'
},

// TextArea
textArea: {
padding: '5px'
},
isDefault: {
fontSize: globalStyles.spacing.textAreaFontSize // Issue #6851
}
})

module.exports = {
Textbox,
FormTextbox,
SettingTextbox,
RecoveryKeyTextbox
RecoveryKeyTextbox,
TextArea,
DefaultTextArea
}
5 changes: 3 additions & 2 deletions js/about/adblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const getSetting = require('../settings').getSetting
const aboutActions = require('./aboutActions')
const ImmutableComponent = require('../components/immutableComponent')
const SwitchControl = require('../components/switchControl')
const {DefaultTextArea} = require('../../app/renderer/components/textbox')

const ipc = window.chrome.ipcRenderer

Expand Down Expand Up @@ -90,10 +91,10 @@ class AboutAdBlock extends React.Component {
</div>
<h3 data-l10n-id='customFilters' />
<div className='adblockSubtext' data-l10n-id='customFilterDescription' />
<textarea
<DefaultTextArea
onChange={this.onChangeCustomFilters}
value={getSetting(ADBLOCK_CUSTOM_RULES, this.state.settings) || ''}
className='customFiltersInput'
data-test-id='customFiltersInput'
cols='100'
rows='10'
spellCheck='false' />
Expand Down
19 changes: 19 additions & 0 deletions js/about/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require('../../less/button.less')
require('../../less/forms.less')

const {Textbox, FormTextbox, SettingTextbox, RecoveryKeyTextbox} = require('../../app/renderer/components/textbox')
const {TextArea, DefaultTextArea} = require('../../app/renderer/components/textbox')
const {Dropdown, FormDropdown, SettingDropdown} = require('../../app/renderer/components/dropdown')

class AboutStyle extends ImmutableComponent {
Expand Down Expand Up @@ -67,6 +68,24 @@ class AboutStyle extends ImmutableComponent {
</code></pre>
</div>

<div className='container'>
<h2>Plain textarea</h2>
<TextArea placeholder='TextArea' />
<pre><code>
const { '{TextArea}' } = require('../../app/renderer/components/textbox'){'\n'}
&lt;TextArea />
</code></pre>
</div>

<div className='container'>
<h2>Default textarea; font size is specified</h2>
<DefaultTextArea placeholder='DefaultTextArea' />
<pre><code>
const { '{DefaultTextArea}' } = require('../../app/renderer/components/textbox'){'\n'}
&lt;DefaultTextArea />
</code></pre>
</div>

<hr />

<h1 data-l10n-id='dropdowns' />
Expand Down
11 changes: 5 additions & 6 deletions less/about/adblock.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
-webkit-user-select: text;
}

.adblockDetailsPageContent {
margin-bottom: 10px;
}

.adblockLists {
margin-top: 10px;
}
Expand All @@ -26,14 +30,9 @@
margin-left: 15px;
}

.customFiltersInput {
margin: 10px 0;
padding: 5px;
font-size: 14.5px; // Issue #6851
}

.adblockSubtext {
font-size: smaller;
font-weight: bold;
margin-bottom: 10px;
}
}
10 changes: 5 additions & 5 deletions test/components/braveryPanelTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const Brave = require('../lib/brave')
const messages = require('../../js/constants/messages')
const {urlInput, braveMenu, braveMenuDisabled, adsBlockedStat, adsBlockedControl, showAdsOption, blockAdsOption, braveryPanel, httpsEverywhereStat, noScriptStat, noScriptSwitch, fpSwitch, fpStat, noScriptNavButton} = require('../lib/selectors')
const {urlInput, braveMenu, braveMenuDisabled, adsBlockedStat, adsBlockedControl, showAdsOption, blockAdsOption, braveryPanel, httpsEverywhereStat, noScriptStat, noScriptSwitch, fpSwitch, fpStat, noScriptNavButton, customFiltersInput} = require('../lib/selectors')
const {getTargetAboutUrl} = require('../../js/lib/appUrlUtil')

describe('Bravery Panel', function () {
Expand Down Expand Up @@ -205,8 +205,8 @@ describe('Bravery Panel', function () {
.tabByIndex(0)
.loadUrl(aboutAdblockURL)
.url(aboutAdblockURL)
.waitForVisible('.customFiltersInput')
.setValue('.customFiltersInput', 'testblock.brave.com')
.waitForVisible(customFiltersInput)
.setValue(customFiltersInput, 'testblock.brave.com')
.windowByUrl(Brave.browserWindowUrl)
.waitUntil(function () {
return this.getAppState().then((val) => {
Expand Down Expand Up @@ -239,8 +239,8 @@ describe('Bravery Panel', function () {
.tabByIndex(0)
.loadUrl(aboutAdblockURL)
.url(aboutAdblockURL)
.waitForVisible('.customFiltersInput')
.setValue('.customFiltersInput', 'testblock.brave.com')
.waitForVisible(customFiltersInput)
.setValue(customFiltersInput, 'testblock.brave.com')
.windowByUrl(Brave.browserWindowUrl)
.waitUntil(function () {
return this.getAppState().then((val) => {
Expand Down
3 changes: 2 additions & 1 deletion test/lib/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,6 @@ module.exports = {
tabsToolbar: '.tabsToolbar',
hamburgerMenu: '.menuButton',
contextMenu: '.contextMenu',
okButton: '[data-l10n-id="ok"]'
okButton: '[data-l10n-id="ok"]',
customFiltersInput: '[data-test-id="customFiltersInput"]'
}