2015-02-10 14:18:56 +01:00
|
|
|
(ns simpleexample.core
|
2015-07-31 09:32:17 +02:00
|
|
|
(:require [reagent.core :as r]))
|
2013-12-16 23:19:36 +01:00
|
|
|
|
2015-07-31 09:32:17 +02:00
|
|
|
(defonce timer (r/atom (js/Date.)))
|
2013-12-16 23:19:36 +01:00
|
|
|
|
2015-07-31 09:32:17 +02:00
|
|
|
(defonce time-color (r/atom "#f34"))
|
2015-02-09 09:43:43 +01:00
|
|
|
|
|
|
|
(defonce time-updater (js/setInterval
|
|
|
|
#(reset! timer (js/Date.)) 1000))
|
2013-12-16 23:19:36 +01:00
|
|
|
|
2014-02-15 13:50:10 +01:00
|
|
|
(defn greeting [message]
|
|
|
|
[:h1 message])
|
2013-12-16 23:19:36 +01:00
|
|
|
|
|
|
|
(defn clock []
|
2014-01-07 12:45:08 +01:00
|
|
|
(let [time-str (-> @timer .toTimeString (clojure.string/split " ") first)]
|
2013-12-16 23:19:36 +01:00
|
|
|
[:div.example-clock
|
|
|
|
{:style {:color @time-color}}
|
|
|
|
time-str]))
|
|
|
|
|
|
|
|
(defn color-input []
|
|
|
|
[:div.color-input
|
|
|
|
"Time color: "
|
|
|
|
[:input {:type "text"
|
|
|
|
:value @time-color
|
|
|
|
:on-change #(reset! time-color (-> % .-target .-value))}]])
|
|
|
|
|
|
|
|
(defn simple-example []
|
|
|
|
[:div
|
2014-02-15 13:50:10 +01:00
|
|
|
[greeting "Hello world, it is now"]
|
2013-12-16 23:19:36 +01:00
|
|
|
[clock]
|
|
|
|
[color-input]])
|
|
|
|
|
|
|
|
(defn ^:export run []
|
2015-07-31 09:32:17 +02:00
|
|
|
(r/render [simple-example]
|
|
|
|
(js/document.getElementById "app")))
|