https://github.com/csstools/postcss-identifiers
Use identifiers in CSS to write intelligent shorthands
https://github.com/csstools/postcss-identifiers
Last synced: 11 months ago
JSON representation
Use identifiers in CSS to write intelligent shorthands
- Host: GitHub
- URL: https://github.com/csstools/postcss-identifiers
- Owner: csstools
- License: cc0-1.0
- Created: 2017-04-24T00:59:34.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-13T03:02:48.000Z (almost 9 years ago)
- Last Synced: 2024-05-22T20:21:46.207Z (almost 2 years ago)
- Language: JavaScript
- Homepage: https://jonathantneal.github.io/postcss-identifiers/
- Size: 39.1 KB
- Stars: 3
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PostCSS Identifiers [
][postcss]
[![NPM Version][npm-img]][npm-url]
[![Build Status][cli-img]][cli-url]
[![Licensing][lic-img]][lic-url]
[![Changelog][log-img]][log-url]
[![Gitter Chat][git-img]][git-url]
[PostCSS Identifiers] lets you use identifiers in CSS to write intelligent
shorthands. And unlike shorthands, identifiers don’t reset every value.
```css
.margin-inline-auto {
margin: [inline] auto;
}
.position-start {
position: [type] absolute [start] 0;
}
/* after */
.margin-inline-auto {
margin-left: auto;
margin-right: auto;
}
.position-start {
position: absolute;
left: 0;
top: 0;
}
```
Direction | Shorthands | Resulting Properties
-------------------- | ----------- | ---------------------
`inline` | `i` `-` | left right
`block` | `b` `\|` | top bottom
`start` | `s` | left top
`end` | `e` | right bottom
`inline-start` | `is` `<` | left
`inline-end` | `ie` `>` | right
`block-start` | `bs` `^` | top
`block-end` | `be` `v` | bottom
`block-inline-start` | `bis` `\|<` | left top bottom
`block-inline-end` | `bie` `\|>` | right top bottom
`inline+block-start` | `ibs` `-^` | left right top
`inline+block-end` | `ibe` `-v` | left right bottom
*(all directions)* | `+` | left right top bottom
## Usage
Add [PostCSS Identifiers] to your build tool:
```bash
npm install postcss-identifiers --save-dev
```
#### Node
Use [PostCSS Identifiers] to process your CSS:
```js
require('postcss-identifiers').process(YOUR_CSS, { /* options */ });
```
#### PostCSS
Add [PostCSS] to your build tool:
```bash
npm install postcss --save-dev
```
Use [PostCSS Identifiers] as a plugin:
```js
postcss([
require('postcss-identifiers')({ /* options */ })
]).process(YOUR_CSS, /* options */);
```
#### Gulp
Add [Gulp PostCSS] to your build tool:
```bash
npm install gulp-postcss --save-dev
```
Use [PostCSS Identifiers] in your Gulpfile:
```js
var postcss = require('gulp-postcss');
gulp.task('css', function () {
return gulp.src('./src/*.css').pipe(
postcss([
require('postcss-identifiers')({ /* options */ })
])
).pipe(
gulp.dest('.')
);
});
```
#### Grunt
Add [Grunt PostCSS] to your build tool:
```bash
npm install grunt-postcss --save-dev
```
Use [PostCSS Identifiers] in your Gruntfile:
```js
grunt.loadNpmTasks('grunt-postcss');
grunt.initConfig({
postcss: {
options: {
use: [
require('postcss-identifiers')({ /* options */ })
]
},
dist: {
src: '*.css'
}
}
});
```
[npm-url]: https://www.npmjs.com/package/postcss-identifiers
[npm-img]: https://img.shields.io/npm/v/postcss-identifiers.svg
[cli-url]: https://travis-ci.org/jonathantneal/postcss-identifiers
[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-identifiers.svg
[lic-url]: LICENSE.md
[lic-img]: https://img.shields.io/npm/l/postcss-identifiers.svg
[log-url]: CHANGELOG.md
[log-img]: https://img.shields.io/badge/changelog-md-blue.svg
[git-url]: https://gitter.im/postcss/postcss
[git-img]: https://img.shields.io/badge/chat-gitter-blue.svg
[PostCSS Identifiers]: https://github.com/jonathantneal/postcss-identifiers
[PostCSS]: https://github.com/postcss/postcss
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss