theminator
Advanced tools
Comparing version 0.1.0 to 0.1.1
import chroma from 'chroma-js'; | ||
declare type MappedValues<T, MappedValue> = { | ||
[K in keyof T]: T[K] extends object ? MappedValues<T[K], MappedValue> : MappedValue; | ||
}; | ||
import { MappedValues } from 'deep-map-object'; | ||
export declare const decorateColors: <Theme extends object>(theme: Theme) => MappedValues<Theme, chroma.Color>; | ||
@@ -6,0 +4,0 @@ export declare const decorateDimensions: <Theme extends object>(theme: Theme) => MappedValues<Theme, { |
@@ -8,3 +8,3 @@ 'use strict'; | ||
var chroma = _interopDefault(require('chroma-js')); | ||
var lodash = require('lodash'); | ||
var deepMap = _interopDefault(require('deep-map-object')); | ||
@@ -44,10 +44,4 @@ function _extends() { | ||
var mapValuesDeep = function mapValuesDeep(obj, fn) { | ||
return lodash.mapValues(obj, function (val, key) { | ||
return lodash.isPlainObject(val) ? mapValuesDeep(val, fn) : fn(val, key, obj); | ||
}); | ||
}; | ||
var decorateColors = function decorateColors(theme) { | ||
return mapValuesDeep(theme, function (value) { | ||
return deepMap(function (value) { | ||
try { | ||
@@ -58,6 +52,6 @@ return chroma(value); | ||
} | ||
}); | ||
})(theme); | ||
}; | ||
var decorateDimensions = function decorateDimensions(theme) { | ||
return mapValuesDeep(theme, function (value) { | ||
return deepMap(function (value) { | ||
if (value === 0 || value === '0') { | ||
@@ -86,3 +80,3 @@ return { | ||
}; | ||
}); | ||
})(theme); | ||
}; | ||
@@ -89,0 +83,0 @@ var index = (function (_ref) { |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r,e=(r=require("chroma-js"))&&"object"==typeof r&&"default"in r?r.default:r,n=require("lodash");function t(){return(t=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r}).apply(this,arguments)}var o=function r(e,t){return n.mapValues(e,(function(o,i){return n.isPlainObject(o)?r(o,t):t(o,i,e)}))},i=function(r){return o(r,(function(r){try{return e(r)}catch(e){throw new Error(r+" is not a valid color: "+e.message)}}))},s=function(r){return o(r,(function(r){if(0===r||"0"===r)return{css:"0",value:0,unit:""};if("string"!=typeof r)throw new Error("Value "+r+" is not a valid dimension.");var e=r.match(/^([-+]?[0-9]*\.?[0-9]+)(cm|mm|in|px|pt|pc|em|ex|ch|rem|vw|vh|vmin|vmax|%)$/i);if(null===e)throw new Error("Value "+r+" is not a valid dimension.");return{css:e[0],value:Number.parseFloat(e[1]),unit:e[2]}}))};exports.decorateColors=i,exports.decorateDimensions=s,exports.default=function(r){var e=r.colors,n=r.dimensions,o=function(r,e){if(null==r)return{};var n,t,o={},i=Object.keys(r);for(t=0;t<i.length;t++)e.indexOf(n=i[t])>=0||(o[n]=r[n]);return o}(r,["colors","dimensions"]);return t({colors:i(e),dimensions:s(n)},o)}; | ||
"use strict";function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}Object.defineProperty(exports,"__esModule",{value:!0});var e=r(require("chroma-js")),n=r(require("deep-map-object"));function t(){return(t=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r}).apply(this,arguments)}var o=function(r){return n((function(r){try{return e(r)}catch(e){throw new Error(r+" is not a valid color: "+e.message)}}))(r)},i=function(r){return n((function(r){if(0===r||"0"===r)return{css:"0",value:0,unit:""};if("string"!=typeof r)throw new Error("Value "+r+" is not a valid dimension.");var e=r.match(/^([-+]?[0-9]*\.?[0-9]+)(cm|mm|in|px|pt|pc|em|ex|ch|rem|vw|vh|vmin|vmax|%)$/i);if(null===e)throw new Error("Value "+r+" is not a valid dimension.");return{css:e[0],value:Number.parseFloat(e[1]),unit:e[2]}}))(r)};exports.decorateColors=o,exports.decorateDimensions=i,exports.default=function(r){var e=r.colors,n=r.dimensions,s=function(r,e){if(null==r)return{};var n,t,o={},i=Object.keys(r);for(t=0;t<i.length;t++)e.indexOf(n=i[t])>=0||(o[n]=r[n]);return o}(r,["colors","dimensions"]);return t({colors:o(e),dimensions:i(n)},s)}; | ||
//# sourceMappingURL=theminator.cjs.production.min.js.map |
import chroma from 'chroma-js'; | ||
import { mapValues, isPlainObject } from 'lodash-es'; | ||
import deepMap from 'deep-map-object'; | ||
@@ -37,10 +37,4 @@ function _extends() { | ||
var mapValuesDeep = function mapValuesDeep(obj, fn) { | ||
return mapValues(obj, function (val, key) { | ||
return isPlainObject(val) ? mapValuesDeep(val, fn) : fn(val, key, obj); | ||
}); | ||
}; | ||
var decorateColors = function decorateColors(theme) { | ||
return mapValuesDeep(theme, function (value) { | ||
return deepMap(function (value) { | ||
try { | ||
@@ -51,6 +45,6 @@ return chroma(value); | ||
} | ||
}); | ||
})(theme); | ||
}; | ||
var decorateDimensions = function decorateDimensions(theme) { | ||
return mapValuesDeep(theme, function (value) { | ||
return deepMap(function (value) { | ||
if (value === 0 || value === '0') { | ||
@@ -79,3 +73,3 @@ return { | ||
}; | ||
}); | ||
})(theme); | ||
}; | ||
@@ -82,0 +76,0 @@ var index = (function (_ref) { |
{ | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"license": "MIT", | ||
@@ -40,7 +40,5 @@ "main": "dist/index.js", | ||
"@types/chroma-js": "^2.0.0", | ||
"@types/lodash": "^4.14.149", | ||
"chroma-js": "^2.1.0", | ||
"lodash": "^4.17.15", | ||
"lodash-es": "^4.17.15" | ||
"deep-map-object": "^0.0.5" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
3
19688
181
+ Addeddeep-map-object@^0.0.5
+ Addeddeep-map-object@0.0.5(transitive)
- Removed@types/lodash@^4.14.149
- Removedlodash@^4.17.15
- Removedlodash-es@^4.17.15
- Removed@types/lodash@4.17.13(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlodash-es@4.17.21(transitive)