diff --git a/app/javascript/application.js b/app/javascript/application.js index 94309267..e527b5fb 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -47,7 +47,3 @@ window.customElements.define('template-builder', class extends HTMLElement { this.appElem?.remove() } }) - -document.addEventListener('clipboard-copy', function (event) { - console.log('Copied to clipboard') // TODO: Add a toast message -}) diff --git a/app/javascript/elements/clipboard_copy.js b/app/javascript/elements/clipboard_copy.js index c059bff5..8c248425 100644 --- a/app/javascript/elements/clipboard_copy.js +++ b/app/javascript/elements/clipboard_copy.js @@ -99,9 +99,16 @@ async function copy (button) { button.dispatchEvent(new CustomEvent('clipboard-copy', { bubbles: true })) } + function toggleActiveIcon () { + if (button.classList.contains('swap')) { + button.classList.toggle('swap-active') + } + } + if (text) { await copyText(text) trigger() + toggleActiveIcon() } else if (id) { const root = 'getRootNode' in Element.prototype ? button.getRootNode() : button.ownerDocument @@ -112,6 +119,7 @@ async function copy (button) { if (node) { await copyTarget(node) trigger() + toggleActiveIcon() } } } diff --git a/app/views/icons/_calendar.html.erb b/app/views/icons/_calendar.html.erb index a396d7f6..83b73501 100644 --- a/app/views/icons/_calendar.html.erb +++ b/app/views/icons/_calendar.html.erb @@ -1,4 +1,4 @@ - + diff --git a/app/views/icons/_clipboard_copy.html.erb b/app/views/icons/_clipboard_copy.html.erb new file mode 100644 index 00000000..2a3fc905 --- /dev/null +++ b/app/views/icons/_clipboard_copy.html.erb @@ -0,0 +1,6 @@ + + + + + + diff --git a/app/views/submissions/index.html.erb b/app/views/submissions/index.html.erb index 8b715478..0ea38f5b 100644 --- a/app/views/submissions/index.html.erb +++ b/app/views/submissions/index.html.erb @@ -9,8 +9,9 @@ Share link