Skip to content

Commit

Permalink
fix grid repositioning on label change (#8713)
Browse files Browse the repository at this point in the history
  • Loading branch information
brad-decker authored Jun 3, 2020
1 parent 171704d commit c6b77c9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/e2e/threebox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ describe('MetaMask', function () {

it('finds the blockies toggle turned on', async function () {
await driver.delay(regularDelayMs)
const toggleLabel = await driver.findElement(By.css('.toggle-button__status-label'))
const toggleLabel = await driver.findElement(By.css('.toggle-button__status'))
const toggleLabelText = await toggleLabel.getText()
assert.equal(toggleLabelText, 'ON')
})
Expand Down
28 changes: 26 additions & 2 deletions ui/app/components/ui/toggle-button/index.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.toggle-button {
display: flex;
$self: &;

&__status-label {
&__status {
font-family: Roboto;
font-style: normal;
font-weight: normal;
Expand All @@ -10,5 +11,28 @@
display: flex;
align-items: center;
text-transform: uppercase;
display: grid;
}
}

&__label-off, &__label-on {
grid-area: 1 / 1 / 1 / 1;
}

&__label-off {
visibility: hidden;
}

&__label-on {
visibility: visible;
}

&--off {
#{ $self }__label-off {
visibility: visible;
}

#{ $self }__label-on {
visibility: hidden;
}
}
}
9 changes: 7 additions & 2 deletions ui/app/components/ui/toggle-button/toggle-button.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ const colors = {
const ToggleButton = (props) => {
const { value, onToggle, offLabel, onLabel } = props

const modifier = value ? 'on' : 'off'

return (
<div className="toggle-button">
<div className={`toggle-button toggle-button--${modifier}`}>
<ReactToggleButton
value={value}
onToggle={onToggle}
Expand All @@ -60,7 +62,10 @@ const ToggleButton = (props) => {
thumbAnimateRange={[3, 18]}
colors={colors}
/>
<div className="toggle-button__status-label">{ value ? onLabel : offLabel }</div>
<div className="toggle-button__status">
<span className="toggle-button__label-off">{offLabel}</span>
<span className="toggle-button__label-on">{onLabel}</span>
</div>
</div>
)
}
Expand Down

0 comments on commit c6b77c9

Please sign in to comment.