aboutsummaryrefslogtreecommitdiff
path: root/notif/example.js
diff options
context:
space:
mode:
Diffstat (limited to 'notif/example.js')
-rw-r--r--notif/example.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/notif/example.js b/notif/example.js
new file mode 100644
index 0000000..1a543fd
--- /dev/null
+++ b/notif/example.js
@@ -0,0 +1,42 @@
+// SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info>
+// SPDX-License-Identifier: GPL-3.0-or-later
+import { WuiNotif, WUI_NOTIF_CLASS_ERROR, WUI_NOTIF_CLASS_INFO, } from "./notif.js";
+let inputMsg;
+let wuiNotif;
+function main() {
+ wuiNotif = new WuiNotif();
+ inputMsg = document.createElement("textarea");
+ inputMsg.id = "input_msg";
+ inputMsg.value =
+ "Test notification with HTML format using <b>bold</b> and <u>underline</u> words.";
+ document.body.appendChild(inputMsg);
+ const elWrapper = document.createElement("div");
+ elWrapper.style.marginTop = "10px";
+ document.body.appendChild(elWrapper);
+ const elButtonInfo = document.createElement("button");
+ elButtonInfo.innerText = "Info";
+ elButtonInfo.style.marginRight = "10px";
+ elButtonInfo.onclick = notifInfo;
+ elWrapper.appendChild(elButtonInfo);
+ const elButtonError = document.createElement("button");
+ elButtonError.innerText = "Error";
+ elButtonError.onclick = notifError;
+ elWrapper.appendChild(elButtonError);
+ document.body.appendChild(document.createElement("p"));
+ const previewError = document.createElement("div");
+ previewError.classList.add(`${WUI_NOTIF_CLASS_ERROR}`);
+ previewError.innerText = `Preview of error style`;
+ document.body.appendChild(previewError);
+ const previewInfo = document.createElement("div");
+ previewInfo.classList.add(`${WUI_NOTIF_CLASS_INFO}`);
+ previewInfo.innerText = `Preview of info style`;
+ document.body.appendChild(previewInfo);
+}
+function notifInfo() {
+ wuiNotif.info(inputMsg.value);
+}
+function notifError() {
+ wuiNotif.error(inputMsg.value);
+}
+// ----
+main();