GithubHelp home page GithubHelp logo

isabella232 / less-plugin-rtl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from less/less-plugin-rtl

0.0 0.0 0.0 179 KB

auto converts stylesheets from LTR to RTL

License: Apache License 2.0

JavaScript 60.68% CSS 39.32%

less-plugin-rtl's Introduction

NPM version Dependencies devDependency Status optionalDependency Status

less-plugin-rtl

Reverses less from ltr to rtl

.reverse {
  float: left;
  margin-left: 5px;
  margin: 1px 2px 3px 4px;
  & when (@rtl) {
    color: green;
  }
}

Becomes...

.reverse {
  float: right;
  margin-right: 5px;
  margin: 1px 4px 3px 2px;
  color: green;
}

To use with lessc

$ npm install -g less-plugin-rtl
$ lessc --rtl file.less out.css

Variables

Three variables are injected ltr and rtl which will be set to true or false and dir which will be set to rtl or ltr.

Property Reversing

To be more in control of properties that get reversed, you can specify property directives

.test {
    -ltr-padding: 0; // rule only appears in LTR
    -rtl-margin: 3px; // rule only appears in RTL
    -ltr-rtl-float: left; // rule does not get reversed in either direction if autoReverse is on
    -rtl-ltr-float: left; // rule does not get reversed in either direction if autoReverse is on
    -ltr-reverse-text-align: left; // rule gets reversed for LTR, so in this case RTL = left, LTR = right
    -rtl-reverse-text-align: left; // rule gets reversed for RTL, so in this case RTL = right, LTR = left
}

Note: The reverse rules only make sense if autoreverse is off.

And this produces in RTL..

.test {
    margin: 3px;
    float: left;
    float: left;
    text-align: left;
    text-align: right;
}

and in LTR...

.test {
    padding: 0;
    float: left;
    float: left;
    text-align: right;
    text-align: left;
}

CLI Options

$ lessc --rtl="dir=LTR auto-reverse=false vars=false" file.less out.css

auto-reverse

Whether rules should be auto reversed or require property directives as above. Defaults to true.

vars

Whether the variables should be available. Defaults to true.

dir

The intended direction. Defaults to RTL.

Programmatic Options

As above, but use dir, vars and autoReverse on the options object.

less-plugin-rtl's People

Contributors

jemavo avatar lukeapage avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.