-
-
Notifications
You must be signed in to change notification settings - Fork 3
fix: support RTL layout and navigation #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
|
|
||
| for (const direction of ['ltr', 'rtl'] as const) { | ||
| test(`${direction} mirrors range geometry`, async ({ page }) => { | ||
| await page.goto('/main/index', { waitUntil: 'networkidle' }); | ||
| await page.evaluate((dir) => { | ||
| const fixture = document.createElement('div'); | ||
| fixture.id = 'rtl-range-probe'; | ||
| fixture.dir = dir; | ||
|
|
||
| const range = document.createElement('ion-range'); | ||
| range.id = 'single-range'; | ||
| range.mode = 'md'; | ||
| range.min = 0; | ||
| range.max = 100; | ||
| range.value = 50; | ||
|
|
||
| const dual = document.createElement('ion-range'); | ||
| dual.id = 'dual-range'; | ||
| dual.mode = 'md'; | ||
| dual.dualKnobs = true; | ||
| dual.min = 0; | ||
| dual.max = 100; | ||
| dual.value = { lower: 0, upper: 100 }; | ||
|
|
||
| fixture.append(range, dual); | ||
| document.body.append(fixture); | ||
| }, direction); | ||
|
|
||
| await expect(page.locator('#single-range')).toHaveClass(/hydrated/); | ||
| await expect(page.locator('#dual-range')).toHaveClass(/hydrated/); | ||
|
|
||
| const normalOffset = await page.locator('#single-range').evaluate((range) => { | ||
| const knob = range.shadowRoot!.querySelector<HTMLElement>('[part~="knob"]')!; | ||
| return new DOMMatrixReadOnly(getComputedStyle(knob).transform).e; | ||
| }); | ||
| expect(normalOffset).toBeCloseTo(direction === 'ltr' ? 20 : -20, 1); | ||
|
|
||
| await page.locator('#single-range').evaluate((range) => range.classList.add('range-pressed')); | ||
| await expect | ||
| .poll(() => | ||
| page.locator('#single-range').evaluate((range) => { | ||
| const knob = range.shadowRoot!.querySelector<HTMLElement>('[part~="knob"]')!; | ||
| return new DOMMatrixReadOnly(getComputedStyle(knob).transform).e; | ||
| }), | ||
| ) | ||
| .toBeCloseTo(direction === 'ltr' ? 21 : -21, 1); | ||
|
|
||
| const dualMargins = await page.locator('#dual-range').evaluate((range) => { | ||
| const bar = range.shadowRoot!.querySelector<HTMLElement>('[part~="bar"]')!; | ||
| const style = getComputedStyle(bar); | ||
| return { start: style.marginInlineStart, end: style.marginInlineEnd }; | ||
| }); | ||
| expect(dualMargins).toEqual({ start: '6px', end: '6px' }); | ||
| }); | ||
|
|
||
| test(`${direction} mirrors Material forward and back transitions`, async ({ page }) => { | ||
| await page.goto('/main/index', { waitUntil: 'networkidle' }); | ||
| await page.evaluate((dir) => { | ||
| document.documentElement.dir = dir; | ||
| const originalAnimate = Element.prototype.animate; | ||
| (window as any).__RTL_ANIMATIONS__ = []; | ||
| Element.prototype.animate = function (keyframes, options) { | ||
| const frames = Array.isArray(keyframes) ? keyframes : []; | ||
| (window as any).__RTL_ANIMATIONS__.push({ | ||
| tag: this.localName, | ||
| transforms: frames.map((frame) => frame.transform).filter(Boolean), | ||
| }); | ||
| return originalAnimate.call(this, keyframes, options); | ||
| }; | ||
| }, direction); | ||
| await page.getByRole('button', { name: 'button', exact: true }).click(); | ||
|
|
||
| const expected = direction === 'ltr' ? 'translateX(40px)' : 'translateX(-40px)'; | ||
| const stacked = direction === 'ltr' ? 'translateX(-40px)' : 'translateX(40px)'; | ||
| await expect | ||
| .poll(() => | ||
| page.evaluate( | ||
| ({ expected, stacked }) => { | ||
| const calls = (window as any).__RTL_ANIMATIONS__ as { tag: string; transforms: string[] }[]; | ||
| return { | ||
| entering: calls.some((call) => call.tag === 'app-button' && call.transforms.includes(expected)), | ||
| stacked: calls.some((call) => call.transforms.includes(stacked)), | ||
| }; | ||
| }, | ||
| { expected, stacked }, | ||
| ), | ||
| ) | ||
| .toEqual({ entering: true, stacked: true }); | ||
|
|
||
| await page.evaluate(() => ((window as any).__RTL_ANIMATIONS__ = [])); | ||
| await page.locator('app-button > ion-header ion-back-button').click(); | ||
| await expect | ||
| .poll(() => | ||
| page.evaluate((expectedTransform) => { | ||
| const calls = (window as any).__RTL_ANIMATIONS__ as { tag: string; transforms: string[] }[]; | ||
| return calls.some((call) => call.tag === 'app-button' && call.transforms.includes(expectedTransform)); | ||
| }, expected), | ||
| ) | ||
| .toBe(true); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| ion-header { | ||
| position: absolute; | ||
| top: 0; | ||
| left: 0; | ||
| inset-inline-start: 0; | ||
| } | ||
|
|
||
| ion-content { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| ion-item *[slot='end'] { | ||
| margin-right: 6px; | ||
| margin-inline-end: 6px; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| :host { | ||
| ion-tab-bar { | ||
| margin-left: calc(16px + var(--ion-safe-area-left, 0px)); | ||
| margin-right: calc(16px + var(--ion-safe-area-right, 0px)); | ||
| margin-inline: calc(16px + var(--ion-safe-area-left, 0px)) calc(16px + var(--ion-safe-area-right, 0px)); | ||
|
|
||
| &:dir(rtl) { | ||
| margin-inline: calc(16px + var(--ion-safe-area-right, 0px)) calc(16px + var(--ion-safe-area-left, 0px)); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🔍 要素単位の RTL と遷移方向の不一致
dir="rtl"がion-appなどに設定されると、:dir(rtl)は反映されても遷移は LTR のままです。文書ルート限定の RTL 契約か確認してください。Was this helpful? React with 👍 or 👎 to provide feedback.