mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-23 09:20:03 +02:00
test(arch): added edge arrow demo
This commit is contained in:
@@ -1,16 +1,20 @@
|
||||
import { Selection } from 'd3-selection';
|
||||
|
||||
type IconResolver = (
|
||||
parent: Selection<SVGGElement, unknown, Element | null, unknown>, width?: number
|
||||
parent: Selection<SVGGElement, unknown, Element | null, unknown>,
|
||||
width?: number
|
||||
) => Selection<SVGGElement, unknown, Element | null, unknown>;
|
||||
type IconLibrary = Record<string, IconResolver>;
|
||||
|
||||
const createIcon = (icon: string, originalSize: number): IconResolver => {
|
||||
return (parent: Selection<SVGGElement, unknown, Element | null, unknown>, size: number = originalSize) => {
|
||||
parent.html(`<g style="transform: scale(${size / originalSize})">${icon}</g>`)
|
||||
return parent
|
||||
}
|
||||
}
|
||||
return (
|
||||
parent: Selection<SVGGElement, unknown, Element | null, unknown>,
|
||||
size: number = originalSize
|
||||
) => {
|
||||
parent.html(`<g style="transform: scale(${size / originalSize})">${icon}</g>`);
|
||||
return parent;
|
||||
};
|
||||
};
|
||||
|
||||
const icons: IconLibrary = {};
|
||||
|
||||
@@ -36,7 +40,7 @@ const getIcon = (name: string): IconResolver | null => {
|
||||
if (isIconNameInUse(name)) {
|
||||
return icons[name];
|
||||
}
|
||||
return icons["unknown"];
|
||||
return icons['unknown'];
|
||||
};
|
||||
|
||||
export { registerIcon, registerIcons, getIcon, isIconNameInUse, createIcon, IconLibrary };
|
||||
export { registerIcon, registerIcons, getIcon, isIconNameInUse, createIcon, IconLibrary, IconResolver };
|
||||
|
Reference in New Issue
Block a user