Skip to content

Commit

Permalink
refactor(clippy): deduplicate showToastCopied()
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed Oct 30, 2023
1 parent 9d8131e commit dc9ea96
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions editor/js/editor-libs/clippy.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,17 @@ function showToastCopied(copyButton) {
/** @var {HTMLElement} */
const toastElement = document.getElementById("user-message");

toastElement.classList.add("show");
toastElement.setAttribute("aria-hidden", "false");
const toggleToast = (show) => {
toastElement.classList.toggle("show", show);
toastElement.setAttribute("aria-hidden", JSON.stringify(!show));
};

toggleToast(true);

setToastPosition(copyButton, toastElement);

window.setTimeout(() => {
toastElement.classList.remove("show");
toastElement.setAttribute("aria-hidden", "true");
toggleToast(false);
}, 1000);
}

Expand Down

0 comments on commit dc9ea96

Please sign in to comment.