Skip to content

Instantly share code, notes, and snippets.

@cassiomarques
Created September 21, 2015 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cassiomarques/0b7c5ba7576bb847b872 to your computer and use it in GitHub Desktop.
Save cassiomarques/0b7c5ba7576bb847b872 to your computer and use it in GitHub Desktop.
;; The idea is to replace the component's content when the atom's value changes.
;; The state for :initial is displayed when the component is first rendered but does not change
;; when `delete-button` is clicked, even though the atom is correctly reset.
(defn delete-button-component [card]
(let [on-delete-clicked (fn [] (reset! delete-state :confirming))
delete-button (fn [card]
[:button {:class "circular ui icon button delete-card" :title "Delete card" :on-click on-delete-clicked}
[:i {:class "icon erase"}]])
confirmation-buttons (fn [card] [:span
[:button {:class "ui button cancel"} "Cancel"]
[:button {:class "ui button confirm"} "I'm sure!"]])]
(fn [card]
(condp = @delete-state
:initial delete-button
:confirming confirmation-buttons))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment