From b44acd9eea7b1e41629d92a8608bbb661b628569 Mon Sep 17 00:00:00 2001 From: David Mosbach Date: Sat, 27 May 2023 16:40:45 +0200 Subject: [PATCH] WIP: side panel for information about selection --- editor.css | 32 ++++++++++++++++++++++++++++++++ editor.html | 11 +++++++++++ editor.js | 13 ++++++++++++- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/editor.css b/editor.css index 1af35c1..e859e2c 100644 --- a/editor.css +++ b/editor.css @@ -18,6 +18,7 @@ body { position: fixed; padding: 8 8 8 8; background-color: rgb(230, 230, 230); + opacity: 0.95; z-index: 2; float: left; overflow: auto; @@ -30,4 +31,35 @@ body { overflow: hidden; float: left; margin-right: 20; +} + +#sidepanel { + position:fixed; + background-color: rgb(230, 230, 230); + box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); + top: 80px; + bottom:30px; + right:20px; + width: 500px; + opacity: 0.95; + padding: 20px; + border-radius: 20px; + z-index:10; + display: none; +} + +#sideheader { + width: 100%; +} + +#sideheader h1 { + text-align: center; + font-size: 2em; + font-style: normal; +} + +#sideheader svg { + position: absolute; + top: 20px; + right: 20px; } \ No newline at end of file diff --git a/editor.html b/editor.html index 4d74269..6f510e5 100644 --- a/editor.html +++ b/editor.html @@ -25,6 +25,17 @@ +
+
+

Hello

+ + + + X + +
+ +
diff --git a/editor.js b/editor.js index ea2d4e7..c41c97e 100644 --- a/editor.js +++ b/editor.js @@ -153,6 +153,7 @@ const selfLoopCurvMin = 0.5; // Minimum curvature of a self loop. const curvatureMinMax = 0.2; // Minimum/maximum curvature (1 +/- x) of overlapping edges. var selection = null; // The currently selected node/edge. +const sidePanel = document.getElementById('sidepanel'); const edgeColourDefault = '#999999ff'; const edgeColourSelected = '#000000ff'; @@ -234,7 +235,17 @@ function computeCurvatures() { * @param {*} item The node or edge to select. */ function select(item) { - selection = item; + selection = selection === item ? null : item; + if (selection === item) { + sidePanel.style.display = 'block' + document.getElementById('sideheading').innerHTML = item.name; + var data = document.createElement('div'); + var text = document.createTextNode(JSON.stringify(selection.stateData && selection.stateData || selection.actionData)); + data.appendChild(text); + sidePanel.appendChild(data); + } else { + sidePanel.style.display = 'none' + } console.log(item); // TODO }