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