Skip to content
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

Support direction property (right-to-left layout) #213

Open
5 tasks
Tracked by #345
TimJentzsch opened this issue Aug 4, 2022 · 4 comments · May be fixed by #736
Open
5 tasks
Tracked by #345

Support direction property (right-to-left layout) #213

TimJentzsch opened this issue Aug 4, 2022 · 4 comments · May be fixed by #736
Labels
enhancement New feature or request

Comments

@TimJentzsch
Copy link
Collaborator

TimJentzsch commented Aug 4, 2022

What problem does this solve or what need does it fill?

The CSS layout specifications allow for reversed layout dependent on the direction property. This allows UI layouts to reflect the layout conventions of users of RTL languages (which conventionally start from the right) in addition to users of LTR langauges that usually expect layouts which start from the left.

What solution would you like?

Note: A PR for this has been started: #736

  • Add a direction style with Ltr and Rtl variants
  • Add support for generating this style in the test generator
  • Update Flexbox algorithm to use this style
  • Update CSS Grid algorithm to use this style
  • Update Block algorithm to use this style

Additional context

More context on MDN

@TimJentzsch TimJentzsch added enhancement New feature or request bug Something isn't working labels Aug 4, 2022
@TimJentzsch
Copy link
Collaborator Author

Here's more information about writing modes: https://drafts.csswg.org/css-writing-modes/#text-flow

Right-to-left will probably not be enough. We also have to consider vertical layouts.

@nicoburns
Copy link
Collaborator

There are really two CSS properties of concern here:

  • direction which switches between left-to-right and right-to-left
  • writing-mode which allows use to switch to vertical text

We probably eventually want to implement both, but we should probably start with direction which is the simpler of the two.

For direction, we will want something like the is_reverse boolean that we currently use for flex-direction, but it would (depending on the value set) be flipped an additional time by direction.

For writing-mode, I think we should change our axis handling. Rather than having a variable called dir (direction) that takes a FlexDirection, I think we should have a variable called main_axis that takes an AbsoluteAxis (Horizontal or Vertical. We can then also store a variable cross_axis, or we can access the cross axis by using main_axis.other() where the other method returns the opposite axis to the one stored. For CSS Grid it will be similar except that we will store an inline_axis rather than a main_axis.

By doing things this way I think we can keep the writing-mode/direction dependent code in one place (there will no doubt be some exceptions).

@nicoburns nicoburns changed the title Support right-to-left writing modes Support right-to-left and vertical writing modes Jan 8, 2023
@nicoburns
Copy link
Collaborator

nicoburns commented Jan 8, 2023

Supporting this will likely require the addition of "flow-relative" equivalents of the following style properties:

  • size/min-size/max-size:
    • inline-size instead of width
    • block-size instead of height
  • inset/border/padding/margin:
    • inset-inline-start instead of left
    • inset-inline-end instead of right
    • inset-block-start instead of top
    • inset-block-end instead of bottom

It will also require all of the above styles (both the new and the old ones) to have an "unset" state (e.g. be wrapped in Option) so that the default style of the one set of styles doesn't overwrite a set value in the other set. CSS defines precedence based on which style was declared first. But I think we could probably take a shortcut here and define a simpler precedence like "physical styles override flow-relative styles" or vice versa.

@nicoburns nicoburns mentioned this issue Jan 30, 2023
37 tasks
@nicoburns nicoburns removed the bug Something isn't working label May 16, 2023
@nicoburns nicoburns moved this to Todo in 🍬 Taffy Roadmap Jan 7, 2024
@nicoburns nicoburns changed the title Support right-to-left and vertical writing modes Support right-to-left layout (direction: rtl) Dec 4, 2024
@nicoburns nicoburns linked a pull request Dec 4, 2024 that will close this issue
@nicoburns
Copy link
Collaborator

I have made this issue just about direction and split writing-mode into it's own issue #752

@nicoburns nicoburns changed the title Support right-to-left layout (direction: rtl) Support direction property (right-to-left layout) Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

2 participants