2020-07-19 15:02:53 +02:00
|
|
|
import { lighten, rgba } from 'khroma';
|
|
|
|
|
|
|
|
class Theme {
|
|
|
|
constructor() {
|
2020-07-19 21:10:52 +02:00
|
|
|
this.background = '#333';
|
2020-07-19 15:02:53 +02:00
|
|
|
this.mainBkg = '#1f2020';
|
|
|
|
this.secondBkg = 'calculated';
|
|
|
|
this.mainContrastColor = 'lightgrey';
|
|
|
|
this.darkTextColor = '#323D47';
|
|
|
|
this.lineColor = 'calculated';
|
|
|
|
this.border1 = '#81B1DB';
|
|
|
|
this.border2 = rgba(255, 255, 255, 0.25);
|
|
|
|
this.arrowheadColor = 'calculated';
|
|
|
|
this.fontFamily = '"trebuchet ms", verdana, arial';
|
|
|
|
this.fontSize = '16px';
|
2020-07-19 21:10:52 +02:00
|
|
|
this.labelBackground = '#181818';
|
|
|
|
this.textColor = '#ccc';
|
2020-07-19 15:02:53 +02:00
|
|
|
/* Flowchart variables */
|
|
|
|
|
|
|
|
this.nodeBkg = 'calculated';
|
|
|
|
this.nodeBorder = 'calculated';
|
|
|
|
this.clusterBkg = 'calculated';
|
|
|
|
this.clusterBorder = 'calculated';
|
|
|
|
this.defaultLinkColor = 'calculated';
|
|
|
|
this.titleColor = '#F9FFFE';
|
2020-07-19 21:10:52 +02:00
|
|
|
this.edgeLabelBackground = 'calculated';
|
2020-07-19 15:02:53 +02:00
|
|
|
|
|
|
|
/* Sequence Diagram variables */
|
|
|
|
|
|
|
|
this.actorBorder = 'calculated';
|
|
|
|
this.actorBkg = 'calculated';
|
|
|
|
this.actorTextColor = 'calculated';
|
|
|
|
this.actorLineColor = 'calculated';
|
|
|
|
this.signalColor = 'calculated';
|
|
|
|
this.signalTextColor = 'calculated';
|
|
|
|
this.labelBoxBkgColor = 'calculated';
|
|
|
|
this.labelBoxBorderColor = 'calculated';
|
|
|
|
this.labelTextColor = 'calculated';
|
|
|
|
this.loopTextColor = 'calculated';
|
|
|
|
this.noteBorderColor = 'calculated';
|
|
|
|
this.noteBkgColor = '#fff5ad';
|
|
|
|
this.noteTextColor = 'calculated';
|
|
|
|
this.activationBorderColor = 'calculated';
|
|
|
|
this.activationBkgColor = 'calculated';
|
|
|
|
this.sequenceNumberColor = 'black';
|
|
|
|
|
|
|
|
/* Gantt chart variables */
|
|
|
|
|
2020-07-19 21:10:52 +02:00
|
|
|
this.sectionBkgColor = rgba(255, 255, 255, 30);
|
2020-07-19 15:02:53 +02:00
|
|
|
this.altSectionBkgColor = 'white';
|
|
|
|
this.sectionBkgColor2 = '#EAE8B9';
|
2020-07-19 21:10:52 +02:00
|
|
|
this.taskBorderColor = rgba(255, 255, 255, 50);
|
2020-07-19 15:02:53 +02:00
|
|
|
this.taskBkgColor = 'calculated';
|
|
|
|
this.taskTextColor = 'calculated';
|
|
|
|
this.taskTextLightColor = 'calculated';
|
|
|
|
this.taskTextOutsideColor = 'calculated';
|
|
|
|
this.taskTextClickableColor = '#003163';
|
2020-07-19 21:10:52 +02:00
|
|
|
this.activeTaskBorderColor = rgba(255, 255, 255, 50);
|
2020-07-19 15:02:53 +02:00
|
|
|
this.activeTaskBkgColor = '#81B1DB';
|
|
|
|
this.gridColor = 'calculated';
|
|
|
|
this.doneTaskBkgColor = 'calculated';
|
|
|
|
this.doneTaskBorderColor = 'grey';
|
|
|
|
this.critBorderColor = '#E83737';
|
|
|
|
this.critBkgColor = '#E83737';
|
|
|
|
this.taskTextDarkColor = 'calculated';
|
|
|
|
this.todayLineColor = '#DB5757';
|
|
|
|
|
|
|
|
/* state colors */
|
2020-07-19 21:10:52 +02:00
|
|
|
this.labelColor = 'calculated';
|
2020-07-19 15:02:53 +02:00
|
|
|
|
|
|
|
this.errorBkgColor = '#a44141';
|
|
|
|
this.errorTextColor = '#ddd';
|
|
|
|
}
|
|
|
|
updateColors() {
|
|
|
|
this.secondBkg = lighten(this.mainBkg, 16);
|
|
|
|
this.lineColor = this.mainContrastColor;
|
|
|
|
this.arrowheadColor = this.mainContrastColor;
|
|
|
|
/* Flowchart variables */
|
|
|
|
|
|
|
|
this.nodeBkg = this.mainBkg;
|
|
|
|
this.nodeBorder = this.border1;
|
|
|
|
this.clusterBkg = this.secondBkg;
|
|
|
|
this.clusterBorder = this.border2;
|
|
|
|
this.defaultLinkColor = this.lineColor;
|
2020-07-19 21:10:52 +02:00
|
|
|
this.edgeLabelBackground = lighten(this.labelBackground, 25);
|
2020-07-19 15:02:53 +02:00
|
|
|
|
|
|
|
/* Sequence Diagram variables */
|
|
|
|
|
|
|
|
this.actorBorder = this.border1;
|
|
|
|
this.actorBkg = this.mainBkg;
|
|
|
|
this.actorTextColor = this.mainContrastColor;
|
|
|
|
this.actorLineColor = this.mainContrastColor;
|
|
|
|
this.signalColor = this.mainContrastColor;
|
|
|
|
this.signalTextColor = this.mainContrastColor;
|
|
|
|
this.labelBoxBkgColor = this.actorBkg;
|
|
|
|
this.labelBoxBorderColor = this.actorBorder;
|
|
|
|
this.labelTextColor = this.mainContrastColor;
|
|
|
|
this.loopTextColor = this.mainContrastColor;
|
|
|
|
this.noteBorderColor = this.border2;
|
|
|
|
this.noteTextColor = this.mainBkg;
|
|
|
|
this.activationBorderColor = this.border1;
|
|
|
|
this.activationBkgColor = this.secondBkg;
|
|
|
|
|
|
|
|
/* Gantt chart variables */
|
|
|
|
|
|
|
|
this.taskBkgColor = this.mainBkg;
|
|
|
|
this.taskTextColor = this.darkTextColor;
|
|
|
|
this.taskTextLightColor = this.mainContrastColor;
|
|
|
|
this.taskTextOutsideColor = this.taskTextLightColor;
|
|
|
|
this.gridColor = this.mainContrastColor;
|
|
|
|
this.doneTaskBkgColor = this.mainContrastColor;
|
|
|
|
this.taskTextDarkColor = this.darkTextColor;
|
|
|
|
|
|
|
|
/* state colors */
|
2020-07-19 21:10:52 +02:00
|
|
|
this.labelColor = this.textColor;
|
2020-07-19 15:02:53 +02:00
|
|
|
}
|
|
|
|
calculate(overrides) {
|
2020-07-19 21:10:52 +02:00
|
|
|
if (typeof overrides !== 'object') {
|
|
|
|
// Calculate colors form base colors
|
|
|
|
this.updateColors();
|
|
|
|
return;
|
|
|
|
}
|
2020-07-19 15:02:53 +02:00
|
|
|
|
|
|
|
const keys = Object.keys(overrides);
|
|
|
|
|
|
|
|
// Copy values from overrides, this is mainly for base colors
|
|
|
|
keys.forEach(k => {
|
|
|
|
this[k] = overrides[k];
|
|
|
|
});
|
|
|
|
|
|
|
|
// Calculate colors form base colors
|
|
|
|
this.updateColors();
|
|
|
|
// Copy values from overrides again in case of an override of derived value
|
|
|
|
keys.forEach(k => {
|
|
|
|
this[k] = overrides[k];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getThemeVariables = userOverrides => {
|
|
|
|
const theme = new Theme();
|
|
|
|
theme.calculate(userOverrides);
|
|
|
|
return theme;
|
|
|
|
};
|