css-flip

A CSS BiDi flipper

  • 所有者: twitter-archive/css-flip
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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.

概览

名称与所有者twitter-archive/css-flip
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证MIT License
发布数3
最新版本名称0.5.0 (发布于 2014-06-23 14:13:04)
第一版名称0.3.0 (发布于 2014-02-24 11:22:02)
创建于2014-02-24 17:16:28
推送于2016-11-16 19:48:03
最后一次提交2014-12-08 08:40:12
星数312
关注者数123
派生数35
提交数30
已启用问题?
问题数23
打开的问题数3
拉请求数5
打开的拉请求数1
关闭的拉请求数2
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?
去到顶部