mermaid/src/styles.js

95 lines
2.0 KiB
JavaScript
Raw Normal View History

2020-07-17 15:57:02 +02:00
import classDiagram from './diagrams/class/styles';
import er from './diagrams/er/styles';
import error from './diagrams/error/styles';
2020-07-17 15:57:02 +02:00
import flowchart from './diagrams/flowchart/styles';
import gantt from './diagrams/gantt/styles';
import gitGraph from './diagrams/git/styles';
2020-07-17 15:57:02 +02:00
import info from './diagrams/info/styles';
import pie from './diagrams/pie/styles';
2022-02-10 20:32:21 +01:00
import requirement from './diagrams/requirement/styles';
2020-07-17 15:57:02 +02:00
import sequence from './diagrams/sequence/styles';
import stateDiagram from './diagrams/state/styles';
import journey from './diagrams/user-journey/styles';
2022-05-15 13:21:16 +08:00
import c4 from './diagrams/c4/styles';
import { log } from './logger';
2020-07-16 20:27:42 +02:00
const themes = {
2020-07-17 15:57:02 +02:00
flowchart,
'flowchart-v2': flowchart,
sequence,
gantt,
classDiagram,
2020-07-22 19:25:26 +02:00
'classDiagram-v2': classDiagram,
class: classDiagram,
2020-07-17 15:57:02 +02:00
stateDiagram,
state: stateDiagram,
gitGraph,
2020-07-17 15:57:02 +02:00
info,
pie,
er,
error,
2022-02-10 20:32:21 +01:00
journey,
requirement,
2022-05-15 13:21:16 +08:00
c4,
2020-07-16 20:27:42 +02:00
};
export const calcThemeVariables = (theme, userOverRides) => {
log.info('userOverides', userOverRides);
return theme.calcColors(userOverRides);
};
const getStyles = (type, userStyles, options) => {
return ` {
2020-07-17 15:57:02 +02:00
font-family: ${options.fontFamily};
font-size: ${options.fontSize};
fill: ${options.textColor}
2020-07-16 20:27:42 +02:00
}
/* Classes common for multiple diagrams */
.error-icon {
fill: ${options.errorBkgColor};
}
.error-text {
fill: ${options.errorTextColor};
stroke: ${options.errorTextColor};
}
.edge-thickness-normal {
stroke-width: 2px;
}
.edge-thickness-thick {
stroke-width: 3.5px
}
.edge-pattern-solid {
stroke-dasharray: 0;
}
.edge-pattern-dashed{
stroke-dasharray: 3;
}
.edge-pattern-dotted {
stroke-dasharray: 2;
}
.marker {
fill: ${options.lineColor};
2022-02-10 20:32:21 +01:00
stroke: ${options.lineColor};
2020-07-16 20:27:42 +02:00
}
.marker.cross {
stroke: ${options.lineColor};
}
svg {
2020-07-17 15:57:02 +02:00
font-family: ${options.fontFamily};
font-size: ${options.fontSize};
2020-07-16 20:27:42 +02:00
}
${themes[type](options)}
2020-07-16 20:27:42 +02:00
${userStyles}
`;
};
2020-07-16 20:27:42 +02:00
export default getStyles;