Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getValue() {
return this.value_ || tinycolor(this.params_.defaultValue || '#000');
}
export function normalizeIconObject( icon ) {
if ( isValidIcon( icon ) ) {
return { src: icon };
}
if ( has( icon, [ 'background' ] ) ) {
const tinyBgColor = tinycolor( icon.background );
return {
...icon,
foreground: icon.foreground ? icon.foreground : mostReadable(
tinyBgColor,
ICON_COLORS,
{ includeFallbackColors: true, level: 'AA', size: 'large' }
).toHexString(),
shadowColor: tinyBgColor.setAlpha( 0.3 ).toRgbString(),
};
}
return icon;
}
setValue(val, pauseUi) {
let oldValue = this.value_;
this.value_ = (val.hasOwnProperty('_r'))
? val
: tinycolor(val || this.params_.defaultValue || '#000');
if (!pauseUi) {
this.el_.spectrum('set', this.value_.toRgbString());
}
this.notifyChanged_(val, oldValue);
}
svgToAndroidColor(color) {
if (color == 'none') {
return null;
}
color = tinycolor(color);
let colorHex = color.toHex();
let alphaHex = color.toHex8().substr(6);
return '#' + (alphaHex != 'ff' ? alphaHex : '') + colorHex;
},
svgToAndroidColor(color, opacity) {
if (color == 'none') {
return null;
}
color = tinycolor(color);
if (opacity) {
color.setAlpha(opacity);
}
return color.toHex8String();
},