mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-25 18:30:10 +02:00
tsConversion: styles
This commit is contained in:
@@ -10,8 +10,10 @@ import sequence from './diagrams/sequence/styles';
|
|||||||
import stateDiagram from './diagrams/state/styles';
|
import stateDiagram from './diagrams/state/styles';
|
||||||
import journey from './diagrams/user-journey/styles';
|
import journey from './diagrams/user-journey/styles';
|
||||||
import c4 from './diagrams/c4/styles';
|
import c4 from './diagrams/c4/styles';
|
||||||
|
import { FlowChartStyleOptions } from './diagrams/flowchart/styles';
|
||||||
import { log } from './logger';
|
import { log } from './logger';
|
||||||
|
|
||||||
|
// TODO Q: Shouldn't registerDiagram be injecting data here?
|
||||||
const themes = {
|
const themes = {
|
||||||
flowchart,
|
flowchart,
|
||||||
'flowchart-v2': flowchart,
|
'flowchart-v2': flowchart,
|
||||||
@@ -31,12 +33,30 @@ const themes = {
|
|||||||
c4,
|
c4,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const calcThemeVariables = (theme, userOverRides) => {
|
// TODO: Delete as it's not used
|
||||||
log.info('userOverides', userOverRides);
|
// export const calcThemeVariables = (theme: string, userOverRides) => {
|
||||||
return theme.calcColors(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 ` {
|
return ` {
|
||||||
font-family: ${options.fontFamily};
|
font-family: ${options.fontFamily};
|
||||||
font-size: ${options.fontSize};
|
font-size: ${options.fontSize};
|
||||||
@@ -83,7 +103,7 @@ const getStyles = (type, userStyles, options) => {
|
|||||||
font-size: ${options.fontSize};
|
font-size: ${options.fontSize};
|
||||||
}
|
}
|
||||||
|
|
||||||
${themes[type](options)}
|
${diagramStyles}
|
||||||
|
|
||||||
${userStyles}
|
${userStyles}
|
||||||
`;
|
`;
|
Reference in New Issue
Block a user