tsConversion: styles

This commit is contained in:
Sidharth Vinod 2022-08-21 08:54:27 +05:30
parent d9bace053b
commit 238cbd14ca
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
1 changed files with 26 additions and 6 deletions

View File

@ -10,8 +10,10 @@ import sequence from './diagrams/sequence/styles';
import stateDiagram from './diagrams/state/styles';
import journey from './diagrams/user-journey/styles';
import c4 from './diagrams/c4/styles';
import { FlowChartStyleOptions } from './diagrams/flowchart/styles';
import { log } from './logger';
// TODO Q: Shouldn't registerDiagram be injecting data here?
const themes = {
flowchart,
'flowchart-v2': flowchart,
@ -31,12 +33,30 @@ const themes = {
c4,
};
export const calcThemeVariables = (theme, userOverRides) => {
log.info('userOverides', userOverRides);
return theme.calcColors(userOverRides);
};
// TODO: Delete as it's not used
// export const calcThemeVariables = (theme: string, userOverRides) => {
// log.info('userOverides', userOverRides);
// return theme.calcColors(userOverRides);
// };
const getStyles = (type, userStyles, options) => {
const getStyles = (
type: string,
userStyles: string,
options: {
fontFamily: string;
fontSize: string;
textColor: string;
errorBkgColor: string;
errorTextColor: string;
lineColor: string;
} & FlowChartStyleOptions
) => {
let diagramStyles: string = '';
if (type in themes && themes[type as keyof typeof themes]) {
diagramStyles = themes[type as keyof typeof themes](options);
} else {
log.warn(`No theme found for ${type}`);
}
return ` {
font-family: ${options.fontFamily};
font-size: ${options.fontSize};
@ -83,7 +103,7 @@ const getStyles = (type, userStyles, options) => {
font-size: ${options.fontSize};
}
${themes[type](options)}
${diagramStyles}
${userStyles}
`;