### Background
Historically, some CSS properties and values have followed LTR-specific directional mappings and required conversion for RTL interfaces. For example, a `margin-left` rule would need to be converted to a `margin-right` rule in an RTL context.
[[ https://github.com/cssjanus/cssjanus | CSSJanus ]] is the solution currently employed in MediaWiki via [[ https://www.mediawiki.org/wiki/ResourceLoader/Architecture#Flipping | ResourceLoader ]]. It works by taking in a stylesheet, converting various properties and values for RTL, and generating a RTL version of the input stylesheet. This stable solution represents over a decade of learning and iteration. To lean more about what CSSJanus actually does, check out the well-commented [[ https://github.com/cssjanus/cssjanus/blob/main/src/cssjanus.js#L353 | source code ]].
A [[ https://drafts.csswg.org/css-logical/ | new CSS spec ]], CSS Logical Properties and Values, has been introduced to resolve this problem at the language level. Not only does this spec remove the need for much of the flipping and conversion done by a tool like CSSJanus, it also encourages the use of //logical// design language rather than //directional//. Though the spec is still in stage 1 ("editor's draft", aka early), [[ https://caniuse.com/css-logical-props | browser support is progressing ]].
### Considerations for Codex
#### CSS Janus
Codex's largest use case is within MediaWiki, where ResourceLoader can use CSSJanus to create RTL stylesheets. However, we hope that Codex can also be used outside of MediaWiki, so we need to create a solution that will work in both contexts.
If we choose to use CSSJanus inside Codex:
- There is a PostCSS plugin for it
- Those using Codex inside MediaWiki can opt out of CSSJanus use by ResourceLoader
#### CSS logical properties and values
Using this new spec in Codex would allow us to demonstrate the future of direction-agnostic CSS. However, it comes down to browser support. We could consider PostCSS plugins.
#### Client-side language switching
This was discussed in [[ https://github.com/wikimedia/wvui/pull/76 | this PR ]]; we need to determine if this is a use case we must cover.
### Previous discussions
- RTL support in WVUI was extensively discussed [[ https://github.com/wikimedia/wvui/pull/76 | in this PR ]]. Some highlights:
- [[ https://github.com/wikimedia/wvui/pull/76#issuecomment-687652715 | Timo's comment ]] about the logical properties and values spec and browser support
- [[ https://github.com/wikimedia/wvui/pull/76#issuecomment-687661957 | Moriel's comment ]] on CSSJanus and client-side language switching
- [[ https://github.com/wikimedia/wvui/pull/76#issuecomment-688104793 | Santhosh's comment ]] on the importance of developing logical design language and CSS asset options
### Acceptance criteria
[] Decide how we will support bidirectionality in Codex's CSS
[] Consider when we might begin using CSS logical properties and values
[] Determine if we will support client-side language switching (and, if so, start talking about how)
[] Document these decisions and implementations in Codex for both Codex designers/developers and library users