![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@andarist/rtl-css-js
Advanced tools
RTL conversion for CSS in JS objects
For some locales, it's necessary to change padding-left
to padding-right
when your text direction is right to left.
There are tools like this for CSS (cssjanus
for example) which manipulate
strings of CSS to do this, but none for CSS in JS where your CSS is represented by an object.
This is a function which accepts a CSS in JS object and can convert padding-left
to padding-right
as well as all
other properties where it makes sense to do that (at least, that's what it's going to be when it's done... This is a
work in progress).
This module is distributed via npm which is bundled with node and should
be installed as one of your project's dependencies
:
npm install --save rtl-css-js
This module is exposed via CommonJS as well as
UMD with the global as rtlCSSJS
CommonJS:
const rtlCSSJS = require('rtl-css-js')
const styles = rtlCSSJS({paddingLeft: 23})
console.log(styles) // logs {paddingRight: 23}
You can also just include a script tag in your browser and use the rtlCSSJS
variable:
<script src="https://unpkg.com/rtl-css-js"></script>
<script>
const styles = rtlCSSJS({paddingRight: 23})
console.log(styles) // logs {paddingLeft: 23}
</script>
You can also control which rules you don't want to flip by adding a /* @noflip */
CSS comment to your rule
const rtlCSSJS = require('rtl-css-js')
const styles = rtlCSSJS({paddingLeft: '20px /* @noflip */'})
console.log(styles) // logs {paddingLeft: '20px /* @noflip */' }
This library support kebab-case properties too.
const rtlCSSJS = require('rtl-css-js')
const styles = rtlCSSJS({'padding-right': 23})
console.log(styles) // logs {'padding-left': 23}
rtl-css-js
also exposes its internal helpers and utilities so you can deal
with certain scenarios
yourself. To use these you can use the rtlCSSJSCore
global with the UMD build,
require('rtl-css-js/core')
, or use
import {propertyValueConverters, arrayToObject} from 'rtl-css-js/core.esm'
.
You can import anything that's exported from src/core
. Please see the code
comments for documentation on how to use these.
background
Right now background
and backgroundImage
just replace all instances of ltr
with rtl
and right
with left
.
This is so you can have a different image for your LTR and RTL, and in order to flip linear gradients. Note that
this is case sensitive! Must be lower case. Note also that it will not change bright
to bleft
.
It's a little smarter than that. But this is definitely something to consider with your URLs.
CSSJanus was a major inspiration.
react-with-styles
with Aphroditertl-css-js
's core.I'm not aware of any, if you are please make a pull request and add it here!
Thanks goes to these people (emoji key):
Kent C. Dodds 💻 ⚠️ 🚇 | Ahmed El Gabri 💻 📖 ⚠️ | Maja Wichrowska 💻 ⚠️ | Yaniv 💻 ⚠️ | Jonathan Pollak 💻 ⚠️ | Ali Taheri Moghaddar 💻 📖 ⚠️ | garrettberg 💻 ⚠️ |
---|
This project follows the all-contributors specification. Contributions of any kind welcome!
MIT
FAQs
Right To Left conversion for CSS in JS objects
The npm package @andarist/rtl-css-js receives a total of 5 weekly downloads. As such, @andarist/rtl-css-js popularity was classified as not popular.
We found that @andarist/rtl-css-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.