Last active
October 2, 2015 16:01
-
-
Save lukemorton/cbe4d72228c45d1e7d9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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