import type { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps, } from "@quartz-community/types"; import { classNames } from "../util/lang"; import { i18n } from "../i18n"; import style from "./styles/graph.scss"; // @ts-expect-error - inline script imported as string by esbuild loader import script from "./scripts/graph.inline.ts"; export interface D3Config { drag: boolean; zoom: boolean; depth: number; scale: number; repelForce: number; centerForce: number; linkDistance: number; fontSize: number; opacityScale: number; removeTags: string[]; showTags: boolean; focusOnHover?: boolean; enableRadial?: boolean; } export interface GraphOptions { localGraph?: Partial; globalGraph?: Partial; } const defaultOptions: GraphOptions = { localGraph: { drag: true, zoom: true, depth: 1, scale: 1.1, repelForce: 0.5, centerForce: 0.3, linkDistance: 30, fontSize: 0.6, opacityScale: 1, showTags: true, removeTags: [], focusOnHover: false, enableRadial: false, }, globalGraph: { drag: true, zoom: true, depth: -1, scale: 0.9, repelForce: 0.5, centerForce: 0.2, linkDistance: 30, fontSize: 0.6, opacityScale: 1, showTags: true, removeTags: [], focusOnHover: true, enableRadial: true, }, }; export default ((userOpts?: Partial) => { const Graph: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => { const localGraph = { ...defaultOptions.localGraph, ...userOpts?.localGraph }; const globalGraph = { ...defaultOptions.globalGraph, ...userOpts?.globalGraph }; return (

{i18n(cfg.locale ?? "en-US").components.graph.title}

); }; Graph.css = style; Graph.afterDOMLoaded = script; return Graph; }) satisfies QuartzComponentConstructor;