Comparing version 0.2.2 to 0.2.3
@@ -6,6 +6,8 @@ 'use strict'; | ||
}); | ||
exports.ex = exports.pc = exports.cm = exports.vmin = exports.mm = exports.inch = exports.vw = exports.vh = exports.pt = exports.rad = exports.em = exports.percent = exports.px = exports.dim = exports.colorFunctions = exports.callable = exports.lessly = exports.parse = undefined; | ||
exports.dimensions = exports.ex = exports.pc = exports.cm = exports.vmin = exports.mm = exports.inch = exports.vw = exports.vh = exports.pt = exports.rad = exports.em = exports.percent = exports.px = exports.dim = exports.colorFunctions = exports.callable = exports.lessly = exports.parse = undefined; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -85,2 +87,4 @@ | ||
function bindParse(func, vars) { | ||
var convert = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2]; | ||
return function () { | ||
@@ -94,3 +98,8 @@ for (var _len = arguments.length, args = Array(_len), _key2 = 0; _key2 < _len; _key2++) { | ||
}); | ||
var result = func.apply(undefined, _toConsumableArray(finalArgs.map(_parser2.default))).toCSS(); | ||
var result = func.apply(undefined, _toConsumableArray(finalArgs.map(function () { | ||
return convert ? _parser2.default.apply(undefined, arguments) : arguments.length <= 0 ? undefined : arguments[0]; | ||
}))); | ||
if (convert) { | ||
result = result.toCSS(); | ||
} | ||
return isNaN(result) ? result : Number(result); | ||
@@ -110,3 +119,3 @@ }; | ||
return Object.keys(_functions.callable).reduce(function (pointer, key) { | ||
defaulFunction = Object.keys(_functions.callable).reduce(function (pointer, key) { | ||
var func = _functions.callable[key]; | ||
@@ -116,2 +125,10 @@ pointer[key] = bindParse(func, vars); | ||
}, defaulFunction); | ||
defaulFunction = Object.keys(dimensions).reduce(function (pointer, key) { | ||
var func = dimensions[key]; | ||
pointer[key] = bindParse(func, vars, false); | ||
return pointer; | ||
}, defaulFunction); | ||
return defaulFunction; | ||
} | ||
@@ -131,7 +148,7 @@ | ||
function isPlainObj(o) { | ||
return (typeof o === 'undefined' ? 'undefined' : _typeof(o)) == 'object' && o.constructor == Object; | ||
} | ||
function dimension(val, unit) { | ||
if (unit === undefined) { | ||
return op(val); | ||
} | ||
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key3 = 2; _key3 < _len2; _key3++) { | ||
@@ -141,2 +158,11 @@ args[_key3 - 2] = arguments[_key3]; | ||
if (isPlainObj(val)) { | ||
return Object.keys(val).reduce(function (pointer, key) { | ||
var subVal = val[key]; | ||
return _extends({}, pointer, _defineProperty({}, key, dimension.apply(undefined, [subVal, unit].concat(args)))); | ||
}, {}); | ||
} | ||
if (unit === undefined) { | ||
return op(val); | ||
} | ||
if (args.length) { | ||
@@ -253,2 +279,6 @@ return op(toOps.apply(undefined, [val, unit].concat(args))); | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9sZXNzbHkuanMiXSwibmFtZXMiOlsidGhlbWUiLCJkaW1lbnNpb24iLCJ2YWx1ZSIsInBhcnNlIiwiY2FtZWxDYXNlVG9EYXNoIiwia2V5IiwicmVwbGFjZSIsIn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N0IHB4ID0gdmFsID0+IGRpbWVuc2lvbih2YWwsICdweCcpO1xuZXhwb3J0IGNvbnN0IHBlcmNlbnQgPSB2YWwgPT4gZGltZW5zaW9uKHZhbCwgJyUnKTtcbmV4cG9ydCBjb25zdCBlbSA9IHZhbCA9PiBkaW1lbnNpb24odmFsLCAnZW0nKTtcbmV4cG9ydCBjb25zdCByYWQgPSB2YWwgPT4gZGltZW5zaW9uKHZhbCwgJ3JhZCcpO1xuZXhwb3J0IGNvbnN0IHB0ID0gdmFsID0+IGRpbWVuc2lvbih2YWwsICdwdCcpO1xuZXhwb3J0IGNvbnN0IHZoID0gdmFsID0+IGRpbWVuc2lvbih2YWwsICd2aCcpO1xuZXhwb3J0IGNvbnN0IHZ3ID0gdmFsID0+IGRpbWVuc2lvbih2YWwsICd2dycpO1xuZXhwb3J0IGNvbnN0IGluY2ggPSB2YWwgPT4gZGltZW5zaW9uKHZhbCwgJ2luJyk7XG5leHBvcnQgY29uc3QgbW0gPSB2YWwgPT4gZGltZW5zaW9uKHZhbCwgJ21tJyk7XG5leHBvcnQgY29uc3Qgdm1pbiA9IHZhbCA9PiBkaW1lbnNpb24odmFsLCAndm1pbicpO1xuZXhwb3J0IGNvbnN0IGNtID0gdmFsID0+IGRpbWVuc2lvbih2YWwsICdjbScpO1xuZXhwb3J0IGNvbnN0IHBjID0gdmFsID0+IGRpbWVuc2lvbih2YWwsICdwYycpO1xuZXhwb3J0IGNvbnN0IGV4ID0gdmFsID0+IGRpbWVuc2lvbih2YWwsICdleCcpO1xuIl19 | ||
var dimensions = exports.dimensions = { | ||
px: px, percent: percent, inch: inch, mm: mm, vh: vh, vw: vw, rad: rad, pt: pt, cm: cm, vmin: vmin, pc: pc, ex: ex, dimension: dimension, dim: dim | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9sZXNzbHkuanMiXSwibmFtZXMiOlsidGhlbWUiLCJkaW1lbnNpb24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IHtcbiAgcHgsIHBlcmNlbnQsIGluY2gsIG1tLCB2aCwgdncsIHJhZCwgcHQsIGNtLCB2bWluLCBwYywgZXgsIGRpbWVuc2lvbiwgZGltXG59O1xuIl19 |
{ | ||
"name": "lessly", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Less functions without less", | ||
@@ -5,0 +5,0 @@ "main": "lib/lessly.js", |
@@ -106,2 +106,20 @@ # [Less][] Standalone Functions [![Build Status](https://travis-ci.org/gtg092x/lessly.svg?branch=master)](https://travis-ci.org/gtg092x/lessly) | ||
We'll also recurse any object and apply operations to child values | ||
```js | ||
import {dimension} from 'lessly'; // or dim for short | ||
dimension({ | ||
myRule: 10 | ||
}, 'px'); | ||
// outputs {myRule: '10px'} | ||
dimension({ | ||
myRule: 10 | ||
}, '+ 10px'); | ||
// outputs {myRule: '20px'} | ||
``` | ||
There's also handy shortcuts for [every css unit](http://www.tutorialspoint.com/css/css_measurement_units.htm). | ||
@@ -108,0 +126,0 @@ |
@@ -45,6 +45,9 @@ import parse from './parser/parser' | ||
// parse function args so we dont need to expose Color Node | ||
function bindParse(func, vars) { | ||
function bindParse(func, vars, convert = true) { | ||
return (...args) => { | ||
const finalArgs = args.map(arg => parseVars(String(arg), vars)); | ||
const result = func(...finalArgs.map(parse)).toCSS(); | ||
let result = func(...finalArgs.map((...argSet) => convert ? parse(...argSet) : argSet[0])); | ||
if (convert) { | ||
result = result.toCSS(); | ||
} | ||
return isNaN(result) ? result : Number(result); | ||
@@ -59,7 +62,7 @@ }; | ||
export function theme(vars = {}) { | ||
const defaulFunction = (str, subVars = {}) => { | ||
let defaulFunction = (str, subVars = {}) => { | ||
return lessly(str, {...vars, ...subVars}); | ||
}; | ||
return Object.keys(callable).reduce((pointer, key) => { | ||
defaulFunction = Object.keys(callable).reduce((pointer, key) => { | ||
const func = callable[key]; | ||
@@ -69,2 +72,10 @@ pointer[key] = bindParse(func, vars); | ||
}, defaulFunction); | ||
defaulFunction = Object.keys(dimensions).reduce((pointer, key) => { | ||
const func = dimensions[key]; | ||
pointer[key] = bindParse(func, vars, false); | ||
return pointer; | ||
}, defaulFunction); | ||
return defaulFunction; | ||
} | ||
@@ -86,4 +97,17 @@ | ||
function isPlainObj(o) { | ||
return typeof o == 'object' && o.constructor == Object; | ||
} | ||
import Dimension from './tree/dimension'; | ||
export function dimension(val, unit, ...args) { | ||
if (isPlainObj(val)) { | ||
return Object.keys(val).reduce(function(pointer, key){ | ||
const subVal = val[key]; | ||
return { | ||
...pointer, | ||
[key]: dimension(subVal, unit, ...args) | ||
}; | ||
}, {}); | ||
} | ||
if (unit === undefined) { | ||
@@ -158,1 +182,5 @@ return op(val); | ||
export const ex = val => dimension(val, 'ex'); | ||
export const dimensions = { | ||
px, percent, inch, mm, vh, vw, rad, pt, cm, vmin, pc, ex, dimension, dim | ||
}; |
@@ -84,3 +84,23 @@ import chai from 'chai'; | ||
assert.deepEqual(dimension({ | ||
'rule1': 10, | ||
'rule2': 20 | ||
}, ' * 10%'), { | ||
rule1: '100%', | ||
rule2: '200%', | ||
}); | ||
assert.deepEqual(px({ | ||
'rule1': 10, | ||
'rule2': { | ||
subrule: 20 | ||
} | ||
}), { | ||
rule1: '10px', | ||
rule2: { | ||
subrule: '20px' | ||
} | ||
}); | ||
const units = { | ||
@@ -97,3 +117,8 @@ px, '%': percent, 'in': inch, mm, vh, vw, rad, pt, cm, vmin, pc, ex | ||
it('supports dimension theme', function() { | ||
let lesslyTheme = theme({mySize: 10}); | ||
assert.equal(lesslyTheme.px('@my-size'), '10px'); | ||
}); | ||
}); | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
346192
3816
168