Detalhes do pacote

postcss-conditionals

andyjansson29.1kMIT2.1.0

PostCSS plugin that enables @if statements in your CSS

postcss, css, postcss-plugin, conditional

readme (leia-me)

postcss-conditionals Build Status

PostCSS plugin that enables @if statements in your CSS.

Installation

npm install postcss-conditionals

Usage

var fs = require('fs');
var postcss = require('postcss');
var conditionals = require('postcss-conditionals');

var css = fs.readFileSync('input.css', 'utf8');

var output = postcss()
  .use(conditionals)
  .process(css)
  .css;

Using this input.css:

.foo {
  @if 3 < 5 {
    background: green;
  }
  @else {
    background: blue;
  }
}

you will get:

.foo {
  background: green;
}

Also works well with postcss-simple-vars:

$type: monster;
p {
  @if $type == ocean {
    color: blue;
  } @else if $type == matador {
    color: red;
  } @else if $type == monster {
    color: green;
  } @else {
    color: black;
  }
}

and with postcss-for:

@for $i from 1 to 3 {
  .b-$i {
    width: $i px;
    @if $i == 2 {
      color: green;
    }
  }
}

Development

  1. Clone repository
  2. Install dependencies npm install
  3. If parser.jison file has been changed, regenerate parser.js by running npm run gen-parser

changelog (log de mudanças)

2.1.0 - 2016-12-21

  • Add support for double-quoted strings #16.

2.0.3 - 2016-11-10

  • Fix string token to include dots, enabling use of class names (among other things) in expressions

2.0.2 - 2016-03-02

  • Fix parsing of strings with escape character used for escaping characters other than single quotes #12

2.0.1 - 2016-01-20

  • Allow for quoted empty strings

2.0.0 - 2015-09-01

  • Update to PostCSS v5.

1.4.0 - 2015-09-01

  • Fix value type being incorrectly transformed for certain unit types.
  • Expand mixed-type operations to include things such as comparisons of differently typed values.

1.3.1 - 2015-08-24

  • Fix @else incorrectly being invoked when any statement other than the one directly preceding the @else is true.

1.3.0 - 2015-08-19

  • Add support for nested if statements
  • Add boolean data type

1.2.0 - 2015-05-27

  • Add transformations and comparisons of color values

1.1.2 - 2015-05-26

  • Fix parsing of negative values #2

1.1.1 - 2015-05-18

  • Add arithmetics for CSS units

1.0.0 - 2015-05-05

  • Initial release