-
Notifications
You must be signed in to change notification settings - Fork 973
SwitchControl text now toggles checked state, and is consistently used #10470
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
const React = require('react') | ||
const Immutable = require('immutable') | ||
const {StyleSheet, css} = require('aphrodite') | ||
|
||
// Components | ||
const ReduxComponent = require('../reduxComponent') | ||
|
@@ -24,6 +25,7 @@ const {getTextColorForBackground} = require('../../../../js/lib/color') | |
const frameStateUtil = require('../../../../js/state/frameStateUtil') | ||
const {getSetting} = require('../../../../js/settings') | ||
const debounce = require('../../../../js/lib/debounce') | ||
const cx = require('../../../../js/lib/classSet') | ||
|
||
// Styles | ||
const globalStyles = require('../styles/global') | ||
|
@@ -224,16 +226,18 @@ class FindBar extends React.Component { | |
|
||
render () { | ||
let findBarStyle = {} | ||
let findBarTextStyle = {} | ||
let findBarTextStyles = {} | ||
|
||
if (this.props.backgroundColor) { | ||
findBarTextStyles = StyleSheet.create({ | ||
matchingTextColor: { | ||
color: this.props.textColor | ||
} | ||
}) | ||
findBarStyle = { | ||
background: this.props.backgroundColor, | ||
color: this.props.textColor | ||
} | ||
findBarTextStyle = { | ||
color: this.props.textColor | ||
} | ||
} | ||
|
||
return <div className='findBar' style={findBarStyle} onBlur={this.onBlur}> | ||
|
@@ -275,16 +279,15 @@ class FindBar extends React.Component { | |
id='caseSensitivityCheckbox' | ||
checkedOn={this.props.isCaseSensitive} | ||
onClick={this.onCaseSensitivityChange} | ||
/> | ||
<label | ||
htmlFor='caseSensitivityCheckbox' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it OK to remove this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The label is now being rendered by the switchControl, and the findBarTestStyle style overrides have been changed to aphrodite-style findBarTextStyles css. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indeed! |
||
data-l10n-id='caseSensitivity' | ||
style={findBarTextStyle} | ||
customRightTextClassName={css(findBarTextStyles.matchingTextColor)} | ||
rightl10nId='caseSensitivity' | ||
/> | ||
</div> | ||
<span | ||
className='closeButton' | ||
style={findBarTextStyle} | ||
className={cx({ | ||
closeButton: true, | ||
[css(findBarTextStyles.matchingTextColor)]: true | ||
})} | ||
onClick={this.onFindHide} | ||
>+</span> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -272,105 +272,6 @@ table.sortableTable { | |
color: @braveOrange; | ||
} | ||
|
||
.prefTabContainer .switchControl { | ||
display: inline-block; | ||
vertical-align: middle; | ||
align-items: center; | ||
padding: 5px; | ||
cursor: pointer; | ||
|
||
&.disabled { | ||
.switchBackground { | ||
opacity: 0.3; | ||
} | ||
.switchControlRightText, .switchControlLeftText { | ||
opacity: 0.3; | ||
} | ||
cursor: default; | ||
} | ||
|
||
&:not(.disabled) { | ||
.switchBackground.switchedOn { | ||
background-color: @switchBG_on; | ||
.switchIndicator { | ||
right: 2px; | ||
} | ||
} | ||
} | ||
|
||
&.large { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok to remove this? |
||
.switchBackground { | ||
height: 26px; | ||
width: 60px; | ||
.switchIndicator { | ||
height: 22px; | ||
width: 22px; | ||
} | ||
} | ||
} | ||
|
||
&.small { | ||
.switchBackground { | ||
height: @smallSwitchHeight; | ||
width: @smallSwitchWidth; | ||
.switchIndicator { | ||
height: @smallSwitchNubDiameter; | ||
width: @smallSwitchNubDiameter; | ||
top: 1px; | ||
right: calc(@smallSwitchWidth - @smallSwitchNubDiameter - @switchNubRightMargin); | ||
} | ||
} | ||
} | ||
|
||
> label { | ||
vertical-align: middle; | ||
} | ||
|
||
.switchControlText { | ||
margin: auto 0; | ||
} | ||
|
||
.switchControlLeftText { | ||
margin: auto 5px auto 0; | ||
} | ||
|
||
.switchControlRightText { | ||
margin: auto 0 auto 5px; | ||
} | ||
|
||
.switchControlTopText { | ||
margin: 0 auto 5px auto; | ||
} | ||
|
||
.switchControlRight { | ||
display: flex; | ||
} | ||
|
||
.switchMiddle { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.switchBackground { | ||
background-color: @switchBG_off; | ||
border-radius: 12px; | ||
height: @switchHeight; | ||
position: relative; | ||
width: @switchWidth; | ||
box-shadow: @switchShadow; | ||
|
||
.switchIndicator { | ||
background-color: white; | ||
border-radius: 100%; | ||
height: @switchNubDiameter; | ||
position: absolute; | ||
top: @switchNubTopMargin; | ||
width: @switchNubDiameter; | ||
box-shadow: @switchNubShadow; | ||
} | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it OK to remove them all? Was There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @luixxiul all the removed styles that were in SettingsCheckBox were already in switchControls.less. The one that wasn't is the space between the label and the switch element. See description for question on whether this should now match all other uses of SwitchControl in the app. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why don't we re-add the space for now until we find a better way of handling the padding than we have currently, avoiding the visual regression? My idea:
That is out of scope of this PR so you would not need to address them There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously the text was rendered with a label element outside the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds good to me. Would you mind adding If, however, no visual regressions are allowed, overriding with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took another look at it and added a prop to |
||
.widevineInfo { | ||
line-height: 1.3em; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,19 @@ | |
} | ||
} | ||
} | ||
|
||
&.small { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change affects every switch controls outside of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my search, no other component currently uses the small variant apart from |
||
.switchBackground { | ||
height: @smallSwitchHeight; | ||
width: @smallSwitchWidth; | ||
.switchIndicator { | ||
height: @smallSwitchNubDiameter; | ||
width: @smallSwitchNubDiameter; | ||
top: 1px; | ||
right: calc(@smallSwitchWidth - @smallSwitchNubDiameter - @switchNubRightMargin); | ||
} | ||
} | ||
} | ||
|
||
.switchControlText { | ||
margin: auto 0; | ||
|
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.