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

Could it be possible to generate a RTL or a LTR version based on the html lang attribute? #86

Open
Chorer opened this issue May 4, 2023 · 1 comment

Comments

@Chorer
Copy link

Chorer commented May 4, 2023

Although there is an onlyDirection option in .postcssrc.js for us to config, it can only receive ltr or rtl string explicitly. We couldn't dynamically pass a value based on the html lang attribute. My project set the lang attribute for html tag in runtime, but this plugin set the onlyDirection option when compiling, which happens before runtime. I don't quite sure if this is the reason why it is hard to generate a RTL or a LTR version dynamically.

@fabercancio
Copy link

Hi @Chorer,
This is a PostCSS plugin. PostCSS is intended to process a CSS input and output a result with the transformations applied by the plugins, it is not intended to process CSS at runtime. Why don‘t you generate LTR and RTL versions separately using RTLCSS (which this plugin uses behind the scenes) and load the correct CSS version from the back-end code that renders your HTML? Or in case that you don‘t have any back-end you could load the CSS dynamically using JavaScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants