add getDiagramStyles type and use it in style.ts

This commit is contained in:
Yokozuna59
2023-06-26 19:26:56 +03:00
parent f020f4a292
commit 3106ddbd1e
2 changed files with 7 additions and 7 deletions

View File

@@ -82,3 +82,5 @@ export type ParseDirectiveDefinition = (statement: string, context: string, type
export type HTML = d3.Selection<HTMLIFrameElement, unknown, Element, unknown>; export type HTML = d3.Selection<HTMLIFrameElement, unknown, Element, unknown>;
export type SVG = d3.Selection<SVGSVGElement, unknown, Element, unknown>; export type SVG = d3.Selection<SVGSVGElement, unknown, Element, unknown>;
export type getDiagramStyles = (options?: unknown) => string;

View File

@@ -1,7 +1,8 @@
import type { FlowChartStyleOptions } from './diagrams/flowchart/styles.js'; import type { FlowChartStyleOptions } from './diagrams/flowchart/styles.js';
import { log } from './logger.js'; import { log } from './logger.js';
import { getDiagramStyles } from './diagram-api/types.js';
const themes: Record<string, (options?: any) => string> = {}; const themes: Record<string, getDiagramStyles> = {};
const getStyles = ( const getStyles = (
type: string, type: string,
@@ -73,12 +74,9 @@ const getStyles = (
`; `;
}; };
export const addStylesForDiagram = ( export const addStylesForDiagram = (type: string, getDiagramStyles?: getDiagramStyles): void => {
type: string, if (getDiagramStyles !== undefined) {
diagramTheme?: (options?: any) => string themes[type] = getDiagramStyles;
): void => {
if (diagramTheme !== undefined) {
themes[type] = diagramTheme;
} }
}; };