test(arch): added edge arrow demo

This commit is contained in:
NicolasNewman
2024-04-06 21:55:06 -05:00
parent 251e808a29
commit baa6c9e4b9
2 changed files with 66 additions and 34 deletions

View File

@@ -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 };