From 2e716dcc9701167f2da600cae344d77d282dcefd Mon Sep 17 00:00:00 2001 From: ckonstanski Date: Mon, 13 Jul 2026 14:57:37 -0600 Subject: added react version --- src/org_ckons_cljs/notifications/react.cljs | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/org_ckons_cljs/notifications/react.cljs (limited to 'src/org_ckons_cljs/notifications/react.cljs') 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))) -- cgit v1.3