Git Product home page Git Product logo

css-flip's Introduction

css-flip Build Status

A CSS BiDi flipper. Generate left-to-right (LTR) or right-to-left (RTL) CSS from your source.

Installation

npm install css-flip

Example use

var flip = require('css-flip');
var css = 'div { float: left; }';

flip(css);
// => 'div { float: right; }'

As a Rework plugin:

var flip = require('css-flip');
var rework = require('rework');
var css = 'div { float: left; }';

rework(css).use(flip.rework()).toString();
// => 'div { float: right; }'

Supported CSS Properties (a-z)

background-position, background-position-x, border-bottom-left-radius, border-bottom-right-radius, border-color, border-left, border-left-color, border-left-style, border-left-width, border-radius, border-right, border-right-color, border-right-style, border-right-width, border-style, border-top-left-radius, border-top-right-radius, border-width, box-shadow, clear, direction, float, left, margin, margin-left, margin-right, padding, padding-left, padding-right, right, text-align transition transition-property

Processing directives

css-flip provides a way to ignore declarations or rules that should not be flipped, and precisely replace property values.

@noflip

Prevent a single declaration from being flipped.

Source:

p {
  /*@noflip*/ float: left;
  clear: left;
}

Yields:

p {
  float: left;
  clear: right;
}

Prevent all declarations in a rule from being flipped.

Source:

/*@noflip*/
p {
  float: left;
  clear: left;
}

Yields:

p {
  float: left;
  clear: left;
}

@replace

Replace the value of a single declaration. Useful for custom LTR/RTL adjustments, e.g., changing background sprite positions or using a different glyph in an icon font.

Source:

p {
  /*@replace: -32px -32px*/ background-position: -32px 0;
  /*@replace: ">"*/ content: "<";
}

Yields:

p {
  background-position: -32px -32px;
  content: ">";
}

CLI

The CLI can be used globally or locally in a package.

View available options:

css-flip --help

Example use:

css-flip path/to/file.css > path/to/file.rtl.css

Development

Run the lint and unit tests:

npm test

Just the JSHint tests:

npm run lint

Just the Mocha unit tests:

npm run unit

Run Mocha unit tests in "watch" mode:

npm run watch

License and Acknowledgements

Copyright 2014 Twitter, Inc. and other contributors.

Licensed under the MIT License

css-flip was inspired by ded/R2 and Closure Stylesheets.

css-flip's People

Contributors

brettstimmerman avatar caniszczyk avatar cvrebert avatar mathiasbynens avatar necolas 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.