From ecc398de0debba132888fc5a738a7ebf53afd2d2 Mon Sep 17 00:00:00 2001 From: kishtarn555 Date: Sat, 28 Sep 2024 19:24:56 -0600 Subject: [PATCH 1/2] [UI][Feature] Toasts --- html/desktop/app.html | 1 + html/toasts.html | 54 +++++++++++++++++++++++++++++++++++++++++ resources/css/style.css | 20 ++++++++++++++- src/index.ts | 4 +++ webapp/css/style.css | 20 ++++++++++++++- webapp/index.html | 54 +++++++++++++++++++++++++++++++++++++++++ webapp/js/cindex.js | 3 +++ 7 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 html/toasts.html diff --git a/html/desktop/app.html b/html/desktop/app.html index 584b790b..616f6eaf 100644 --- a/html/desktop/app.html +++ b/html/desktop/app.html @@ -5,6 +5,7 @@ @@include('./editor.html') @@include('./karel.html') + @@include('../toasts.html') diff --git a/html/toasts.html b/html/toasts.html new file mode 100644 index 00000000..eaba018d --- /dev/null +++ b/html/toasts.html @@ -0,0 +1,54 @@ +
+
+
+ + + + + + + +
+
+
\ No newline at end of file diff --git a/resources/css/style.css b/resources/css/style.css index 6094a1c2..1635a18c 100644 --- a/resources/css/style.css +++ b/resources/css/style.css @@ -298,4 +298,22 @@ pre.error-popup { .hidden-mobile { display: none; } -} \ No newline at end of file +} + + + +.toast-danger { + color: #fff!important; + background-color: RGBA(var(--bs-danger-rgb), 0.8)!important; +} + +.toast-success { + color: #fff!important; + background-color: RGBA(var(--bs-success-rgb), 0.8)!important; +} + +.toast-primary { + color: #fff!important; + background-color: RGBA(var(--bs-primary-rgb), 0.85)!important; +} + diff --git a/src/index.ts b/src/index.ts index 34a0dd56..95371f17 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,6 +12,7 @@ import { HookSession, RestoreSession } from "./session"; import { RegisterHighlightListeners } from "./editor/editor.listeners"; import { editorJava2pascal, editorPascal2Java } from "./editor/transpiler"; import { MobileUI } from "./mobile/mobile"; +import bootstrap from "bootstrap"; let KarelWorld: World = new World(100, 100); @@ -445,6 +446,9 @@ $(document).ready(() => { DesktopUI.Init(); StartSettings(DesktopUI); RestoreSession(); + $(".toast").each(function( index ) { + bootstrap.Toast.getOrCreateInstance($(this)[0]).show() + }); }) export const GetKarelController = KarelController.GetInstance; diff --git a/webapp/css/style.css b/webapp/css/style.css index 6094a1c2..1635a18c 100644 --- a/webapp/css/style.css +++ b/webapp/css/style.css @@ -298,4 +298,22 @@ pre.error-popup { .hidden-mobile { display: none; } -} \ No newline at end of file +} + + + +.toast-danger { + color: #fff!important; + background-color: RGBA(var(--bs-danger-rgb), 0.8)!important; +} + +.toast-success { + color: #fff!important; + background-color: RGBA(var(--bs-success-rgb), 0.8)!important; +} + +.toast-primary { + color: #fff!important; + background-color: RGBA(var(--bs-primary-rgb), 0.85)!important; +} + diff --git a/webapp/index.html b/webapp/index.html index a36eabd6..f74b9b8e 100644 --- a/webapp/index.html +++ b/webapp/index.html @@ -905,6 +905,60 @@
Procesando
+
+
+
+ + + + + + + +
+
+
diff --git a/webapp/js/cindex.js b/webapp/js/cindex.js index fc193cfd..90e996c5 100644 --- a/webapp/js/cindex.js +++ b/webapp/js/cindex.js @@ -33352,6 +33352,9 @@ var karel = (function (exports, bootstrap) { DesktopUI.Init(); StartSettings(DesktopUI); RestoreSession(); + $(".toast").each(function (index) { + bootstrap.Toast.getOrCreateInstance($(this)[0]).show(); + }); }); const GetKarelController = KarelController.GetInstance; function MoveEditorCursorToLine(line, column = 0) { From 2c7c334f8b02f75b2e200be4f0e3a21b33800ad6 Mon Sep 17 00:00:00 2001 From: kishtarn555 Date: Sat, 28 Sep 2024 19:50:21 -0600 Subject: [PATCH 2/2] [Toast][UI] Toasts notifications are now event driven --- html/toasts.html | 4 +-- src/desktop/desktop-ui.ts | 11 +++++---- src/desktop/toast.ts | 52 +++++++++++++++++++++++++++++++++++++++ src/index.ts | 11 ++++++--- webapp/index.html | 4 +-- webapp/js/cindex.js | 50 ++++++++++++++++++++++++++++++++++--- 6 files changed, 116 insertions(+), 16 deletions(-) create mode 100644 src/desktop/toast.ts diff --git a/html/toasts.html b/html/toasts.html index eaba018d..fe20dd58 100644 --- a/html/toasts.html +++ b/html/toasts.html @@ -3,7 +3,7 @@
-