Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jednano/parse-css-font
Parses the CSS font property value.
https://github.com/jednano/parse-css-font
css font font-property npm parse shorthand
Last synced: about 2 months ago
JSON representation
Parses the CSS font property value.
- Host: GitHub
- URL: https://github.com/jednano/parse-css-font
- Owner: jednano
- License: mit
- Created: 2015-07-13T03:06:10.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-01T22:31:18.000Z (almost 2 years ago)
- Last Synced: 2024-05-02T05:46:58.105Z (8 months ago)
- Topics: css, font, font-property, npm, parse, shorthand
- Language: TypeScript
- Size: 385 KB
- Stars: 21
- Watchers: 2
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# parse-css-font
[![NPM version](http://img.shields.io/npm/v/parse-css-font.svg?style=flat)](https://www.npmjs.org/package/parse-css-font)
[![npm license](http://img.shields.io/npm/l/parse-css-font.svg?style=flat-square)](https://www.npmjs.org/package/parse-css-font)
[![Travis Build Status](https://img.shields.io/travis/jedmao/parse-css-font.svg)](https://travis-ci.org/jedmao/parse-css-font)
[![codecov](https://codecov.io/gh/jedmao/parse-css-font/branch/master/graph/badge.svg)](https://codecov.io/gh/jedmao/parse-css-font)
[![BundlePhobia Minified](https://badgen.net/bundlephobia/min/parse-css-font?label=min)](https://bundlephobia.com/result?p=parse-css-font)
[![BundlePhobia Minified + gzip](https://badgen.net/bundlephobia/minzip/parse-css-font?label=min%2Bgzip)](https://bundlephobia.com/result?p=parse-css-font)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Unicorn Approved](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://twitter.com/sindresorhus/status/457989012528316416?ref_src=twsrc%5Etfw&ref_url=https%3A%2F%2Fwww.quora.com%2FWhat-does-the-unicorn-approved-shield-mean-in-GitHub)[![npm](https://nodei.co/npm/parse-css-font.svg?downloads=true)](https://nodei.co/npm/parse-css-font/)
Parses the CSS [font property](https://developer.mozilla.org/en-US/docs/Web/CSS/font#font-variant-css21).
## Installation
```
$ npm install parse-css-font [--save[-dev]]
```## Usage
```js
const parseCSSFont = require('parse-css-font')
parseCSSFont('1rem "Roboto Condensed", sans-serif;')
/*
{
size: '1rem',
family: ['Roboto Condensed', 'sans-serif'],
style: 'normal',
variant: 'normal',
weight: 'normal',
stretch: 'normal',
lineHeight: 'normal'
}
*/
```See [the tests](https://github.com/jedmao/parse-css-font/blob/master/src/index.test.ts) for more scenarios.
### ES6/2015 import
```ts
import parseCSSFont from 'parse-css-font'
```## Testing
```
$ npm test
```This will run tests and generate a code coverage report. Anything less than 100% coverage will throw an error.