项目作者: jedmao

项目描述 :
PostCSS plugin to unwrap nested properties.
高级语言: TypeScript
项目地址: git://github.com/jedmao/postcss-nested-props.git
创建时间: 2015-07-10T06:41:52Z
项目社区:https://github.com/jedmao/postcss-nested-props

开源协议:MIT License

下载


postcss-nested-props

NPM version
npm license
Travis Build Status
codecov
Dependency Status

npm

PostCSS plugin to unwrap nested properties.

Nested Properties

CSS has quite a few properties that are in “namespaces;” for instance, font-family, font-size, and font-weight are all in the font namespace. In CSS, if you want to set a bunch of properties in the same namespace, you have to type it out each time. This plugin provides a shortcut: just write the namespace once, then nest each of the sub-properties within it. For example:

  1. .funky {
  2. font: {
  3. family: fantasy;
  4. size: 30em;
  5. weight: bold;
  6. }
  7. }

is compiled to:

  1. .funky {
  2. font-family: fantasy;
  3. font-size: 30em;
  4. font-weight: bold;
  5. }

The property namespace itself can also have a value. For example:

  1. .funky {
  2. font: 20px/24px fantasy {
  3. weight: bold;
  4. }
  5. }

is compiled to:

  1. .funky {
  2. font: 20px/24px fantasy;
  3. font-weight: bold;
  4. }

For nested rules, use the postcss-nested plugin, but make sure to run it after this one.

Installation

  1. $ npm install postcss-nested-props

Usage

JavaScript

  1. postcss([ require('postcss-nested-props') ]);

TypeScript

  1. import * as postcssNestedProps from 'postcss-nested-props';
  2. postcss([ postcssNestedProps ]);

Options

None at this time.

Testing

Run the following command:

  1. $ npm test

This will build scripts, run tests and generate a code coverage report. Anything less than 100% coverage will throw an error.

Watching

For much faster development cycles, run the following commands in 2 separate processes:

  1. $ npm run build:watch

Compiles TypeScript source into the ./dist folder and watches for changes.

  1. $ npm run watch

Runs the tests in the ./dist folder and watches for changes.