Automatic RTL Conversion #935
-
Hey folks 👋🏻 As part of working on my design system, I've added the ability for Stitches to automatically convert styles to "mirrored", RTL-friendly styles (in my fork). My question is, is this something people would want to become a core feature of Stitches? Details
// Pre-conversion
const Regular = styled("div", {
background: "$gray1",
left: "0px",
marginRight: "20px",
})
// Post-conversion
const Fancy = styled("div", {
background: "$gray1",
"[dir='ltr'] &": { left: "0px", marginRight: "20px" },
"[dir='rtl'] &": { right: "0px", marginLeft: "20px" },
})
Suggested Implementation
Part of my objective was to make this code as clean as possible, so as to make my fork easier to maintain. That objective meant that I put all that logic into helper functions (which should make for a clean port), but also that I setup this conversion in a pre-generation step, that does a recursive search-and-replace on any style object passed into Stitches, which is not the most performant approach. The Stitches core team might have a suggestion on how to better integrate my logic with the current style-generation process, to reduce overhead. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Just a note that, with my suggested feature of support for pre-processors, this feature here would no longer need to be a core feature. If that gets approved, I might open source my RTL pre-processor, if anyone wants it. |
Beta Was this translation helpful? Give feedback.
Just a note that, with my suggested feature of support for pre-processors, this feature here would no longer need to be a core feature.
#993
If that gets approved, I might open source my RTL pre-processor, if anyone wants it.