Nominating Presidential Muppets

npm

Join us for the upcoming webinar, "Enterprise JavaScript done right: the tools you love, the security you need."Sign up here »

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'
        }
    }
});

install

npm i postcss-space-start-attrs

Downloadsweekly downloads

9

version

2.0.1

license

CC0-1.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability