themestress
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -89,8 +89,10 @@ "use strict"; | ||
}, function (_a) { | ||
var theme = _a.theme, variant = _a.variant, fontColor = _a.fontColor; | ||
var theme = _a.theme, v = _a.variant, fc = _a.fontColor, bg = _a.bgColor; | ||
var color = theme.palette.primary.main; | ||
if (variant === 'contained') | ||
if (v === 'contained') | ||
color = theme.palette.primary.on; | ||
if (fontColor) | ||
color = (0, themeUtils_1.colorFromTheme)(theme, fontColor); | ||
if (bg && !fc) | ||
color = (0, themeUtils_1.onColorFromTheme)(theme, bg); | ||
if (fc) | ||
color = (0, themeUtils_1.colorFromTheme)(theme, fc); | ||
return color; | ||
@@ -97,0 +99,0 @@ }, function (_a) { |
@@ -14,3 +14,3 @@ "use strict"; | ||
/** Check if a string is an RGB string */ | ||
var isRgb = function (c) { return c.includes('rgb') && c.split(',').length === 3; }; | ||
var isRgb = function (c) { return c.includes('rgb'); }; | ||
/** Check if a string is a HEX string */ | ||
@@ -75,7 +75,11 @@ var isHex = function (c) { return c[0] === '#' && c.split('').length === 7; }; | ||
/** Call a function on every value in an object */ | ||
var objDeep = function (value, fn) { | ||
Object.values(value).forEach(function (v) { | ||
fn(v); | ||
if (isObject(v)) | ||
objDeep(v, fn); | ||
var objDeep = function (value, fn, ignoreKeys) { | ||
if (ignoreKeys === void 0) { ignoreKeys = []; } | ||
Object.entries(value).forEach(function (_a) { | ||
var k = _a[0], v = _a[1]; | ||
if (!ignoreKeys.includes(k)) { | ||
fn(v); | ||
if (isObject(v)) | ||
objDeep(v, fn); | ||
} | ||
}); | ||
@@ -147,6 +151,6 @@ }; | ||
/** Generate the palette */ | ||
var createPalette = function (palette) { | ||
var createPalette = function (initialPalette) { | ||
// Generate "on" colors | ||
var fn = function (value) { | ||
if (!isObject(value) || value['main'] !== undefined) | ||
var createOnColors = function (value) { | ||
if (!isObject(value) || value['main'] === undefined) | ||
return; | ||
@@ -162,8 +166,8 @@ validateColorString(value['main']); | ||
}; | ||
var _palette = Object.assign({}, palette); | ||
objDeep(_palette, fn); | ||
// Add any defaults | ||
var palette = Object.assign({}, initialPalette); | ||
objDeep(palette, createOnColors, []); | ||
var defaultPalette = mergeDeep({}, corePalette); | ||
mergeDeep(defaultPalette, palette['mode'] === 'dark' ? darks : lights); | ||
var result = mergeDeep(defaultPalette, _palette); | ||
objDeep(defaultPalette, createOnColors, []); | ||
mergeDeep(defaultPalette, initialPalette.mode === 'dark' ? darks : lights); | ||
var result = mergeDeep(defaultPalette, palette); | ||
return result; | ||
@@ -179,3 +183,3 @@ }; | ||
var result = mergeDeep(defaultTheme, theme); | ||
result['palette'] = createPalette(result['palette']); | ||
result.palette = createPalette(result.palette); | ||
return result; | ||
@@ -182,0 +186,0 @@ }; |
{ | ||
"name": "themestress", | ||
"description": "A lightweight theme package.", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "types": "index.d.ts", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
156796
3462
0