Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(ns rmfu-ui.profile
[reagent.core :as reagent :refer [atom]])) ;; <--- special version of the atom here, rerenders componets on change
(defn input-range-component
[state param]
"Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."]
"Agree "
{:type "range"
:min 0
:max 3
:step 1
:list "agreevalues"
:value (:agreeness @state);; <---- notice the binding of the value to the input
:on-change (fn [e]
(println (-> e .-target .-value));; <----- checkout out the console,
;; we should see this value printed
(swap! state assoc param (-> e .-target .-value)) ;; <--- state transition happening here!
" Disagree"]])
(defn profile []
(let [app-state (atom {:agreeness 0})] ;; <----- define some app-state to play with
{:style {:max-width "700px"}}
"Tell Us About Yourself"]
[input-range-component app-state :agreeness] ;; <--- we use the component here
{:type "text", :placeholder "First Name", :value ""}]]
{:type "text", :placeholder "Last Name", :value ""}]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment