Skip to content

Instantly share code, notes, and snippets.

@lukemorton
Last active October 2, 2015 16:01
Show Gist options
  • Save lukemorton/cbe4d72228c45d1e7d9e to your computer and use it in GitHub Desktop.
Save lukemorton/cbe4d72228c45d1e7d9e to your computer and use it in GitHub Desktop.
(ns big-time.ui.clock
(:require [quiescent.core :as q]
[quiescent.dom :as dom]
[clojure.string :as string]
[big-time.ui.app :as app]))
(q/defcomponent Clock
:name "Clock"
:css {:clock {:font-size "3em"}
:clock__unit {:margin-left "1em"}}
:on-render (fn [_ data] (set-doc-title-as-time data))
[data]
(dom/div {:css :clock}
(dom/span {:css :clock__unit} (get (:current-time data) 0))
(dom/span {:css :clock__unit} ":" (get (:current-time data) 1))
(dom/span {:css :clock__unit} ":" (get (:current-time data) 2))))
(defn- set-doc-title-as-time [data]
(set! (.-title js/document) (string/join ":" (:current-time data))))
(ns big-time.ui.clock
(:require [quiescent.core :as q]
[quiescent.dom :as dom]
[clojure.string :as string]
[big-time.ui.app :as app]))
(q/defcomponent Clock
:name "Clock"
:css {:clock {:font-size "3em"}
:clock__unit {:margin-left "1em"}}
:on-render (fn [_ data] (set-doc-title-as-time data))
[data]
(dom/div {:css :clock}
(dom/span (-> {} (with-css :clock__unit)) (get (:current-time data) 0))
(dom/span (-> {} (with-css :clock__unit)) ":" (get (:current-time data) 1))
(dom/span (-> {} (with-css :clock__unit)) ":" (get (:current-time data) 2))))
(defn- set-doc-title-as-time [data]
(set! (.-title js/document) (string/join ":" (:current-time data))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment