Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

postcss-font-helpers

jedmao113MIT3.0.0

Font helpers for PostCSS.

postcss, font, helpers

readme

postcss-font-helpers

NPM version npm license Travis Build Status

npm

Font helpers for PostCSS.

Installation

$ npm install postcss-font-helpers [--save[-dev]]

Usage

var postcss = require('postcss');
var font = require('postcss-font-helpers');

var rule = postcss.parse([
    'a {',
    '  line-height: 1;',
    '  font: 1rem/1.2 serif;',
    '  font-size: .8rem;',
    '}'
].join('')).first;

// Get all props
font(rule); /*
{
    size: ".8rem",
    line-height: 1.2,
    family: ["serif"]
}
*/

// Get individual props
font.lineHeight(rule); // 1.2
font.size(rule);       // ".8rem"
font.family(rule);     // ["serif"]

See the tests for more scenarios.

Testing

$ npm test

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

changelog

3.0.0

  • Preserve functions with spaces and commas inside.

2.1.0

  • Module function call returns an object with all font properties.

2.0.0

1.0.1

  • Move PostCSS dependency to dev dependencies.

1.0.0

  • Initial release.