diff options
| author | Shulhan <ms@kilabit.info> | 2021-09-05 22:46:05 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-09-05 22:46:05 +0700 |
| commit | e3da79cf1adfb6dc2d9fed2e982bcde7fe7a7161 (patch) | |
| tree | 74b71ed9f9c3b58d93269a9cda32729a9c679d2a /notif/example.ts | |
| parent | 903561a9074da0632e1e001db3879cc45f974493 (diff) | |
| download | pakakeh.ts-e3da79cf1adfb6dc2d9fed2e982bcde7fe7a7161.tar.xz | |
notif: convert the example using TypeScript and load it with type="module"
Diffstat (limited to 'notif/example.ts')
| -rw-r--r-- | notif/example.ts | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/notif/example.ts b/notif/example.ts new file mode 100644 index 0000000..bb919ae --- /dev/null +++ b/notif/example.ts @@ -0,0 +1,52 @@ +import { WuiNotif, WUI_NOTIF_CLASS_ERROR, WUI_NOTIF_CLASS_INFO } from "./notif.js" + +let inputMsg: HTMLTextAreaElement +let wuiNotif: WuiNotif + +function main() { + wuiNotif = new WuiNotif() + + inputMsg = document.createElement("textarea") as HTMLTextAreaElement + inputMsg.id = "input_msg" + inputMsg.value = `Hello world, this is a notification with HTML format using <b>bold</b> and <u>underline</u> words.` + document.body.appendChild(inputMsg) + + let el_wrapper = document.createElement("div") + el_wrapper.style.marginTop = "10px" + document.body.appendChild(el_wrapper) + + let el_button_info = document.createElement("button") + el_button_info.innerText = "Info" + el_button_info.style.marginRight = "10px" + el_button_info.onclick = notifInfo + el_wrapper.appendChild(el_button_info) + + let el_button_error = document.createElement("button") + el_button_error.innerText = "Error" + el_button_error.onclick = notifError + el_wrapper.appendChild(el_button_error) + + document.body.appendChild(document.createElement("p")) + + let previewError = document.createElement("div") + previewError.classList.add(`${WUI_NOTIF_CLASS_ERROR}`) + previewError.innerText = `Preview of error style` + document.body.appendChild(previewError) + + let 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() |
