summaryrefslogtreecommitdiff
path: root/src/org_ckons_cljs/notifications/react.cljs
diff options
context:
space:
mode:
authorckonstanski <carlos.konstanski@olo.com>2026-07-13 14:57:37 -0600
committerckonstanski <carlos.konstanski@olo.com>2026-07-13 14:57:37 -0600
commit2e716dcc9701167f2da600cae344d77d282dcefd (patch)
treefac2fb90f50a5b405462602f34f36ed140857231 /src/org_ckons_cljs/notifications/react.cljs
parente4b2e2e4171311c9007c27fb3adb8276d474fc8d (diff)
added react version
Diffstat (limited to 'src/org_ckons_cljs/notifications/react.cljs')
-rw-r--r--src/org_ckons_cljs/notifications/react.cljs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/org_ckons_cljs/notifications/react.cljs b/src/org_ckons_cljs/notifications/react.cljs
new file mode 100644
index 0000000..9fad6a4
--- /dev/null
+++ b/src/org_ckons_cljs/notifications/react.cljs
@@ -0,0 +1,39 @@
+(ns org-ckons-cljs.notifications.react
+ (:require-macros [hiccups.core :as hiccups :refer [html]])
+ (:require [hiccups.runtime :as hiccupsrt]
+ [dommy.core :as dommy]
+ [clojure.string :as str]
+ [reagent.core :as r]
+ [reagent.dom :as rd]
+ [reagent.dom.client :as rdc]))
+
+(declare reset-message)
+(declare reset-errormsg)
+(declare comp-message)
+(declare comp-errormsg)
+(declare set-message)
+(declare set-errormsg)
+
+(def notification-state (r/atom {:message nil :errormsg nil}))
+
+(defn reset-message [message]
+ (reset! notification-state (assoc @notification-state :message message)))
+
+(defn reset-errormsg [errormsg]
+ (reset! notification-state (assoc @notification-state :errormsg errormsg)))
+
+(defn comp-message []
+ [:div {:class "alert alert-success"
+ :style {:display (cond (empty? (@notification-state :message)) "none" :else "block")}}
+ (@notification-state :message)])
+
+(defn comp-errormsg []
+ [:div {:class "alert alert-danger"
+ :style {:display (cond (empty? (@notification-state :errormsg)) "none" :else "block")}}
+ (@notification-state :errormsg)])
+
+(defn set-message [message]
+ (reset! notification-state (assoc @notification-state :message message)))
+
+(defn set-errormsg [errormsg]
+ (reset! notification-state (assoc @notification-state :errormsg errormsg)))