-
Notifications
You must be signed in to change notification settings - Fork 970
Partial refactoring of switchControl.js #10482
Conversation
@@ -197,21 +197,21 @@ class PaymentsTab extends ImmutableComponent { | |||
styles.paymentsSwitches | |||
)}> | |||
<div className={css(styles.flexAlignCenter, styles.switchWrap)} data-test-id='enablePaymentsSwitch'> | |||
<span className={css(styles.switchWrap__switchSpan)} data-l10n-id='off' /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with dataL10nIdLeft='off'
below.
/> | ||
{this.props.options} | ||
</div> | ||
} | ||
} | ||
|
||
const settingCheckboxStyles = StyleSheet.create({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The Cause of the Fragments"
fontSize: 'smaller' | ||
}, | ||
expansiveRightText: { | ||
paddingLeft: '9px' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -264,7 +264,8 @@ class LedgerTable extends ImmutableComponent { | |||
<div className={css(styles.hideExcludedSites)}> | |||
<div className={css(styles.columnOffset)} /> | |||
<div className={css(styles.rightColumn)}> | |||
<SettingCheckbox small compact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<SettingCheckbox | ||
dataL10nId='on' | ||
compact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
@@ -228,7 +227,6 @@ class PaymentsTab extends ImmutableComponent { | |||
<div className={css(styles.switchWrap__autoSuggestSwitch)}> | |||
<div className={css(styles.flexAlignCenter, styles.autoSuggestSwitch__subtext)}> | |||
<SettingCheckbox dataL10nId='autoSuggestSites' | |||
compact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
Codecov Report
@@ Coverage Diff @@
## master #10482 +/- ##
==========================================
- Coverage 54.24% 54.23% -0.01%
==========================================
Files 249 249
Lines 21836 21844 +8
Branches 3399 3407 +8
==========================================
+ Hits 11844 11847 +3
- Misses 9992 9997 +5
|
@luixxiul please rebase |
rebased! |
: (this.props.leftl10nId | ||
? <label className='switchControlLeftText' onClick={this.onClick} data-l10n-id={this.props.leftl10nId} /> | ||
? <label className={cx({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before rebasing this line had been wrapped with div
. It was a regression, so I removed that.
<div className='switchControlLeftText'> | ||
<div className='switchSpacer'> </div> | ||
<label className={cx({ | ||
[css(styles.switchControlText__label, styles.switchControlText_left__label, this.props.small && styles.switchControlText__label_small)]: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better if
[css(styles.switchControlText__label]: true,
[css(styles.switchControlText_left__label): true,
[styles.switchControlText__label_small]: this.props.small
lmk if you disagree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you set background: #000
to switchControlText__label
and background: #111
to switchControlText_left__label
at the same time, we usually get background: #000
instead of the latter, which is what we want. I'd love to prefer readability but we have to assure that the styles are surely cascaded.
I've noticed that issue for a while and tried another way to set them as follows:
[css(
styles.switchControlText__label,
styles.switchControlText_left__label
)]
but it was avoided because Standard complained about that the [
and ]
should appear on the very same line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still I believe this is a kind of issue on the transitional phase until you would eventually remove cx
by creating components in a way which @petemill has demonstrated.
We could create an issue to track the work.
It seems to me that replacing customLeftTextClassName
with this.props.custom
as you @cezaraugusto did on browserButton
should work. I took that way for commonForm
on #10978, e.g. <CommonForm custom={styles.commonForm_small}>
, so <SwitchLabel custom={styles.switchControlText_left__label}>
or <SwitchLabel left>
.
fontWeight: 'bold', | ||
switchWrap__label_left: { | ||
paddingRight: '.75ch !important' | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you prefer spacing brakets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch, thanks!
/> | ||
<a className={cx({ | ||
fa: true, | ||
'fa-question-circle': true, | ||
[css(styles.autoSuggestSwitch__moreInfo)]: true, | ||
[css(styles.autoSuggestSwitch__moreInfoBtnSuggest)]: true | ||
[css(styles.autoSuggestSwitch__moreInfo, styles.autoSuggestSwitch__moreInfoBtnSuggest)]: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above better if
[css(styles.autoSuggestSwitch__moreInfo)]: true,
[css(styles.autoSuggestSwitch__moreInfoBtnSuggest)]: true
unless aphrodite is buggy in such cases
: (this.props.leftl10nId | ||
? <label className='switchControlLeftText' onClick={this.onClick} data-l10n-id={this.props.leftl10nId} /> | ||
? <label className={cx({ | ||
[css(styles.switchControlText__label, styles.switchControlText_left__label, this.props.small && styles.switchControlText__label_small)]: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
: null) | ||
} | ||
<div className='switchMiddle'> | ||
{ | ||
this.props.topl10nId | ||
? <label className={cx({ | ||
switchControlTopText: true, | ||
[css(styles.switchControlText__label, this.props.small && styles.switchControlText__label_small)]: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
<div className={cx({ | ||
switchIndicator: true, | ||
[css(this.props.small && styles.switchControlText__label_small)]: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep same
@@ -69,7 +91,7 @@ class SwitchControl extends ImmutableComponent { | |||
<div className='switchControlRightText'> | |||
<div className='switchSpacer'> </div> | |||
<label className={cx({ | |||
switchControlRightText: true, | |||
[css(styles.switchControlText__label, styles.switchControlText_right__label, this.props.small && styles.switchControlText__label_small)]: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -82,7 +104,7 @@ class SwitchControl extends ImmutableComponent { | |||
{ | |||
(this.props.rightl10nId || this.props.rightText) && !this.props.onInfoClick | |||
? <label className={cx({ | |||
switchControlRightText: true, | |||
[css(styles.switchControlText__label, styles.switchControlText_right__label, this.props.small && styles.switchControlText__label_small)]: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yaya
data-l10n-args={this.props.rightl10nArgs}> | ||
? <div className='switchControlRight'> | ||
<label className={cx({ | ||
[css(styles.switchControlText__label, styles.switchControlText_right__label, this.props.small && styles.switchControlText__label_small)]: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^^^
{this.props.rightText} | ||
</label> | ||
<span className={cx({ | ||
fa: true, | ||
'fa-question-circle': true, | ||
info: true, | ||
clickable: true, | ||
[css(styles.switchControlText__label, this.props.small && styles.switchControlText__label_small)]: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yet another one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see above, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm but please see inline comments
Addresses #7321 - Add rightLabelClassName and leftLabelClassName props - Add user-select:none to the labels - Move 'small' option from settings.js to switchControls.js, removing settingsCheckboxStyles - Remove 'compact' props as padding-left / padding-right is set by default - Replace 9px margin with 1ch padding for labels - Overwrite that padding with 0.75ch for payments switch labels TODO: Apply 'position: relative' and 'bottom: 1px' for macOS (en_US) only. The placement of the right label has been corrupted on the other environments such as Windows 10 (ja-JP). Auditors: Test Plan 1: 1. Open about:preferences 2. Make sure there is padding space between switches and labels 3. Make sure the labels text cannot be selected Test Plan 2: 1. Open about:preferences#payments 2. Make sure the 3 switches are displayed 3. Change the language setting 4. Restart the browser 5. Reopen about:preferences#payments 6. Make sure the labels and the switch are aligned at the center Test Plan 3: 1. Open braveryPanel.js 2. Replace 'SwitchControl large' to 'SwitchControl small' 3. Run npm run watch && npm start 4. Open brave.com 5. Open the bravery panel 6. Make sure the main switch and the labels around it are small
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok merging. @luixxiul could you please create a tracking issue for cases I mentioned in here? seems to have other cases and I'll in one point move them w/o cx()
and add props as you suggested. Nice work!
Addresses #7321
Fixes #11937TODO: Apply 'position: relative' and 'bottom: 1px' for macOS (en_US) only on about:preferences#payments.
The placement of the right label has been corrupted on the other environments such as Windows 10 (ja-JP);
Auditors: @cezaraugusto @petemill
Test Plan 1:
Test Plan 2:
Test Plan 3:
Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist:
Tests