Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-tailor

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-tailor

Tailor CSS from the HTML classes

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

✂ css-tailor

Build Status Code Coverage Package Version

Automatically generate CSS from your HTML classes

Utility that turns the classes applied upon the DOM elements to CSS. So that you don't have to manually write the CSS for those minor UI enhancements like increasing the padding, adding a little margin, changing the font size, applying a border radius, pumping up the line-height a bit etc.

Usage

All you have to do is specify the CSS class on an element: CSS will be generated and written to a CSS file of your liking or returned for any programmatical use.

All you have to do is specify any HTML class as follows

[formula][value][unit] # If you donot provide the unit, `px` will be used.

For example; mt25 translates to margin-top: 25px, fs14px to font-size: 14px; etc.

The list of supported formulae and examples is given below

Supported Formulae

Currently supported styles are as follows.

FormulaCSS PropertyExample Usage
ppaddingp10 will translate to padding: 10px
ptpadding-toppt20 will translate to padding-top: 20px;
pbpadding-bottompb10 will translate to padding-bottom: 10px;
prpadding-rightpr20 will translate to padding-right: 20px;
plpadding-leftpl23 will translate to padding-left: 23px;
mmarginm20 will translate to margin: 20px
mtmargin-topmt20 will translate to margin-top: 20px;
mbmargin-bottommb20 will translate to margin-bottom: 20px;
mlmargin-leftml50 will translate to margin-left: 50px;
mrmargin-rightmr30 will translate to margin-right: 30px;
wwidthw200 will translate to width: 200px
hheighth60 will translate to height: 60px;
brborder-radiusbr5 will translate to border-radius: 5px;
fsfont-sizefs15 will translate to font-size: 15px
fwfont-weightfw400 will translate to font-weight: 400px
lhline-heightlh20em will translate to line-height: 20em
ttopt6 will translate to top: 6px;
lleftl30 will translate to left: 30px
bbottomb20em will translate to bottom: 20em;
rrightr20em will translate to right: 20em;

Notes for Units

All the default CSS units are supported. You can specify it and relevant CSS unit will be used

  • Units including px, pt, em, p, vh, vw, vmin, ex, cm, in, mm, pc will translate to the same unit in CSS
  • If you don't provide any unit px will be used
  • If you need % specify it as p e.g. w50p will get translated to width: 50%
  • If no unit is needed, specify n e.g. fw600n will translate to font-weight: 600

Install

If you are looking for usage as a preprocessor, check gulp-css-tailor

$ npm install --save css-tailor
From a Directory

You can provide the path in the form of

  • string Path to a single file or a directory
  • array An array of directory paths, file paths or a mix of both the directory and file paths
var tailor = require('css-tailor');

// Will generate the output file [if required] and return the generated CSS
var generatedCss = tailor.generatePathCss('resources/html/', options)
From HTML string

Also you can generate CSS from the HTML string

var tailor = require('css-tailor');

// Will generate the output file [if required] and return the generated CSS
var generatedCss = tailor.generateCss('<html>...</html>', options)
Options

Both the functions above accept an object as a second argument having following options. (Values specified below are the defaults)

var options = {
    tabSpacing: 4,          // Tab spacing for the formatted CSS
    outputPath: '',         // Path to the output file where CSS is to be generated
    minifyOutput: false,    // Whether to minify the output while generating CSS
    setImportant: false     // Will add the `!important` flag to all the CSS properties
};

License

MIT © Kamran Ahmed

Keywords

FAQs

Package last updated on 16 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc