Created
September 29, 2015 18:53
-
-
Save bsima/a1c4ecbd7f7887c54a0c 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 bio.nebula.client | |
"State handler for all of the client-side stuff." | |
(:require-macros [javelin.core :refer [defc defc= cell=]] | |
[hoplon.core :refer [loop-tpl defelem]]) | |
(:require | |
[javelin.core :as j :refer [cell]] | |
[castra.core :as c :refer [mkremote]] | |
[hoplon.core :as h])) | |
;; card component state | |
(defc state {}) | |
(defc error nil) | |
(defc= error-message (when error (.-message error))) | |
(defc loading ["loading"]) | |
(defc= needs-funding-cards (:needs-funding-cards state)) | |
;; api functions for getting cards that need funding | |
(def get-state (mkremote 'bio.nebula.card/get-state state error loading)) | |
(defn init [] | |
(get-state) | |
(js/setInterval (get-state) 200)) | |
;;;;;;;;;;;;;;;;;;;;;;;; views ;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(defelem label [{:keys [color name]}] | |
(h/div :class (str "ui label " color) name)) | |
(defelem card-model [card] | |
(let [{:keys [name owner image labels url desc] :as ks} card] | |
(h/div :class "item" | |
(h/div :class "image" | |
(h/img :src image)) | |
(h/div :class "content" | |
(h/div :class "header card-title" (h/text name)) | |
(h/div :class "meta" | |
(h/span :class "owner card-owner" (:name owner)) | |
(map label labels)) | |
(h/div :class "description" (h/text desc)) | |
(h/div :class "extra" | |
(h/a :class "ui right floated basic button" :href url :target "_blank" | |
"View on Trello") | |
(h/button :class "ui right floated green button fund-me" | |
"Fund Me")))))) | |
(def cards-view | |
(h/div :class "ui segment" | |
(h/div :id "cards" :class "ui divided items" | |
(loop-tpl :bindings [card needs-funding-cards] | |
(card-model @card))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment