Handy mixins for bidirectional css inspired by flex-start & flex-end behavior.
ℹ️ Input
div
+padding-start(5px)
+padding-end(10px)
+margin-start(5px)
+margin-end(10px)
div {
padding-left: 5px;
padding-right: 10px;
margin-left: 5px;
margin-right: 10px;
}
div {
padding-right: 5px;
padding-left: 10px;
margin-right: 5px;
margin-left: 10px;
}
html[dir='ltr'] div {
padding-left: 5px;
padding-right: 10px;
}
html[dir='rtl'] div {
padding-left: 10px;
padding-right: 5px;
}
html[dir='ltr'] div {
margin-left: 5px;
margin-right: 10px;
}
html[dir='rtl'] div {
margin-left: 10px;
margin-right: 5px;
}
$ yarn add sass-startend
To produce a single CSS for both LTR & RTL (You must specifiy direction in your html <html dir="rtl">
):
@import "~sass-startend/mixins/bidirectional"
// Your sass here
To produce a single CSS for each direction (You must have 2 entry files):
// RTL
$direction: rtl;
@import "~sass-startend/mixins/monodirectional"
// Your sass here
// LTR
$direction: ltr;
@import "~sass-startend/mixins/monodirectional"
// Your sass here
Take a look at bidi.sass, ltr.sass & rtl.sass in this repo.
This project is licensed under the MIT License