All Projects → Scrum → Postcss At Rules Variables

Scrum / Postcss At Rules Variables

Licence: mit
PostCss plugin to use CSS Custom Properties in at-rule @each, @for, @if, @else and more...

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Postcss At Rules Variables

Postcss Aspect Ratio Mini
A PostCSS plugin to fix an element's dimensions to an aspect ratio
Stars: ✭ 123 (+136.54%)
Mutual labels:  postcss, postcss-plugins
laggard
Automatically generate CSS fallbacks for legacy browsers, built on PostCSS
Stars: ✭ 23 (-55.77%)
Mutual labels:  postcss, postcss-plugins
Rucksack
A little bag of CSS superpowers, built on PostCSS
Stars: ✭ 1,861 (+3478.85%)
Mutual labels:  postcss, postcss-plugins
Postcss Plugins
The "officially unofficial" consolidated list of PostCSS plugins in a ready-to-use package
Stars: ✭ 107 (+105.77%)
Mutual labels:  postcss, postcss-plugins
Postcss Cssnext
`postcss-cssnext` has been deprecated in favor of `postcss-preset-env`.
Stars: ✭ 5,388 (+10261.54%)
Mutual labels:  postcss, postcss-plugins
Postcss Instagram
📷 PostCSS plugin for using Instagram filters in CSS
Stars: ✭ 111 (+113.46%)
Mutual labels:  postcss, postcss-plugins
postcss-if-media
A PostCSS plugin to inline or nest media queries within CSS rules & properties.
Stars: ✭ 35 (-32.69%)
Mutual labels:  postcss, postcss-plugins
Postcss High Contrast
Create high contrast version of your project with ease.
Stars: ✭ 108 (+107.69%)
Mutual labels:  postcss, postcss-plugins
Postcss Utilities
PostCSS plugin to add a collection of mixins, shortcuts, helpers and tools for your CSS
Stars: ✭ 293 (+463.46%)
Mutual labels:  postcss, postcss-plugins
react-cli
基于 create-react-app 搭建的前端脚手架
Stars: ✭ 18 (-65.38%)
Mutual labels:  postcss, postcss-plugins
Postcss Font Family System Ui
PostCSS plugin to transform W3C CSS font-family: system-ui to a practical font-family list
Stars: ✭ 91 (+75%)
Mutual labels:  postcss, postcss-plugins
Stencil Postcss
Autoprefixer plugin for Stencil
Stars: ✭ 19 (-63.46%)
Mutual labels:  postcss, postcss-plugins
Stylefmt
stylefmt is a tool that automatically formats stylesheets.
Stars: ✭ 2,123 (+3982.69%)
Mutual labels:  postcss, postcss-plugins
postcss-gtk
Processes GTK+ CSS into browser CSS
Stars: ✭ 23 (-55.77%)
Mutual labels:  postcss, postcss-plugins
Postcss Start To End
PostCSS plugin that lets you control your layout (LTR or RTL) through logical rather than physical rules
Stars: ✭ 18 (-65.38%)
Mutual labels:  postcss, postcss-plugins
Postcss Selector Not
PostCSS plugin to transform :not() W3C CSS level 4 pseudo class to more compatible CSS (multiple css3 :not() selectors)
Stars: ✭ 49 (-5.77%)
Mutual labels:  postcss, postcss-plugins
Gradle Dependencies Plugins Helper Plugin
This is an IntelliJ IDEA plugin for searching dependencies/plugins from JCentral/GradlePlugins inside Gradle projects.
Stars: ✭ 31 (-40.38%)
Mutual labels:  plugins
Postjss
Use the power of PostCSS in compiling with JSS
Stars: ✭ 40 (-23.08%)
Mutual labels:  postcss
Jekyll Boilerplate
Helpful files to get started working on a new Jekyll website
Stars: ✭ 30 (-42.31%)
Mutual labels:  postcss
Sapper Template Firebase
Starter Rollup template for Sapper apps with Firebase functions based on https://github.com/nhristov/sapper-template-rollup.
Stars: ✭ 29 (-44.23%)
Mutual labels:  postcss

postcss-at-rules-variables

PostCSS plugin to transform W3C CSS Custom Properties for at-rule’s parameters.

Travis Build StatusAppVeyor Build Statusnodenpm versionDependency StatusXO code styleCoveralls status

npm downloadsnpmPackage Quality

Why?

Adds the ability to use a custom property in the options, at-rules.
Used in conjunction with the plugin postcss-each, postcss-conditionals, postcss-for and more at-rules plugins.

Install

$ npm install --save-dev postcss postcss-at-rules-variables

Note: This project is compatible with node v10+

Usage

// Dependencies
var fs = require('fs');
var postcss = require('postcss');
var colorFunction = require('postcss-color-function');
var atImport = require('postcss-import');
var atEach = require('postcss-each');
var atVariables = require('postcss-at-rules-variables');
var atIf = require('postcss-conditionals');
var atFor = require('postcss-for');
var cssVariables = require('postcss-css-variables');
var nested = require('postcss-nested');

// CSS to be processed
var css = fs.readFileSync('css/input.css', 'utf8');

// Process CSS
var output = postcss()
  .use(atVariables({ /* atRules: ['media'] */ }))
  .use(colorFunction())
  .use(atEach())
  .use(atImport({
    plugins: [
      require('postcss-at-rules-variables')({ /* options */ }),
      require('postcss-import')
    ]
  }))
  .use(atFor())
  .use(atIf())
  .use(cssVariables())
  .use(nested())
  .process(css, {
    from: 'css/input.css'
  })
  .css;

console.log(output);

Use postcss-at-rules-variables before you at-rules plugins

Example

/* input.css */
:root {
    --array: foo, bar, baz;
    --from: 1;
    --to: 3;
    --icon-exclude: 2;
    --color-danger: red;
    --nested-variable: color(var(--color-danger) a(90%)) ;
}

@each $val in var(--array) {
    @import "$val.css";
}
/* foo.css */
html {
    background-color: var(--color-danger);
    color: var(--nested-variable);
}
/* bar.css */
.some-class {
    color: #fff;

    @for $val from var(--from) to var(--to) {
        @if $val != var(--icon-exclude) {
            .icon-$val {
                background-position: 0 $(val)px;
            }
        }
    }
}
/* baz.css */
h1 {
    font-size: 24px;
}

@import "biz.css";
/* biz.css */
h2 {
    color: olive;
}
/* Output example */
html {
    background-color: red;
    color: rgba(255, 0, 0, 0.9);
}

.some-class {
    color: #fff;
}

.some-class .icon-1 {
    background-position: 0 1px;
}

.some-class .icon-3 {
    background-position: 0 3px;
}

h1 {
    font-size: 24px;
}

h2 {
    color: olive;
}

Options

atRules

Type: Array
Default: ['for', 'if', 'else', 'each', 'mixin', 'custom-media']
Description: The array used in all at-rules in your project

variables

Type: Object
Default: {}
Description: Allows you to pass an object of variables for :root. These definitions will override any that exist in the CSS

declarationByWalk

Type: boolean
Default: false
Description: Searches for root declarations by traversing all declarations before interpolating them.

⚠️ Attention, this approach is slower and carries the risk of overriding existing variables

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].