fix(vidstack): right-to-left layout and spoken time in the page's language - #1866
Open
aviahmorag wants to merge 2 commits into
Open
aviahmorag wants to merge 2 commits into
aviahmorag wants to merge 2 commits into
Conversation
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related:
No existing issue.
Description:
Makes sliders and the default layout's menus work in right-to-left pages (Hebrew, Arabic, Persian), and speaks times in the page's language. Today, in a
dir="rtl"page:justify-content: left), and icons, hints, radio check marks and their indentation use physical margins and padding, so they sit on the wrong side.translateX, so it leaves the track.Changes:
SliderEventsController: a horizontal slider whose computeddirectionisrtlreads pointer position from the right edge, inverts touch-drag, and swaps ArrowLeft/ArrowRight. Up/Down, Home/End and vertical sliders are unchanged.default/sliders.css: horizontal sliders in:dir(rtl)are mirrored withscale: -1 1(so thetransforms Vidstack sets on the thumb and fill still apply), and the preview is mirrored back so its text and thumbnail read normally.default/menus.css: physical properties become logical ones (margin-inline-*,padding-inline-*,inset-inline-start,border-inline-start,justify-content: flex-start). The two menu arrows flip in:dir(rtl), and the switch knob is anchored to the right and moves left.Spoken time:
formatSpokenTime(duration, lang?)spells the units withIntl.DurationFormatin the given language when the browser has it, so plurals follow CLDR (Arabic "دقيقتان", Russian "21 минута 3 секунды"). The time slider's value text, the announcer's seek announcement and the chapters menu pass the closestlangattribute. Without alang, or withoutIntl.DurationFormat, the output is the current "1 min 23 sec".The time slider gets a
translationsprop for the two words CLDR has no pattern for,out ofandlive; both default layouts pass theirs, andDefaultLayoutWordgains the two words.Left-to-right rendering is unchanged. One visible difference in English: on a page with
lang="en", the screen-reader text now says "6 seconds out of 12 seconds" instead of "6 sec out of 12 sec".Ready?
Yes.
Anything Else?
Before: the Accessibility menu in Hebrew with
dir="rtl"alone. The back arrow runs into the title and the switch knobs sit outside their tracks.After: the same menu as the mirror image of the left-to-right one.
Tested in WebKit (Playwright) and Safari with React +
DefaultVideoLayoutin adir="rtl"page:lang="he"page with Hebrew translations: "6 שניות מתוך 12 שניות"; onlang="en": "6 seconds out of 12 seconds".pnpm -F vidstack testpasses, with new cases forformatSpokenTimein English, Hebrew and Arabic and for an invalid language tag.The Plyr layout is not covered here.
Review Process:
<html dir="rtl">.