npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

less-plugin-auto-rtl

v1.0.13

Published

Converts less to apply Rtl Rules when dir="rtl" is set in a parent element

Downloads

31

Readme

less-plugin-auto-rtl

With this plugin you can write your less files normally to cover ltr-languages. For all direction specifig rules like 'margin-left', there will be added a rtl rule ('margin-right') with a [dir="rtl"] selector. In you application you can now apply the rtl rules by adding the dir="rtl" tag to an element.

Setup

Install the plugin:

$ npm install less-plugin-auto-rtl

Use with less:

$ lessc --auto-rtl file.less out.css

Use with webpack and less-loader:

// webpack.config.js
const AutoRtlPlugin = require('less-plugin-auto-rtl');

module.exports = {
  ...
    {
      loader: 'less-loader', 
      options: {
        plugins: [
          new AutoRtlPlugin()
        ]
      }
    }]
  ...
};

Hint: when you have problems with compiling and dumpLineNumbers: "comments" in the options, try to remove it.

How to use

Use the normal styling (LTR):

<body>
  <p> This is LTR!</p>
</body>

Use the RTL styling:

<body dir="rtl">
  <p> This is RTL!</p>
</body>

Use the RTL styling and exclude some parts:

<body dir="rtl">
  <p> This is RTL!</p>
  <div dir="ltr">
    <p> This is LTR!</p>
  </div>
</body>

What will be converted?

| Rule |RTL Rule | | ------------- |-------------| | border-color: yellow green blue red | border-color: yellow red blue green | | border-left: 5px solid red | border-right: 5px solid red | | border-left-color: green | border-right-color: green | | border-left-style: solid | border-right-style: solid | | border-left-width: 5px | border-right-width: 5px | | border-right: 5px solid red | border-left: 5px solid red | | border-right-color: green | border-left-color: green | | border-right-style: solid | border-left-style: solid | | border-right-width: 5px | border-left-width: 5px | | border-style: solid dotted dashed hidden | border-style: solid hidden dashed dotted | | border-width: 10px 20px 30px 40px | border-width: 10px 40px 30px 20px | | border-top-left-radius: 5px | border-top-right-radius: 5px | | border-top-right-radius: 5px | border-top-left-radius: 5px | | border-bottom-left-radius: 5px | border-bottom-right-radius: 5px | | border-bottom-right-radius: 5px | border-bottom-left-radius: 5px | | box-shadow: 10px 20px | box-shadow: -10px 20px | | float: left | float: right | | float: right | float: left | | left: 5px | right: 5px | | margin: 10px 20px 30px 40px | margin: 10px 40px 30px 20px | | margin-left: 5px | margin-right: 5px | | margin-right: 5px | margin-left: 5px | | padding: 10px 20px 30px 40px | padding: 10px 40px 30px 20px | | padding-left: 5px | padding-right: 5px | | padding-right: 5px | padding-left: 5px | | right: 5px | left: 5px | | text-align: left | text-align: right | | text-align: right | text-align: left | | transform: translate(30px, 0) | transform: translate(-30px, 0) | | transform: translateX (30px) | transform: translateX (-30px) | | transform: translate3d (30px, 25px, 20px) | transform: translate3d (-30px, 25px, 20px) |

Specify direction

For single rules you can set a specific direction. Per default, rules for LTR will stay the same and there will an additional rule for RTL added, which is reversed. To create a rule that applies only on LTR or RTL or is in RTL and LTR the same, you have to specify this by a prefix.

-ltr-margin-left: 5px; // will only applied in dir="ltr"
-rtl-margin-left: 5px; // will only applied in dir="rtl"
-ltr-rtl-margin-left: 5px //rule will be the same in dir="ltr" and dir="rtl"; will not be reversed for dir="rtl"

Conversion Example

Less file:

.test {
  margin-left: 5px;
  padding: 10px 20px 30px 40px;
  text-align: left;
  transform: translate(30px, 10px);
  -rtl-left: 10px;
  -rtl-ltr-border-color: yellow green blue red;
}

Output css:

.test {
  margin-left: 5px;
  padding: 10px 20px 30px 40px;
  text-align: left;
  transform: translate(30px, 10px);
  border-color: yellow green blue red;
}
[dir="rtl"] .test,
:host-context([dir="rtl"]) .test {
  margin-left: initial;
  margin-right: 5px;
  padding: 10px 40px 30px 20px;
  text-align: right;
  transform: translate(-30px, 10px);
  left: 10px;
}
[dir="ltr"] .test,
:host-context([dir="ltr"]) .test {
  margin-right: initial;
  margin-left: 5px;
  padding: 10px 20px 30px 40px;
  text-align: left;
  transform: translate(30px, 10px);
}