Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (37 sloc) 1.44 KB
(:require [keechma.ui-component :as ui]
[ :refer [render-address render-hours]]
[keechma.toolbox.ui :refer [sub> route>]]))
(defn render-header [r]
{:style {:background-image (str "url(/" (get-in r [:images :banner]) ")")}}
[:h2 (:name r)]
(render-address (:address r))
(defn render-content [ctx r current-route]
[:h3 "The best food this side of the Mississippi"]
[:img {:src (get-in r [:images :owner])}]
(str "Description for " (:name r))]
[:a.btn {:href (ui/url ctx (merge current-route {:action "order"}))}
(str "Order from " (:name r))]]])
(defn render [ctx]
(let [current-route-sub (ui/current-route ctx)
current-restaurant-sub (ui/subscription ctx :current-restaurant)]
(fn []
(let [r (sub> ctx :current-restaurant)
r-meta (sub> ctx :current-restaurant-meta)
current-route (route> ctx)]
(if (= :pending (:status r-meta))
(render-header r)
(render-content ctx r current-route)])))))
(def component (ui/constructor
{:renderer render
:subscription-deps [:current-restaurant