@xiwell/auto-styles
TypeScript icon, indicating that this package has built-in type declarations

7.0.8 • Public • Published

##Install

npm install @xiwell/auto-styles
yarn add @xiwell/auto-styles

##Usage

import autostyle from '@xiwell/auto-styles';

// Basic usage
console.log(
  autostyle({
    margin: 10,
    padding: 10
  }).px().toString()
); /* margin: 10px; padding: 10px */

// Use array
console.log(
  // string and object can be added to the array
  autostyle([
    {
      margin: 10,
      padding: 10
    },
    'fontSize: 10'
  ]).px().toString()
); /* margin: 10px; padding: 10px; font-size: 10px */

// Use function
console.log(
  autostyle(function (utils) {
    // return array || string || object
    return [
      'margin: 10',
      {
        padding: 10
      }
    ]
  }).px().toString()
); /* margin: 10px; padding: 10px; */

// force cover
console.log(
  autostyle('fontSize: 10px; margin: 10px!important')
    .rem()
    .toString()
); /* font-size: 10rem; margin: 10rem!important */

// use @ sign to ignore
console.log(
  autostyle({
    margin: '@10px',
    padding: 10
  }).rem().toString()
); /* margin: 10px; padding: 10rem */

##API

const style = autostyle(...args);
// unit
style.px();
style.pc();
style.pt();
style.rem();
style.em();
style.vh();
style.vw();
style.percent();
// return
style.px().toJSON();
style.px().toString();
style.px().toStringify()

Package Sidebar

Install

npm i @xiwell/auto-styles

Weekly Downloads

2

Version

7.0.8

License

ISC

Unpacked Size

50.6 kB

Total Files

7

Last publish

Collaborators

  • xiwell