34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
/** @odoo-module **/
|
|
|
|
|
|
export const get_rgba_format = (val) => {
|
|
let rgba = val.split(',')[0].match(/[A-Za-z0-9]{2}/g);
|
|
rgba = rgba.map(function(v) {
|
|
return parseInt(v, 16)
|
|
}).join(",");
|
|
return "rgba(" + rgba + "," + val.split(',')[1] + ")";
|
|
}
|
|
|
|
export const get_dark_color = (color, opacity, percent) => {
|
|
let num = parseInt(color.slice(1), 16),
|
|
amt = Math.round(2.55 * percent),
|
|
R = (num >> 16) + amt,
|
|
G = (num >> 8 & 0x00FF) + amt,
|
|
B = (num & 0x0000FF) + amt;
|
|
return "#" + (0x1000000 + (R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 + (G < 255 ? G < 1 ? 0 : G : 255) * 0x100 + (B < 255 ? B < 1 ? 0 : B : 255))
|
|
.toString(16).slice(1) + "," + opacity;
|
|
|
|
}
|
|
|
|
export const mainBodyStyle = (rgba_background_color, rgba_font_color, tile) => {
|
|
const background_style = "background-color:" + rgba_background_color + ";color : " + rgba_font_color + ";";
|
|
const rgba_dark_background_color_l2 = get_rgba_format(get_dark_color(tile.ks_background_color.split(',')[0], tile.ks_background_color.split(',')[1], -10));
|
|
const style_image_body_l2 = "background-color:" + rgba_dark_background_color_l2 + ";";
|
|
return {
|
|
'background_style': background_style,
|
|
'style_image_body_l2': style_image_body_l2
|
|
};
|
|
}
|
|
|
|
|