2.0.1 • Published 7 years ago

postcss-space-start-attrs v2.0.1

Weekly downloads
2
License
CC0-1.0
Repository
github
Last release
7 years ago

Space Start Attributes

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