SHARE
TWEET

Untitled

a guest Jul 17th, 2017 38 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (require '[reagent.core :as reagent])
  2.  
  3. (def color
  4.   (reagent/atom "black"))
  5.  
  6. (def styles
  7.   {:inputs {:padding "15px"}
  8.    :inputs-label {:margin-left "5px"}
  9.    :text {:fontSize "20px"}})
  10.  
  11. (defn color-item [n]
  12.   [:label {:style (:inputs styles)}
  13.    [:input {:type "radio" :name "color" :onClick #(reset! color n)}]
  14.    [:span {:style (:inputs-label styles)} n]])
  15.  
  16. (defn color-picker []
  17.   [:div
  18.    [color-item "Chocolate"]
  19.    [color-item "CornflowerBlue"]
  20.    [color-item "LightSeaGreen"]])
  21.  
  22. (defn color-example []
  23.   [:div
  24.    [color-picker]
  25.    [:p {:style (assoc (:text styles) :color @color)}
  26.     "My color is dynamic, change it !"]])
  27.  
  28. (reagent/render [color-example] js/klipse-container)
RAW Paste Data
Top