Skip to content

Commit

Permalink
[error-modal] Fix react errors when x-button is mounted
Browse files Browse the repository at this point in the history
  • Loading branch information
kimo-k committed Oct 18, 2024
1 parent 54a2a82 commit 2273858
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
11 changes: 6 additions & 5 deletions src/re_com/error_modal.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
:on-mouse-leave (partial reset! hover? false)
:on-click on-click
:style {:padding "12px 7px 7px 7px"}}
[u/x-button (merge props {:width "12px"
:height "12px"
:hover? hover?
:stroke (if @hover? "#000000" "#ffffff")
:stroke-width "1.2px"})]])))
[u/x-button (merge {:width "12px"
:height "12px"
:hover? hover?
:stroke (if @hover? "#000000" "#ffffff")
:stroke-width "1.2px"}
props)]])))

(defn error-modal
[& {:keys [severity title
Expand Down
29 changes: 14 additions & 15 deletions src/re_com/util.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -268,25 +268,24 @@
:down "4,7 8,2 0,2")
:fill fill}]])

(defn x-button [& {:as props}]
(defn x-button [& {}]
(let [hover-internal? (r/atom nil)]
(fn [& {:keys [hover? width height stroke-width]
(fn [& {:keys [hover? on-click width height stroke-width]
:or {width "9px"
height "9px"
hover? hover-internal?
stroke-width "1px"}
:as props}]
[:svg (merge {:on-mouse-enter (partial reset! hover? true)
:on-mouse-leave (partial reset! hover? false)
:width width
:height height
:viewBox (str "0 0 " (<-px width) " " (<-px height))
:xmlns "http://www.w3.org/2000/svg"
:stroke (if (deref-or-value hover?) "#767a7c" "currentColor")
:stroke-width stroke-width}
props)
[:line {:x1 0 :y1 0 :x2 (<-px width) :y2 (<-px height)}]
[:line {:x1 0 :y1 (<-px height) :x2 (<-px width) :y2 0}]])))
stroke-width "1px"}}]
[:div {:on-click on-click}
[:svg {:on-mouse-enter (partial reset! hover? true)
:on-mouse-leave (partial reset! hover? false)
:width width
:height height
:viewBox (str "0 0 " (<-px width) " " (<-px height))
:xmlns "http://www.w3.org/2000/svg"
:stroke (if (deref-or-value hover?) "#767a7c" "currentColor")
:stroke-width stroke-width}
[:line {:x1 0 :y1 0 :x2 (<-px width) :y2 (<-px height)}]
[:line {:x1 0 :y1 (<-px height) :x2 (<-px width) :y2 0}]]])))

(def scrollbar-thickness 10)
(def scrollbar-margin 2)
Expand Down

0 comments on commit 2273858

Please sign in to comment.