2021-04-06 16:10:46 +02:00
|
|
|
export class Layout {
|
|
|
|
_id:string;
|
|
|
|
portalPid:string;
|
|
|
|
layoutOptions:CustomizationOptions;
|
|
|
|
constructor(community, options:CustomizationOptions){
|
|
|
|
this.portalPid = community;
|
|
|
|
this.layoutOptions = options;
|
|
|
|
}
|
|
|
|
}
|
2019-09-12 11:40:17 +02:00
|
|
|
export class CustomizationOptions {
|
2021-04-05 15:14:43 +02:00
|
|
|
identity: {
|
|
|
|
isDefault: boolean;
|
|
|
|
mainColor: string;
|
|
|
|
secondaryColor: string;
|
2021-02-10 11:24:52 +01:00
|
|
|
};
|
2021-04-05 15:14:43 +02:00
|
|
|
backgrounds: {
|
|
|
|
isDefault:boolean,
|
|
|
|
dark: {
|
|
|
|
isDefault:boolean,
|
|
|
|
color: string; //background
|
|
|
|
}
|
|
|
|
light: {
|
|
|
|
isDefault:boolean,
|
2019-10-07 08:58:49 +02:00
|
|
|
color: string; //background
|
2021-02-10 11:24:52 +01:00
|
|
|
}
|
2019-09-12 11:40:17 +02:00
|
|
|
};
|
|
|
|
buttons: {
|
2021-04-05 15:14:43 +02:00
|
|
|
isDefault:boolean,
|
|
|
|
darkBackground: ButtonsCustomization;
|
|
|
|
lightBackground: ButtonsCustomization;
|
2019-09-12 11:40:17 +02:00
|
|
|
};
|
2019-10-07 08:58:49 +02:00
|
|
|
|
2021-04-05 15:14:43 +02:00
|
|
|
constructor(mainColor: string = null, secondaryColor: string = null) {
|
|
|
|
|
|
|
|
this.identity= {
|
|
|
|
mainColor: mainColor ? mainColor : CustomizationOptions.getIdentity().mainColor,
|
|
|
|
secondaryColor : secondaryColor ? secondaryColor : CustomizationOptions.getIdentity().secondaryColor,
|
|
|
|
isDefault : true
|
2019-10-07 08:58:49 +02:00
|
|
|
};
|
2021-04-05 15:14:43 +02:00
|
|
|
this.backgrounds={
|
|
|
|
isDefault: true,
|
|
|
|
dark : {
|
|
|
|
isDefault: true,
|
|
|
|
color: this.identity.mainColor,
|
2019-10-07 08:58:49 +02:00
|
|
|
},
|
2021-04-05 15:14:43 +02:00
|
|
|
light : {
|
|
|
|
isDefault: true,
|
|
|
|
color: CustomizationOptions.getRGBA(this.identity.mainColor,0.1),
|
2019-10-07 08:58:49 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-04-05 15:14:43 +02:00
|
|
|
|
2019-10-07 08:58:49 +02:00
|
|
|
this.buttons = {
|
2021-04-05 15:14:43 +02:00
|
|
|
isDefault: true,
|
2019-10-07 08:58:49 +02:00
|
|
|
darkBackground: {
|
2021-04-05 15:14:43 +02:00
|
|
|
isDefault:true,
|
2019-10-07 08:58:49 +02:00
|
|
|
backgroundColor: "#ffffff",
|
2021-04-05 15:14:43 +02:00
|
|
|
color: "#000000",
|
|
|
|
borderStyle: "solid",
|
2019-10-07 08:58:49 +02:00
|
|
|
borderColor: "#ffffff",
|
|
|
|
borderWidth: 1,
|
2021-03-31 13:23:24 +02:00
|
|
|
borderRadius: 500,
|
2019-10-07 08:58:49 +02:00
|
|
|
onHover: {
|
|
|
|
backgroundColor: "#eeeeee",
|
2021-03-31 13:23:24 +02:00
|
|
|
color: "#000000",
|
2019-10-07 08:58:49 +02:00
|
|
|
borderColor: "#eeeeee",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
lightBackground: {
|
2021-04-05 15:14:43 +02:00
|
|
|
isDefault:true,
|
|
|
|
backgroundColor: this.identity.mainColor,
|
2019-10-07 08:58:49 +02:00
|
|
|
color: '#ffffff',
|
|
|
|
borderStyle: "solid",
|
2021-04-05 15:14:43 +02:00
|
|
|
borderColor: this.identity.mainColor,
|
2019-10-07 08:58:49 +02:00
|
|
|
borderWidth: 1,
|
2021-03-31 13:23:24 +02:00
|
|
|
borderRadius: 500,
|
2019-10-07 08:58:49 +02:00
|
|
|
onHover: {
|
2021-04-05 15:14:43 +02:00
|
|
|
backgroundColor: this.identity.secondaryColor,
|
2019-10-07 08:58:49 +02:00
|
|
|
color: '#ffffff',
|
2021-04-05 15:14:43 +02:00
|
|
|
borderColor: this.identity.secondaryColor,
|
2019-10-07 08:58:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
2021-04-05 15:14:43 +02:00
|
|
|
public static getIdentity(community:string=null){
|
|
|
|
let COLORS= {
|
|
|
|
default:{
|
|
|
|
mainColor:'#4687E6',
|
|
|
|
secondaryColor: '#2D72D6'
|
|
|
|
},
|
|
|
|
"covid-19":{
|
|
|
|
mainColor:"#03ADEE",
|
|
|
|
secondaryColor: "#F15157"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
if(community && COLORS[community]){
|
|
|
|
return COLORS[community];
|
|
|
|
}
|
|
|
|
return COLORS.default;
|
|
|
|
}
|
|
|
|
public static getRGBA(color, A){
|
|
|
|
if(color.indexOf("#")!=-1){
|
|
|
|
return 'rgba('+parseInt(color.substring(1,3),16)+','+parseInt(color.substring(3,5),16)+','+parseInt(color.substring(5,7),16)+','+A+')';
|
|
|
|
}
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
2021-04-06 16:10:46 +02:00
|
|
|
public static isForLightBackground(color:string){
|
|
|
|
let L, r, g, b, a = 1;
|
|
|
|
// console.log(color + " " +color.length);
|
|
|
|
if(color.length == 7 || color.length == 9) {
|
|
|
|
r = parseInt(color.substring(1, 3), 16);
|
|
|
|
g = parseInt(color.substring(3, 5), 16);
|
|
|
|
b = parseInt(color.substring(5, 7), 16);
|
|
|
|
if(color.length == 9) {
|
|
|
|
a = parseInt(color.substring(7, 9), 16);
|
|
|
|
}
|
|
|
|
}else if(color.length > 9){
|
|
|
|
let array = color.split("rgba(")[1].split(")")[0].split(",");
|
|
|
|
r = parseInt(array[0]);
|
|
|
|
g = parseInt(array[1]);
|
|
|
|
b = parseInt(array[2]);
|
|
|
|
a = +array[3];
|
|
|
|
|
|
|
|
}
|
|
|
|
console.log(color, color.length, r, g, b, a);
|
|
|
|
const brightness = r* 0.299 + g * 0.587 + b * 0.114 + (1 - a) * 255;
|
|
|
|
|
|
|
|
return (brightness < 186)
|
|
|
|
|
|
|
|
// return !(r*0.299 + g*0.587 + b*0.114 > 186);
|
|
|
|
/*for(let c of [r,g,b]){
|
|
|
|
c = c / 255.0;
|
|
|
|
if(c <= 0.03928){
|
|
|
|
c = c / 12.92;
|
|
|
|
}else {
|
|
|
|
c = ((c + 0.055) / 1.055) ^ 2.4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
L = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
|
|
return L > 0.179// (L + 0.05) / (0.05) > (1.0 + 0.05) / (L + 0.05); //use #000000 else use #ffffff
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2019-10-07 08:58:49 +02:00
|
|
|
|
2019-09-12 11:40:17 +02:00
|
|
|
}
|
2021-04-05 15:14:43 +02:00
|
|
|
export class ButtonsCustomization{
|
|
|
|
isDefault:boolean;
|
|
|
|
backgroundColor: string;
|
|
|
|
color: string;
|
|
|
|
borderStyle: string;
|
|
|
|
borderColor: string;
|
|
|
|
borderWidth: number;
|
|
|
|
borderRadius: number;
|
|
|
|
onHover: {
|
|
|
|
backgroundColor: string;
|
|
|
|
color: string;
|
|
|
|
borderColor: string;
|
|
|
|
};
|
|
|
|
}
|