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

react-base16-styling

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-base16-styling - npm Package Compare versions

Comparing version 0.4.6 to 0.4.7

172

lib/index.js

@@ -8,6 +8,2 @@ 'use strict';

var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _typeof2 = require('babel-runtime/helpers/typeof');

@@ -17,5 +13,5 @@

var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
var _extends2 = require('babel-runtime/helpers/extends');
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _extends3 = _interopRequireDefault(_extends2);

@@ -50,2 +46,10 @@ var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');

var _rgb = require('color-space/rgb');
var _rgb2 = _interopRequireDefault(_rgb);
var _yuv = require('color-space/yuv');
var _yuv2 = _interopRequireDefault(_yuv);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -55,8 +59,2 @@

var rgb = require('color-space/rgb');
var yuv = require('color-space/yuv');
var truthy = function truthy(x) {
return x;
};
var DEFAULT_BASE16 = base16.default;

@@ -72,10 +70,10 @@

var invertColor = (0, _lodash4.default)(_parse2.default, rgb.yuv, function (_ref) {
var _ref2 = (0, _slicedToArray3.default)(_ref, 3);
var invertColor = (0, _lodash4.default)(_parse2.default, _rgb2.default.yuv, function (_ref) {
var _ref2 = (0, _slicedToArray3.default)(_ref, 3),
y = _ref2[0],
u = _ref2[1],
v = _ref2[2];
var y = _ref2[0];
var u = _ref2[1];
var v = _ref2[2];
return [flip(y), u, v];
}, yuv.rgb, _rgb2hex2.default);
}, _yuv2.default.rgb, _rgb2hex2.default);

@@ -89,9 +87,109 @@ var invertThemeColors = function invertThemeColors(theme) {

var getStylingByKeys = function getStylingByKeys(customStyling, defaultStyling, keys) {
for (var _len = arguments.length, args = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
args[_key - 3] = arguments[_key];
var merger = function merger(styling) {
return function (prevStyling) {
return {
className: [prevStyling.className, styling.className].filter(Boolean).join(' '),
style: (0, _extends3.default)({}, prevStyling || {}, styling || {})
};
};
};
var mergeStyling = function mergeStyling(customStyling, defaultStyling) {
if (customStyling === undefined) {
return defaultStyling;
}
if (defaultStyling === undefined) {
return customStyling;
}
var customType = typeof customStyling === 'undefined' ? 'undefined' : (0, _typeof3.default)(customStyling);
var defaultType = typeof defaultStyling === 'undefined' ? 'undefined' : (0, _typeof3.default)(defaultStyling);
switch (customType) {
case 'string':
switch (defaultType) {
case 'string':
return defaultStyling + ' ' + customStyling;
case 'object':
return merger({ className: customStyling, style: defaultStyling });
case 'function':
return function (styling) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return (0, _extends3.default)({}, defaultStyling.apply(undefined, [styling].concat(args)), {
className: customStyling
});
};
}
case 'object':
switch (defaultType) {
case 'string':
return merger({ className: defaultStyling, style: customStyling });
case 'object':
return (0, _extends3.default)({}, defaultStyling, customStyling);
case 'function':
return function (styling) {
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
return (0, _extends3.default)({}, defaultStyling.apply(undefined, [styling].concat(args)), {
style: customStyling
});
};
}
case 'function':
switch (defaultType) {
case 'string':
return function (styling) {
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
args[_key3 - 1] = arguments[_key3];
}
return customStyling.apply(undefined, [(0, _extends3.default)({}, styling, {
className: defaultStyling
})].concat(args));
};
case 'object':
return function (styling) {
for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
args[_key4 - 1] = arguments[_key4];
}
return customStyling.apply(undefined, [(0, _extends3.default)({}, styling, {
style: defaultStyling
})].concat(args));
};
case 'function':
return function (styling) {
for (var _len5 = arguments.length, args = Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
args[_key5 - 1] = arguments[_key5];
}
return customStyling.apply(undefined, [defaultStyling.apply(undefined, [styling].concat(args))].concat(args));
};
}
}
};
var mergeStylings = function mergeStylings(customStylings, defaultStylings) {
var keys = (0, _keys2.default)(defaultStylings);
for (var key in customStylings) {
if (keys.indexOf(key) == -1) keys.push(key);
}
return keys.reduce(function (mergedStyling, key) {
return mergedStyling[key] = mergeStyling(customStylings[key], defaultStylings[key]), mergedStyling;
}, {});
};
var getStylingByKeys = function getStylingByKeys(mergedStyling, keys) {
for (var _len6 = arguments.length, args = Array(_len6 > 2 ? _len6 - 2 : 0), _key6 = 2; _key6 < _len6; _key6++) {
args[_key6 - 2] = arguments[_key6];
}
if (keys === null) {
return defaultStyling;
return mergedStyling;
}

@@ -103,11 +201,9 @@

var styles = keys.reduce(function (s, key) {
return [].concat((0, _toConsumableArray3.default)(s), [defaultStyling[key], customStyling[key]]);
}, []).filter(truthy);
var styles = keys.map(function (key) {
return mergedStyling[key];
}).filter(Boolean);
var props = styles.reduce(function (obj, s) {
if (typeof s === 'string') {
obj.className = [obj.className, s].filter(function (c) {
return c;
}).join(' ');
obj.className = [obj.className, s].filter(Boolean).join(' ');
} else if ((typeof s === 'undefined' ? 'undefined' : (0, _typeof3.default)(s)) === 'object') {

@@ -134,13 +230,13 @@ obj.style = (0, _extends3.default)({}, obj.style, s);

var createStyling = exports.createStyling = (0, _lodash2.default)(function (getStylingFromBase16) {
for (var _len2 = arguments.length, args = Array(_len2 > 4 ? _len2 - 4 : 0), _key2 = 4; _key2 < _len2; _key2++) {
args[_key2 - 4] = arguments[_key2];
for (var _len7 = arguments.length, args = Array(_len7 > 4 ? _len7 - 4 : 0), _key7 = 4; _key7 < _len7; _key7++) {
args[_key7 - 4] = arguments[_key7];
}
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var themeOrStyling = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var themeOrStyling = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var invertTheme = arguments[3];
var _options$defaultBase = options.defaultBase16;
var defaultBase16 = _options$defaultBase === undefined ? DEFAULT_BASE16 : _options$defaultBase;
var _options$base16Themes = options.base16Themes;
var base16Themes = _options$base16Themes === undefined ? null : _options$base16Themes;
var _options$defaultBase = options.defaultBase16,
defaultBase16 = _options$defaultBase === undefined ? DEFAULT_BASE16 : _options$defaultBase,
_options$base16Themes = options.base16Themes,
base16Themes = _options$base16Themes === undefined ? null : _options$base16Themes;

@@ -163,3 +259,5 @@

return (0, _lodash2.default)(getStylingByKeys, 3).apply(undefined, [customStyling, defaultStyling].concat(args));
var mergedStyling = mergeStylings(customStyling, defaultStyling);
return (0, _lodash2.default)(getStylingByKeys, 2).apply(undefined, [mergedStyling].concat(args));
}, 4);

@@ -166,0 +264,0 @@

{
"name": "react-base16-styling",
"version": "0.4.6",
"version": "0.4.7",
"description": "React styling with base16 color scheme support",

@@ -34,8 +34,8 @@ "main": "lib/index.js",

"babel-core": "^6.7.4",
"babel-eslint": "^6.0.2",
"babel-eslint": "^7.1.1",
"babel-plugin-transform-runtime": "^6.6.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-stage-0": "^6.5.0",
"eslint": "^2.7.0",
"eslint-plugin-babel": "^3.1.0",
"eslint": "^3.14.1",
"eslint-plugin-babel": "^4.0.1",
"pre-commit": "^1.1.3"

@@ -42,0 +42,0 @@ },

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