Socket
Socket
Sign inDemoInstall

fela-plugin-unit

Package Overview
Dependencies
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fela-plugin-unit

Fela plugin to automatically add units if required


Version published
Weekly downloads
22K
increased by7.36%
Maintainers
1
Weekly downloads
 
Created
Source

fela-plugin-unit

npm downloads gzipped size

Always writing length values as string with a value applied seems not like the JavaScript way to do it. You can also use mathematics to process number values.
It is aware of unitless properties such as lineHeight and also adds units to multiple values inside an array.

Installation

npm i --save fela-plugin-unit

Assuming you are using npm as your package mananger you can just npm install.
Otherwise we also provide a UMD. You can easily use it via npmcdn. It registers a FelaPluginUnit global.

<!-- Fela (Development): Unminified version including all warnings -->
<script src="https://npmcdn.com/fela-plugin-unit@1.0.1/dist/fela-plugin-unit.js"></script>
<!-- Fela (Production): Minified version -->
<script  src="https://npmcdn.com/fela-plugin-unit@1.0.1/dist/fela-plugin-unit.min.js"></script>

Example

Let's say we want to have a custom property size that accepts a single number which will then be transformed into both width and height with a px unit applied.

Input
{
  width: 25,
  lineHeight: 1.4,
  height: '53'
}
Output
{
  width: '25px',
  lineHeight: 1.4,
  height: '53px'
}

Configuration

By default it adds px to the value, but you may use units other than that.

import unit from 'fela-plugin-unit'

const plugin = unit('em')

License

Fela is licensed under the MIT License.
Documentation is licensed under Creative Common License.
Created with ♥ by @rofrischmann and all the great contributors.

Keywords

FAQs

Package last updated on 29 Jun 2016

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