-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix rtl direction for components #1381
base: main
Are you sure you want to change the base?
Conversation
dac7735
to
bfc761a
Compare
I feel like there should be a way of getting direction keyboard events like "RightArrow" and "LeftBracket" but as text-direction-aware abstractions like "EndArrow" and "StartBracket". CSS already does this (e.g. I saw @slingk 's PR to add text direction awareness to a bunch of components and thought, golly, a JS core feature like like this could save us a lot of code. https://github.com/paranext/paranext-core/pull/1381/files ChatGPT seems to think any component should be able to get text direction from an element using
Might we use this approach for components to get text direction without needing to pass it as a parameter?
|
bfc761a
to
08afe7b
Compare
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.
Thanks for picking up the work to make these controls work left-to-right and right-to-left. This is very helpful!
Unfortunately, I don't think we want to explicitly have a direction prop to determine ltr
or rtl
. HTML already defines a mechanism for specifying this, and creating a separate prop to indicate the same idea can cause conflicts/confusion. For React controls, it would be helpful to create a hook that uses getComputedStyle
as Alex indicates above. We need to make sure not to call getComputedStyle
on every render as it isn't "free", but allowing the controls to call a hook to get the direction will standardize where/how we get it safely.
Reviewable status: 0 of 44 files reviewed, 1 unresolved discussion (waiting on @Sebastian-ubs)
lib/platform-bible-react/dist/index.d.ts
line 211 at r1 (raw file):
handleSubmit: (scrRef: ScriptureReference) => void; /** Text and layout direction */ direction?: "rtl" | "ltr";
We should not be adding direction
props to all of our controls. I'm just marking the first one as a block, but the same thought applies to all the later ones. More thoughts in the overall comments for this PR.
This change is
This is about fixing correct alignment of ui elements in a right to left layout, not direction of the text, which will be determined by the script of the text itself.
Components fixed
tw-ml -> tw-ms
className
s (8b6a9e3)Example: BCV
Before
After