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.
CSSJanus is the solution currently employed in MediaWiki via 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 source code.
A new CSS spec, CSS Logical Properties and Values, has been introduced to resolve this problem. 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), browser support is progressing.
Considerations for Codex
CSS Janus and/or PostCSS plugins
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 (not very active repo!)
- Those using Codex inside MediaWiki can opt out of CSSJanus use by ResourceLoader
A different approach would be PostCSS-RTL plugin for RTL-adaptivity
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 this PR; we need to determine if this is a use case we must cover.
Previous discussions
- RTL support in WVUI was extensively discussed in this PR. Some highlights:
- Timo's comment about the logical properties and values spec and browser support
- Moriel's comment on CSSJanus and client-side language switching
- Santhosh's comment on the importance of developing logical design language and CSS asset options
- Santhosh's comments here and here on using PostCSS to support bidirectionality in stylesheets
Acceptance criteria
- Decide how we will support bidirectionality in Codex's CSS
- Consider when we might begin using CSS logical properties and values (moved to T304017)
- 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