mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 06:49:47 +02:00

* develop: (67 commits) fix: Tsconfig Update prettier chore: Run postbuild with prepare (formatting) prettier fix Removed warnings in the grammar oand some console logging ci: lint .jison files for any console.log() fix JSDOC @param, @returns; fixed a few minor typos in comments unmangle sentence about doc changes committed and showing up on docsify site change references from /docs to /src/docs; rework doc section in CONTRIBUTING Update after lint comments Regenerate the directive docs as I changed them chore(deps-dev): bump typescript from 4.7.4 to 4.8.2 Update duplicate copy pasted directive description chore(deps-dev): bump @types/dompurify from 2.3.3 to 2.3.4 chore(deps-dev): bump jest-environment-jsdom from 29.0.1 to 29.0.2 chore(deps-dev): bump babel-jest from 29.0.1 to 29.0.2 Lint fixes Removing requirement to add ids for nodes with a shape #3336 Merged typescript changes Merged typescript changes ...
111 lines
2.4 KiB
TypeScript
111 lines
2.4 KiB
TypeScript
import classDiagram from './diagrams/class/styles';
|
|
import er from './diagrams/er/styles';
|
|
import flowchart from './diagrams/flowchart/styles';
|
|
import gantt from './diagrams/gantt/styles';
|
|
// import gitGraph from './diagrams/git/styles';
|
|
import info from './diagrams/info/styles';
|
|
import pie from './diagrams/pie/styles';
|
|
import requirement from './diagrams/requirement/styles';
|
|
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 @knut: Inject from registerDiagram.
|
|
const themes: Record<string, any> = {
|
|
flowchart,
|
|
'flowchart-v2': flowchart,
|
|
sequence,
|
|
gantt,
|
|
classDiagram,
|
|
'classDiagram-v2': classDiagram,
|
|
class: classDiagram,
|
|
stateDiagram,
|
|
state: stateDiagram,
|
|
// gitGraph,
|
|
info,
|
|
pie,
|
|
er,
|
|
journey,
|
|
requirement,
|
|
c4,
|
|
};
|
|
|
|
const getStyles = (
|
|
type: string,
|
|
userStyles: string,
|
|
options: {
|
|
fontFamily: string;
|
|
fontSize: string;
|
|
textColor: string;
|
|
errorBkgColor: string;
|
|
errorTextColor: string;
|
|
lineColor: string;
|
|
} & FlowChartStyleOptions
|
|
) => {
|
|
let diagramStyles = '';
|
|
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};
|
|
fill: ${options.textColor}
|
|
}
|
|
|
|
/* 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};
|
|
stroke: ${options.lineColor};
|
|
}
|
|
.marker.cross {
|
|
stroke: ${options.lineColor};
|
|
}
|
|
|
|
svg {
|
|
font-family: ${options.fontFamily};
|
|
font-size: ${options.fontSize};
|
|
}
|
|
|
|
${diagramStyles}
|
|
|
|
${userStyles}
|
|
`;
|
|
};
|
|
|
|
export const addStylesForDiagram = (type: string, diagramTheme: unknown): void => {
|
|
themes[type] = diagramTheme;
|
|
};
|
|
|
|
export default getStyles;
|