Skip to content

Instantly share code, notes, and snippets.

@aarkerio
Last active October 22, 2018 19:17
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 aarkerio/11a8606a1253fea50910a17325826536 to your computer and use it in GitHub Desktop.
Save aarkerio/11a8606a1253fea50910a17325826536 to your computer and use it in GitHub Desktop.
Hide show ClojureScript reagent edit form
(defn question-item
[{:keys [question explanation hint key qtype id ordnen] :as q}]
(let [counter (reagent/atom 0)
editing (reagent/atom false)] ;; show and switch icons (Edit/Cancel)
(fn []
[:div.div-separator {:key (str "div-question-separator-" id) :id (str "div-question-separator-" id)}
(if @editing
[:img.img-float-right {:title "Cancel question"
:alt "Cancel question"
:key (str "cancel-question-img-" id)
:id (str "cancel-question-img-" id)
:src "/img/icon_cancel.png"
:on-click #(swap! editing not)}]
[:img.img-float-right {:title "Edit question"
:alt "Edit question"
:key (str "edit-question-img-" id)
:id (str "edit-question-img-" id)
:src "/img/icon_edit.png"
:on-click #(swap! editing not)}])
[:p {:key (str "div-question" id) :id (str "div-question" id)} [:span.bold-font (str key ".-")] "Question: " question " ordnen:" ordnen " id:" id]
[:p {:key (str "div-hint" id) :id (str "div-hint" id)} [:span.bold-font "Hint: "] hint]
[:p {:key (str "div-explan" id) :id (str "div-explan" id)} [:span.bold-font "Explanation: "] explanation]
(when @editing
[simple-input q]) <-- react component
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment