@iconify/tools
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -5,3 +5,3 @@ { | ||
"author": "Vjacheslav Trushkin", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"license": "MIT", | ||
@@ -27,5 +27,5 @@ "bugs": "https://github.com/iconify-design/tools/issues", | ||
"simple-tokenizer": "*", | ||
"svgo": "^1.2.1", | ||
"svgo": "^1.2.2", | ||
"tmp": "^0.0.33" | ||
} | ||
} |
@@ -71,10 +71,25 @@ /** | ||
} else { | ||
let colorKey = token.value; | ||
let colorKey = token.value, | ||
callbackColor = null; | ||
if (palette[colorKey] === void 0) { | ||
colorKey = color.toString({compress: true}); | ||
if (palette[colorKey] === void 0) { | ||
return; | ||
// Make sure actual color is used in callback | ||
callbackColor = colorKey; | ||
colorKey = 'default'; | ||
if (palette[colorKey] === void 0) { | ||
return; | ||
} | ||
} | ||
} | ||
token.value = palette[colorKey]; | ||
let newColor = palette[colorKey]; | ||
if (typeof newColor === 'function') { | ||
// Get color from callback('css', color, token, key) | ||
newColor = newColor('css', callbackColor === null ? colorKey : callbackColor, token, key); | ||
} | ||
if (typeof newColor === 'string') { | ||
token.value = palette[colorKey]; | ||
} | ||
} | ||
@@ -132,3 +147,6 @@ break; | ||
if (props[attr] !== void 0) { | ||
// Node has fill or stroke - check value | ||
if (isNone(props[attr])) { | ||
// Color is set to "none" - ignore node | ||
attributes[attr] = false; | ||
@@ -140,3 +158,4 @@ return; | ||
if (typeof palette !== 'string') { | ||
let colorKey = props[attr]; | ||
let colorKey = props[attr], | ||
callbackColor = null; | ||
if (palette[colorKey] === void 0) { | ||
@@ -149,16 +168,32 @@ let color = Color.fromString(props[attr]); | ||
if (palette[colorKey] === void 0 && palette.default !== void 0) { | ||
// Send actual color instead of 'default' to callback | ||
callbackColor = colorKey; | ||
colorKey = 'default'; | ||
} | ||
if (palette[colorKey] !== void 0) { | ||
$child.attr(attr, palette[colorKey]); | ||
let newColor = palette[colorKey]; | ||
// Call callback('node', color, $node, attr) to get new color | ||
if (typeof newColor === 'function') { | ||
newColor = newColor('node', callbackColor === null ? colorKey : callbackColor, $child, attr); | ||
} | ||
if (typeof newColor === 'string') { | ||
$child.attr(attr, newColor); | ||
} | ||
} | ||
} | ||
attributes[attr] = props[attr]; | ||
} else if ( | ||
addColor !== false && shape && | ||
attributes[attr] === true // do not add if value is 'none' or parent color is set | ||
) { | ||
$child.attr(attr, addColor); | ||
attributes[attr] = addColor; | ||
if (props[attr] !== void 0) { | ||
attributes[attr] = props[attr]; | ||
} | ||
} else if (shape && attributes[attr] === true) { | ||
// Shape that supposed to have color, but it is not set. Set default value | ||
// Get color value from callback('add', $node) | ||
let color = typeof addColor === 'function' ? addColor('add', $child) : addColor; | ||
if (typeof color === 'string') { | ||
$child.attr(attr, color); | ||
attributes[attr] = color; | ||
} | ||
} | ||
@@ -165,0 +200,0 @@ }); |
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
206783
5072
Updatedsvgo@^1.2.2