parse-css-sides
Parses CSS sides (e.g., margin, padding, border) into an object.
Last updated 3 years ago by jedmao .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install parse-css-sides 
SYNC missed versions from official npm registry.

parse-css-sides

NPM version npm license Travis Build Status codecov Downloads Minified size Gzip size Unicorn Approved

npm

This package exports a default function that parses CSS sides (e.g., the value of margin, padding and border declarations).

Originally created for PostCSS plugins.

Installation

$ npm install parse-css-sides [--save[-dev]]

Usage

JavaScript

import parseSides from 'parse-css-sides';
const sides = parseSides('0 5% 10px');
/**
 * {
 *   top: '0',
 *   right: '5%',
 *   bottom: '10px',
 *   left: '5%',
 * }
 **/

All 4 sides are always returned and are always strings.

Note: if !important is found, an additional important: true will be added to the result.

TypeScript

This is a TypeScript project with generated type definitions included. There is an additional ISides interface that is exported if you need it for whatever reason. It just defines the shape of the result:

interface ISides {
	top: string
	right: string
	bottom: string
	left: string
	important?: boolean
}

Testing

$ npm test

This will run the tests in watch mode.

$ npm run cover

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

Current Tags

  • 3.0.1                                ...           latest (3 years ago)

4 Versions

  • 3.0.1                                ...           3 years ago
  • 3.0.0                                ...           3 years ago
  • 2.0.0                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Total 262
Today 0
This Week 4
This Month 4
Last Day 0
Last Week 0
Last Month 3
Dependencies (1)
Dev Dependencies (8)

Copyright 2014 - 2021 © npmmirror.com |