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

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 - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

28

dist/fela-plugin-unit.js

@@ -147,16 +147,19 @@ (function (global, factory) {

function addUnit(style, unit) {
function addUnit(style, unit, propertyMap) {
Object.keys(style).forEach(function (property) {
if (!isUnitlessCSSProperty(property)) {
(function () {
var value = style[property];
if (Array.isArray(value)) {
style[property] = value.map(function (value) {
return addUnitIfNeeded(property, value, unit);
});
} else if (value instanceof Object) {
style[property] = addUnit(value, unit);
} else {
style[property] = addUnitIfNeeded(property, value, unit);
}
var value = style[property];
var propertyUnit = propertyMap[property] || unit;
if (Array.isArray(value)) {
style[property] = value.map(function (value) {
return addUnitIfNeeded(property, value, propertyUnit);
});
} else if (value instanceof Object) {
style[property] = addUnit(value, unit, propertyMap);
} else {
style[property] = addUnitIfNeeded(property, value, propertyUnit);
}
})();
}

@@ -170,2 +173,3 @@ });

var unit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'px';
var propertyMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -175,3 +179,3 @@ warning$1(unit.match(/ch|em|ex|rem|vh|vw|vmin|vmax|px|cm|mm|in|pc|pt|mozmm|%/) !== null, 'You are using an invalid unit `' + unit + '`. Consider using one of the following ch, em, ex, rem, vh, vw, vmin, vmax, px, cm, mm, in, pc, pt, mozmm or %.');

return function (style) {
return addUnit(style, unit);
return addUnit(style, unit, propertyMap);
};

@@ -178,0 +182,0 @@ });

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.FelaPluginUnit=t()}(this,function(){"use strict";function e(e,t){return t={exports:{}},e(t,t.exports),t.exports}function t(e,t,o){var r="undefined"==typeof t?"undefined":n.typeof(t);return("number"===r||"string"===r&&t==parseFloat(t))&&(t+=o),t}function o(e,n){return Object.keys(e).forEach(function(r){if(!u(r)){var i=e[r];Array.isArray(i)?e[r]=i.map(function(e){return t(r,e,n)}):i instanceof Object?e[r]=o(i,n):e[r]=t(r,i,n)}}),e}var n={};n.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n.extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e};var r=e(function(e){function t(e){return e.replace(o,"-$&").toLowerCase().replace(n,"-ms-")}var o=/[A-Z]/g,n=/^ms-/;e.exports=t}),i=r&&"object"==typeof r&&"default"in r?r.default:r,f=e(function(e){function t(e,t){return e+t.charAt(0).toUpperCase()+t.slice(1)}var o=i,n={borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},r={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridColumn:!0,order:!0,lineClamp:!0},f=["Webkit","ms","Moz","O"];Object.keys(r).forEach(function(e){n[e]=!0,f.forEach(function(o){n[t(o,e)]=!0})}),Object.keys(n).forEach(function(e){n[o(e)]=!0}),e.exports=function(e){return n[e]}}),u=f&&"object"==typeof f&&"default"in f?f.default:f,a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"px";return function(t){return o(t,e)}};return a});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.FelaPluginUnit=e()}(this,function(){"use strict";function t(t,e){return e={exports:{}},t(e,e.exports),e.exports}function e(t,e,o){var r="undefined"==typeof e?"undefined":n.typeof(e);return("number"===r||"string"===r&&e==parseFloat(e))&&(e+=o),e}function o(t,n,r){return Object.keys(t).forEach(function(i){u(i)||!function(){var f=t[i],u=r[i]||n;Array.isArray(f)?t[i]=f.map(function(t){return e(i,t,u)}):f instanceof Object?t[i]=o(f,n,r):t[i]=e(i,f,u)}()}),t}var n={};n.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n.extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t};var r=t(function(t){function e(t){return t.replace(o,"-$&").toLowerCase().replace(n,"-ms-")}var o=/[A-Z]/g,n=/^ms-/;t.exports=e}),i=r&&"object"==typeof r&&"default"in r?r.default:r,f=t(function(t){function e(t,e){return t+e.charAt(0).toUpperCase()+e.slice(1)}var o=i,n={borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},r={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridColumn:!0,order:!0,lineClamp:!0},f=["Webkit","ms","Moz","O"];Object.keys(r).forEach(function(t){n[t]=!0,f.forEach(function(o){n[e(o,t)]=!0})}),Object.keys(n).forEach(function(t){n[o(t)]=!0}),t.exports=function(t){return n[t]}}),u=f&&"object"==typeof f&&"default"in f?f.default:f,a=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"px",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){return o(n,t,e)}};return a});
{
"name": "fela-plugin-unit",
"version": "3.0.3",
"version": "3.0.4",
"description": "Fela plugin to automatically add units if required",

@@ -24,4 +24,4 @@ "main": "index.js",

"peerDependencies": {
"fela": "3.0.3"
"fela": "3.0.4"
}
}

@@ -5,3 +5,3 @@ # fela-plugin-unit

<img alt="npm downloads" src="https://img.shields.io/npm/dm/fela-plugin-unit.svg">
<img alt="gzipped size" src="https://img.shields.io/badge/gzipped-0.95kb-brightgreen.svg">
<img alt="gzipped size" src="https://img.shields.io/badge/gzipped-0.98kb-brightgreen.svg">

@@ -19,5 +19,5 @@ 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. <br>

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

@@ -43,2 +43,3 @@

| unit | `ch`, `em`, `ex`, `rem`, `vh`, `vw`, `vmin`, `vmax`, `px`, `cm`, `mm`, `in`, `pc`, `pt`, `mozmm` | `px` | unit which gets applied |
| unitPerProperty | *(Object)* | `{}` | Default units per property |

@@ -50,3 +51,6 @@ ##### Example

const unitPlugin = unit('em')
const unitPlugin = unit('em', {
margin: '%',
fontSize: 'pt'
})

@@ -60,3 +64,3 @@ const renderer = createRenderer({

## 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.
Using the above example code:

@@ -68,3 +72,5 @@ #### Input

lineHeight: 1.4,
height: '53'
height: '53',
fontSize: 15,
margin: 10
}

@@ -75,5 +81,7 @@ ```

{
width: '25px',
width: '25em',
lineHeight: 1.4,
height: '53px'
height: '53em',
fontSize: '15pt',
margin: '10%'
}

@@ -80,0 +88,0 @@ ```

Sorry, the diff of this file is not supported yet

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