Repository navigation
feat(core): RTL direction API (useDirection + getLocaleDirection + dir prop) - #4269
Merged
Merged
Conversation
nynexman4464
requested review from
cixzhang,
ejhammond,
imdreamrunner and
josephfarina
as code owners
July 23, 2026 21:49
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsPagination · View in Storybook
i18n
Bundle Size Summary
Accessibility AuditStatus: 1 accessibility violation(s) found — 1 moderate. Pagination - 1 issue(s)
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
nynexman4464
force-pushed
the
nynexman4464/feat/rtl-direction-api
branch
from
July 27, 2026 15:05
58edf49 to
62175ca
Compare
nynexman4464
force-pushed
the
nynexman4464/feat/rtl-direction-api
branch
from
July 27, 2026 15:25
62175ca to
67e78e3
Compare
github-actions
Bot
requested review from
cvkxx,
ernestt,
kentonquatman and
rubyycheung
July 27, 2026 16:16
…r prop) Adds Phase 1 of RTL support: - `direction: 'ltr' | 'rtl'` on InternationalizationContext value - `dir?: 'ltr' | 'rtl'` prop on InternationalizationProvider (overrides locale-derived default) - `useDirection()` hook — returns 'ltr' outside a provider (matches useTranslator fallback pattern) - `getLocaleDirection(locale)` — server-safe helper for RSC / <html dir> - Pagination flips chevron prev/next icons under RTL - Storybook `dir` global toolbar toggle (LTR / RTL) - Pagination `RightToLeft` story - Docs updated with the new API Direction is derived from Intl.Locale.getTextInfo() with try/catch fallback to 'ltr'. Explicit `dir` prop always wins. Ref #4116
…rovider Adds a live, interactive block that toggles text direction via a SegmentedControl (LTR/RTL) and renders Pagination inside InternationalizationProvider with the dir prop, plus a matching dir attribute on the wrapping DOM element. Pagination's prev/next chevrons flip under RTL, making the mirroring visually obvious.
Reworks the Text direction (RTL) section for newcomers: - Moves it up to sit right after "Runtime language swap" - Explains setting <html dir> in plain language (why it's needed, that astryx doesn't set it for you) instead of jargon about hydration and portals - Moves the component-author useDirection() guidance into the Developers subsection where it belongs - Links Intl.Locale.getTextInfo() to its MDN reference
VStack already forwards dir to its DOM node (BaseProps keeps dir; Stack spreads it through), so the extra <div dir> wrapper is unnecessary. Using VStack also sidesteps the dir-vs-direction confusion: VStack omits the flex `direction` prop, so `dir` sits alone with nothing to conflict with. Renamed the state to `textDirection` to keep the text/locale direction clearly distinct from any layout notion.
nynexman4464
force-pushed
the
nynexman4464/feat/rtl-direction-api
branch
from
July 27, 2026 20:24
006ea35 to
ba3fcf2
Compare
31 of 40 tasks
AKnassa
added a commit
to AKnassa/astryx
that referenced
this pull request
Aug 2, 2026
Upstream meta#4269 (RTL direction API) added `direction` to the i18n context, a `dir` prop to the provider, and useDirection / getLocaleDirection exports — the same three spots this branch touches for `translator`. Every conflict was add-add, so both features are kept side by side. - provider memo now carries {locale, direction, messages, overrides, translator} with all five deps - SYNC list keeps this branch's t.client.ts -> translator.ts fix (t.client.ts no longer exists in the tree); upstream's useDirection and getLocaleDirection entries added alongside it Verified: 83 i18n tests and 59 useTableSortable tests pass, typecheck and lint exit 0, and the net diff against upstream/main is unchanged at 1123+/15- across the same 10 files.
This branch was successfully 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.
Summary
Phase 1 of astryx RTL support (refs #4116). Adds the small foundation API — hook, server helper, provider surface — plus Pagination as the reference implementation and a Storybook
Directiontoolbar. Actual component CSS migrations (borders, chevrons, calendar range pills, slider math) land in follow-up PRs.API
Direction is computed via
Intl.Locale.getTextInfo()(CLDR-backed, covers the full RTL BCP 47 tag set —ar,he,fa,ur,ps,sd,yi,ug,dv,ku— not just a hardcoded shortlist). Atry/catchfallback returns'ltr'for exotic runtimes; no polyfill needed on React 19's browser baseline.Design decisions
InternationalizationProvideraccepts bothlocaleand optionaldir. The 99% case islocale="ar"and direction is derived automatically; the 1% case (RTL layout testing under an English catalog, forcing LTR for admin UIs, etc.) uses the explicit override.<html dir>themselves. NouseEffectmutatingdocument.dir— that causes SSR hydration mismatch and misses portaled overlays. This matches every mainstream React library (react-aria, Radix, MUI, Chakra, Ant Design, Mantine, Fluent).setDirection/toggleDirection; consumers manage direction state via their own store or Next.js locale.useDirection()returning the primitive string matches Radix and Mantine's shape.Reference implementation: Pagination
Pagination's prev/next chevron icons now flip under RTL. The aria-labels stay semantic (
@astryx.pagination.previous/@astryx.pagination.next) — only the visual arrow direction changes. ARightToLeftstory demonstrates the behavior.Storybook
New global
Directiontoolbar toggle between LTR and RTL. Wraps every story in<InternationalizationProvider dir={value}>and appliesdir={value}to the story container. Existing decorators (theme, color mode) are unchanged.Docs
packages/cli/docs/internationalization.doc.mjsgains a new "Direction" section coveringuseDirection(),getLocaleDirection(), and thedirprop.Testing
packages/core/src/i18n/__tests__/getLocaleDirection.test.ts— 8 cases:en → ltr,ar/he/fa/ur → rtl,pt-BR/zh-CN → ltr, invalid locale falls back toltr.packages/core/src/i18n/__tests__/useDirection.test.tsx— hook returns provider value; explicitdiroverrides derived; missing provider returnsltr.pnpm --filter '@astryxdesign/core' typecheck: clean.pnpm check:repo: PASS.Follow-ups (not this PR)
Per the RTL migration plan, remaining work: