postcss-space-start-attrs

2.0.1 • Public • Published

Space Start Attributes PostCSS Logo

NPM Version Build Status Licensing Changelog Gitter Chat

Space Start Attributes targets attributes beginning with a certain value in a space separated list in CSS.

/* before */
 
div[data-thing~^"starts-with"] {
    background-color: red;
}
 
div:not([data-thing~^"starts-with"]) {
    background-color: blue;
}
 
/* after */
 
div[class^="starts-with"],div[class*=" starts-with"] {
    background-color: red;
}
 
div:not([class^="starts-with"],[class*=" starts-with"]) {
    background-color: blue;
}

Note: The above example generates a W3C CSS level 4 :not() selector. I recommend using Selector Not to transpile this to a more compatible CSS level 3 selector.

Usage

Add Space Start Attributes to your build tool:

npm install postcss-space-start-attrs --save-dev

Node

require('postcss-space-start-attrs').process(YOUR_CSS, { /* options */ });

PostCSS

Add PostCSS to your build tool:

npm install postcss --save-dev

Load Space Start Attributes as a PostCSS plugin:

postcss([
    require('postcss-space-start-attrs')({ /* options */ })
]).process(YOUR_CSS, /* options */);

Gulp

Add Gulp PostCSS to your build tool:

npm install gulp-postcss --save-dev

Enable Space Start Attributes within your Gulpfile:

var postcss = require('gulp-postcss');
 
gulp.task('css', function () {
    return gulp.src('./src/*.css').pipe(
        postcss([
            require('postcss-space-start-attrs')({ /* options */ })
        ])
    ).pipe(
        gulp.dest('.')
    );
});

Grunt

Add Grunt PostCSS to your build tool:

npm install grunt-postcss --save-dev

Enable Space Start Attributes within your Gruntfile:

grunt.loadNpmTasks('grunt-postcss');
 
grunt.initConfig({
    postcss: {
        options: {
            use: [
                require('postcss-space-start-attrs')({ /* options */ })
            ]
        },
        dist: {
            src: '*.css'
        }
    }
});

Package Sidebar

Install

npm i postcss-space-start-attrs

Weekly Downloads

0

Version

2.0.1

License

CC0-1.0

Last publish

Collaborators

  • romainmenke
  • alaguna
  • jonathantneal