@xiwell/auto-styles
v7.0.8
Published
auto-styles
Downloads
5
Readme
##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()