Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
rtl-css-js
Advanced tools
The rtl-css-js npm package is designed to convert CSS styles written for left-to-right (LTR) layouts into right-to-left (RTL) layouts. This is particularly useful for developers creating or maintaining websites and applications that need to support multiple languages, including those read from right to left, such as Arabic and Hebrew. The package provides a straightforward API to transform CSS objects, making it easier to manage styles in multilingual projects.
Convert LTR CSS to RTL
Converts a CSS object with left-based properties to right-based ones for RTL support. For example, 'paddingLeft: 10px' becomes 'paddingRight: 10px'.
{"paddingLeft": "10px"}
Handle Flipping Values
Automatically flips certain CSS values to their opposite direction. For instance, 'textAlign: left' is converted to 'textAlign: right' for RTL layouts.
{"textAlign": "left"}
Ignore Specific Properties
Allows specific CSS properties to be ignored during the conversion process by using a special comment directive. This is useful for properties that should not change direction.
{"/* rtl:ignore */ paddingLeft": "10px"}
Similar to rtl-css-js, postcss-rtl is a PostCSS plugin that generates RTL stylesheets. The main difference is that postcss-rtl works at the CSS file level and is part of the PostCSS ecosystem, making it more suitable for projects already using PostCSS.
rtlcss is another npm package that focuses on converting LTR CSS to RTL. It provides more granular control over the conversion process compared to rtl-css-js, including the ability to define custom rules and directives within CSS files. rtlcss is often used directly in build processes or as part of a larger CSS processing pipeline.
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@1.0.0-beta.1"></script>
<script>
const styles = rtlCSSJS({paddingRight: 23})
console.log(styles) // logs {paddingLeft: 23}
</script>
CSSJanus was a major inspiration.
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 💻 ⚠️ 🚇 |
---|
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 rtl-css-js receives a total of 645,250 weekly downloads. As such, rtl-css-js popularity was classified as popular.
We found that 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.