From 525177cf83abb18c2e8133eca63011ffb4fd436b Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Thu, 15 Aug 2024 04:35:57 -0400 Subject: [PATCH] fix(graph): change svg as button render global graph on toggle Signed-off-by: Aaron Pham --- quartz/components/Graph.tsx | 53 ++++++++++++----------- quartz/components/scripts/graph.inline.ts | 16 ++----- quartz/components/styles/graph.scss | 7 ++- 3 files changed, 36 insertions(+), 40 deletions(-) diff --git a/quartz/components/Graph.tsx b/quartz/components/Graph.tsx index 4602f9e5c..389a977b8 100644 --- a/quartz/components/Graph.tsx +++ b/quartz/components/Graph.tsx @@ -65,34 +65,35 @@ export default ((opts?: GraphOptions) => {

{i18n(cfg.locale).components.graph.title}

- - - +
- +
) diff --git a/quartz/components/scripts/graph.inline.ts b/quartz/components/scripts/graph.inline.ts index bd7d52a07..0cfe258aa 100644 --- a/quartz/components/scripts/graph.inline.ts +++ b/quartz/components/scripts/graph.inline.ts @@ -58,16 +58,12 @@ function animate(time: number) { } requestAnimationFrame(animate) -async function renderGraph(container: string, fullSlug: FullSlug, global?: boolean) { +async function renderGraph(container: string, fullSlug: FullSlug) { const slug = simplifySlug(fullSlug) const visited = getVisited() const graph = document.getElementById(container) if (!graph) return - - global = global ?? false - if (!global) { - removeAllChildren(graph) - } + removeAllChildren(graph) let { drag: enableDrag, @@ -306,7 +302,6 @@ async function renderGraph(container: string, fullSlug: FullSlug, global?: boole await app.init({ width, height, - canvas: global ? (graph as HTMLCanvasElement) : undefined, antialias: true, autoStart: false, autoDensity: true, @@ -315,10 +310,7 @@ async function renderGraph(container: string, fullSlug: FullSlug, global?: boole resolution: window.devicePixelRatio, eventMode: "static", }) - - if (!global) { - graph.appendChild(app.canvas) - } + graph.appendChild(app.canvas) const stage = app.stage stage.interactive = false @@ -535,7 +527,7 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => { sidebar.style.zIndex = "1" } - renderGraph("global-graph-container", slug, true) + renderGraph("global-graph-container", slug) registerEscapeHandler(container, hideGlobalGraph) } diff --git a/quartz/components/styles/graph.scss b/quartz/components/styles/graph.scss index 497edb802..188907d1b 100644 --- a/quartz/components/styles/graph.scss +++ b/quartz/components/styles/graph.scss @@ -16,10 +16,13 @@ overflow: hidden; & > #global-graph-icon { + cursor: pointer; + background: none; + border: none; color: var(--dark); opacity: 0.5; - width: 18px; - height: 18px; + width: 24px; + height: 24px; position: absolute; padding: 0.2rem; margin: 0.3rem;