From a039c4d95e21e707cfe962eb9fbfd37c5ff7cb9e Mon Sep 17 00:00:00 2001 From: jfh Date: Mon, 9 Nov 2020 20:30:37 +0100 Subject: [PATCH] progress --- src/editor/components/seExplorerButton.js | 13 +++++++++++-- .../extensions/ext-shapes/shapelib/index.json | 13 ++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/editor/components/seExplorerButton.js b/src/editor/components/seExplorerButton.js index 651e3cdf..1bb8afd5 100644 --- a/src/editor/components/seExplorerButton.js +++ b/src/editor/components/seExplorerButton.js @@ -238,6 +238,8 @@ export class ExplorerButton extends HTMLElement { connectedCallback () { // capture click event on the button to manage the logic const onClickHandler = (ev) => { + console.log(ev.target); + ev.stopPropagation(); switch (ev.target.nodeName) { case 'SE-EXPLORERBUTTON': this.$menu.classList.add('open'); @@ -247,9 +249,10 @@ export class ExplorerButton extends HTMLElement { // change to the current action this.$img.setAttribute('src', ev.target.getAttribute('src')); this.currentAction = ev.target; - this.setAttribute('pressed', 'pressed'); + this.currentAction.setAttribute('pressed', 'pressed'); // and close the menu this.$menu.classList.remove('open'); + this.$lib.classList.remove('open-lib'); break; case 'DIV': this._shadowRoot.querySelectorAll('.menu > .pressed').forEach((b) => { b.classList.remove('pressed'); }); @@ -264,6 +267,7 @@ export class ExplorerButton extends HTMLElement { // capture event from slots this.addEventListener('click', onClickHandler); this.$menu.addEventListener('click', onClickHandler); + this.$lib.addEventListener('click', onClickHandler); } /** * @function updateLib @@ -277,11 +281,16 @@ export class ExplorerButton extends HTMLElement { const response = await fetch(`${libDir}${lib}.json`); const json = await response.json(); const {data} = json; + const size = json.size ?? 300; + const fill = json.fill ? '#333' : 'none'; + const off = size * 0.05; + const vb = [-off, -off, size + off * 2, size + off * 2].join(' '); + const stroke = json.fill ? 0 : (size / 30); // eslint-disable-next-line no-unsanitized/property this.$lib.innerHTML = Object.entries(data).map(([key, path]) => { const encoded = btoa(` - + `); return ``; }).join(''); diff --git a/src/editor/extensions/ext-shapes/shapelib/index.json b/src/editor/extensions/ext-shapes/shapelib/index.json index 3e1fe0da..d5d4b858 100644 --- a/src/editor/extensions/ext-shapes/shapelib/index.json +++ b/src/editor/extensions/ext-shapes/shapelib/index.json @@ -2,6 +2,17 @@ "lib": [ "basic", "animal", - "game" + "arrow", + "dialog_balloon", + "electronics", + "flowchart", + "game", + "math", + "misc", + "music", + "object", + "raphael_1", + "raphael_2", + "symbol" ] } \ No newline at end of file