mirror of
https://github.com/lus/pasty.git
synced 2023-08-10 21:13:09 +03:00
Improve the frontend (API v2 functionalities) (#18)
* Fix line number height issue * Fix notification container position * Remove line wrapping * Switch to the new API * Rework JS & implement paste editing * Implement paste reports * Document the report webhook
This commit is contained in:
committed by
GitHub
parent
149abf77f1
commit
70c4392390
25
web/assets/js/modules/notifications.js
Normal file
25
web/assets/js/modules/notifications.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import * as Animation from "./animation.js";
|
||||
|
||||
const ELEMENT = document.getElementById("notifications");
|
||||
|
||||
// Shows a success notification
|
||||
export function success(message) {
|
||||
create("success", message, 3000);
|
||||
}
|
||||
|
||||
// Shows an error notification
|
||||
export function error(message) {
|
||||
create("error", message, 3000);
|
||||
}
|
||||
|
||||
// Creates a new custom notification
|
||||
function create(type, message, duration) {
|
||||
const node = document.createElement("div");
|
||||
node.classList.add(type);
|
||||
Animation.animate(node, "animate__fadeInUp", "0.2s");
|
||||
node.innerHTML = message;
|
||||
|
||||
ELEMENT.childNodes.forEach(child => Animation.animate(child, "animate__slideInUp", "0.2s"));
|
||||
ELEMENT.appendChild(node);
|
||||
setTimeout(() => Animation.animate(node, "animate__fadeOutUp", "0.2s", () => ELEMENT.removeChild(node)), duration);
|
||||
}
|
||||
Reference in New Issue
Block a user