From 1d4008cb4e5b64c3401fd09f8942e2d534b150d7 Mon Sep 17 00:00:00 2001 From: Arsero <54241944+Arsero@users.noreply.github.com> Date: Tue, 28 May 2024 21:48:41 +0200 Subject: [PATCH] Squashed commit of the following: commit 4b3a68de5b14a909942a2fef3ee958a601f2e1f3 Author: Arsero <54241944+Arsero@users.noreply.github.com> Date: Tue May 28 21:48:28 2024 +0200 feat: update version commit d036ac9af56dd8b33e548bc1b724dad50aeae1af Author: Arsero <54241944+Arsero@users.noreply.github.com> Date: Tue May 28 21:44:08 2024 +0200 fix: don't open graph view with screen smaller than 800x720 commit d85a21d84ba31dbf9dab76f08f3cdcab4d48f8dc Author: Arsero <54241944+Arsero@users.noreply.github.com> Date: Tue May 28 21:42:00 2024 +0200 feat: add text in burger menu commit 7b948d1156bcc84149c2e20c1ffd71c7b4990910 Author: Arsero <54241944+Arsero@users.noreply.github.com> Date: Tue May 28 21:41:41 2024 +0200 fix: theme color --- package.json | 2 +- src/theme/templates.ts | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 48d1fbe..e2a287b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "docusaurus-graph", - "version": "1.0.3", + "version": "1.1.0", "main": "src/index.ts", "repository": "https://github.com/Arsero/docusaurus-graph.git", "author": "Arsero <54241944+Arsero@users.noreply.github.com>", diff --git a/src/theme/templates.ts b/src/theme/templates.ts index 589cf73..6a2ba10 100644 --- a/src/theme/templates.ts +++ b/src/theme/templates.ts @@ -38,7 +38,7 @@ const templates = { left: 50%; transform: translate(-50%, -50%); padding: 20px; - background-color: white; + background-color: var(--ifm-background-surface-color); border-radius: 8px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); z-index: 2; @@ -85,10 +85,20 @@ const templates = { + Graph View + `, scriptGraph: ` let graphViewGlobal = null; + let isOpen = false; + async function initGraphView() { const notes = await ( await fetch('/docusaurus-graph.json') @@ -111,21 +121,31 @@ const templates = { const graphContainer = document.getElementById('graph-container'); const graphOverlay = document.getElementById('graph-overlay'); - function openGraph() { - graphContainer.style.display = 'block'; - graphOverlay.style.display = 'block'; - graphViewGlobal.forceGraph.zoomToFit(1000, 20); - } - graphOverlay.addEventListener('click', closeGraph); function closeGraph() { graphContainer.style.display = 'none'; graphOverlay.style.display = 'none'; } + + function openGraph() { + if(isOpen === true) { + closeGraph(); + isOpen = false; + } else { + if(window.innerWidth >= 800 && window.innerHeight >= 720) { + graphContainer.style.display = 'block'; + graphOverlay.style.display = 'block'; + graphViewGlobal.forceGraph.zoomToFit(1000, 20); + isOpen = true; + } else { + alert('Your screen size must be greater than 800x720.'); + } + } + } `, containerGraph: `
-
+
X