Skip to content

Commit

Permalink
fix(Toggle): support labels for small toggles (#7752)
Browse files Browse the repository at this point in the history
* fix(Toggle): support labels for small toggles

* test(Toggle): remove obsolete test

Co-authored-by: Taylor Jones <tay1orjones@users.noreply.github.com>
  • Loading branch information
emyarod and tay1orjones authored Feb 8, 2021
1 parent 47665bd commit 026bb4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
7 changes: 0 additions & 7 deletions packages/react/src/components/Toggle/Toggle-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,5 @@ describe('Toggle', () => {
const svg = wrapper.find(`.${prefix}--toggle__check`);
expect(svg.length).toBe(1);
});

it('Does not render toggle text', () => {
const offLabel = wrapper.find(`.${prefix}--toggle__text--off`);
const onLabel = wrapper.find(`.${prefix}--toggle__text--on`);
expect(offLabel.length).toBe(0);
expect(onLabel.length).toBe(0);
});
});
});
20 changes: 6 additions & 14 deletions packages/react/src/components/Toggle/Toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,12 @@ class Toggle extends React.Component {
<path d="M2.2 2.7L5 0 6 1 2.2 5 0 2.7 1 1.5z" />
</svg>
)}
{!size && (
<>
<span
className={`${prefix}--toggle__text--off`}
aria-hidden="true">
{labelA}
</span>
<span
className={`${prefix}--toggle__text--on`}
aria-hidden="true">
{labelB}
</span>
</>
)}
<span className={`${prefix}--toggle__text--off`} aria-hidden="true">
{labelA}
</span>
<span className={`${prefix}--toggle__text--on`} aria-hidden="true">
{labelB}
</span>
</span>
</label>
</div>
Expand Down

0 comments on commit 026bb4d

Please sign in to comment.