From c7d816155ccac31a639deb6f0cde5a4733160d77 Mon Sep 17 00:00:00 2001 From: jfh Date: Sun, 25 Oct 2020 20:00:12 +0100 Subject: [PATCH] move layout buttons to web components --- src/editor/components/seButton.js | 39 +++++++++++++++++++--- src/editor/images/context_menu.svg | 9 +++++ src/editor/images/go_down.svg | 9 +++++ src/editor/images/go_up.svg | 9 +++++ src/editor/images/new.svg | 10 ++++++ src/editor/images/svg_edit_icons.svg | 49 ---------------------------- src/editor/index.html | 16 ++++----- src/editor/svgedit.css | 31 ++---------------- src/editor/svgedit.js | 49 +++++++++------------------- 9 files changed, 98 insertions(+), 123 deletions(-) create mode 100644 src/editor/images/context_menu.svg create mode 100644 src/editor/images/go_down.svg create mode 100644 src/editor/images/go_up.svg create mode 100644 src/editor/images/new.svg diff --git a/src/editor/components/seButton.js b/src/editor/components/seButton.js index 7f73214f..abcbcea1 100644 --- a/src/editor/components/seButton.js +++ b/src/editor/components/seButton.js @@ -19,11 +19,17 @@ template.innerHTML = ` cursor: pointer; border-radius: 3px; } + .small { + width: 14px; + height: 14px; + padding: 1px; + border-radius: 1px; + } img { border: none; - width: 24px; - height: 24px; overflow: none; + width: 100%; + height: 100%; } .pressed { background-color: #F4E284 !important; @@ -35,7 +41,7 @@ template.innerHTML = ` }
- icon + icon
`; /** @@ -59,7 +65,7 @@ export class ToolButton extends HTMLElement { * @returns {any} observed */ static get observedAttributes () { - return ['title', 'src', 'pressed', 'disabled']; + return ['title', 'src', 'pressed', 'disabled', 'size']; } /** * @function attributeChangedCallback @@ -74,7 +80,7 @@ export class ToolButton extends HTMLElement { case 'title': { const shortcut = this.getAttribute('shortcut'); - this.$div.setAttribute('title', `${newValue} [${shortcut}]`); + this.$div.setAttribute('title', `${newValue} ${shortcut ? `[${shortcut}]` : ''}`); } break; case 'src': @@ -87,6 +93,13 @@ export class ToolButton extends HTMLElement { this.$div.classList.remove('pressed'); } break; + case 'size': + if (newValue === 'small') { + this.$div.classList.add('small'); + } else { + this.$div.classList.remove('small'); + } + break; case 'disabled': if (newValue) { this.$div.classList.add('disabled'); @@ -171,6 +184,22 @@ export class ToolButton extends HTMLElement { this.setAttribute('src', value); } + /** + * @function get + * @returns {any} + */ + get size () { + return this.getAttribute('size'); + } + + /** + * @function set + * @returns {void} + */ + set size (value) { + this.setAttribute('size', value); + } + /** * @function connectedCallback * @returns {void} diff --git a/src/editor/images/context_menu.svg b/src/editor/images/context_menu.svg new file mode 100644 index 00000000..4bc94a31 --- /dev/null +++ b/src/editor/images/context_menu.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/editor/images/go_down.svg b/src/editor/images/go_down.svg new file mode 100644 index 00000000..504a2d46 --- /dev/null +++ b/src/editor/images/go_down.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/editor/images/go_up.svg b/src/editor/images/go_up.svg new file mode 100644 index 00000000..b8cbbf9f --- /dev/null +++ b/src/editor/images/go_up.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/editor/images/new.svg b/src/editor/images/new.svg new file mode 100644 index 00000000..e4e250e8 --- /dev/null +++ b/src/editor/images/new.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/editor/images/svg_edit_icons.svg b/src/editor/images/svg_edit_icons.svg index ffae5896..79194ec9 100644 --- a/src/editor/images/svg_edit_icons.svg +++ b/src/editor/images/svg_edit_icons.svg @@ -257,19 +257,6 @@ - - - - - - - - - - - - - @@ -360,42 +347,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/editor/index.html b/src/editor/index.html index c72d604d..c106cf8b 100644 --- a/src/editor/index.html +++ b/src/editor/index.html @@ -52,12 +52,12 @@

Layers

-
-
-
-
-
-
+ + + + + +
@@ -140,7 +140,7 @@ - +