Skip to content

Commit

Permalink
fix(color-wheel): add test for dir="rtl" orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
majornista committed Jul 11, 2023
1 parent 98ce8b2 commit 1bc5ba2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/color-wheel/src/color-wheel.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ governing permissions and limitations under the License.
z-index: 0;
}

:host([dir='rtl']) .wheel {
:host([dir='rtl']) .wheel,
:host([dir='rtl']) ::slotted([slot='gradient']) {
transform: scaleX(-1);
}
23 changes: 23 additions & 0 deletions packages/color-wheel/test/color-wheel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,4 +628,27 @@ describe('ColorWheel', () => {
expect(el.value).to.equal(hue);
expect(tinyHSLA.equals(el.color)).to.be.true;
});
it('should flip orientation with dir="rtl"', async () => {
const el = await fixture<ColorWheel>(
html`
<sp-color-wheel></sp-color-wheel>
`
);

await elementUpdated(el);

const root = el.shadowRoot ? el.shadowRoot : el;
expect(
getComputedStyle(root.querySelector('.wheel') as HTMLElement)
.transform
).to.equal('none');

el.setAttribute('dir', 'rtl');

await elementUpdated(el);
expect(
getComputedStyle(root.querySelector('.wheel') as HTMLElement)
.transform
).to.equal('matrix(-1, 0, 0, 1, 0, 0)');
});
});

0 comments on commit 1bc5ba2

Please sign in to comment.