mirror of
https://github.com/status-im/reagent.git
synced 2025-03-03 12:50:33 +00:00
Simplify page handling in demo a little
This commit is contained in:
parent
6d9bb35996
commit
d57fbc8fd6
@ -22,11 +22,9 @@
|
||||
(def index-page "index.html")
|
||||
(def news-page "news/index.html")
|
||||
|
||||
(tools/register-page index-page
|
||||
(fn [] [intro/main])
|
||||
(tools/register-page index-page [#'intro/main]
|
||||
"Reagent: Minimalistic React for ClojureScript")
|
||||
(tools/register-page news-page
|
||||
(fn [] [news/main])
|
||||
(tools/register-page news-page [#'news/main]
|
||||
"Reagent news")
|
||||
|
||||
(defn demo []
|
||||
@ -43,6 +41,6 @@
|
||||
|
||||
(defn start! [{:keys [test-results]}]
|
||||
(reset! test-results-comp test-results)
|
||||
(tools/start! {:body (fn [] [demo])
|
||||
(tools/start! {:body [#'demo]
|
||||
:css-infiles ["site/public/css/examples.css"
|
||||
"site/public/css/main.css"]}))
|
||||
|
@ -133,5 +133,5 @@
|
||||
|
||||
[demo-component {:comp geometry-example}]])]]))
|
||||
|
||||
(tools/register-page url (fn [] [main])
|
||||
(tools/register-page url [main]
|
||||
(str "Reagent 0.4.0: " title))
|
||||
|
@ -197,5 +197,5 @@
|
||||
:ncolors-choose :color-plate
|
||||
:palette :color-demo])]}]])]]))
|
||||
|
||||
(tools/register-page url (fn [] [main])
|
||||
(tools/register-page url [main]
|
||||
(str "Reagent: " title))
|
||||
|
@ -122,5 +122,5 @@
|
||||
description that corresponds to those arguments, and leave it
|
||||
to React to actually display that UI."]])]]))
|
||||
|
||||
(tools/register-page url (fn [] [main])
|
||||
(tools/register-page url [main]
|
||||
(str "Reagent: " title))
|
||||
|
@ -191,4 +191,4 @@
|
||||
will cause the entire component tree to update (by-passing the
|
||||
equality checks)."] ])]])
|
||||
|
||||
(tools/register-page url (fn [] [main]) title)
|
||||
(tools/register-page url [#'main] title)
|
||||
|
@ -85,4 +85,4 @@
|
||||
|
||||
[undo-demo-cleanup]])]]))
|
||||
|
||||
(tools/register-page url (fn [] [main]) title)
|
||||
(tools/register-page url [main] title)
|
||||
|
@ -17,10 +17,9 @@
|
||||
|
||||
;;; Configuration
|
||||
|
||||
(defonce config (atom {:page-map {"index.html"
|
||||
(fn [] [:div "Empty"])}
|
||||
(defonce config (atom {:page-map {"index.html" [:div "Empty"]}
|
||||
:page-titles {}
|
||||
:body (fn [] [:div (page-content)])
|
||||
:body [page-content]
|
||||
:site-dir "outsite/public"
|
||||
:css-infiles ["site/public/css/main.css"]
|
||||
:css-file "css/built.css"
|
||||
@ -38,7 +37,8 @@
|
||||
([pageurl comp title]
|
||||
(assert (string? pageurl)
|
||||
(str "expected string, not " pageurl))
|
||||
(assert (fn? comp))
|
||||
(assert (vector? comp)
|
||||
(str "expected vector, not " (pr-str comp)))
|
||||
(assert (or (nil? title)
|
||||
(string? title)))
|
||||
(swap! config update-in [:page-map] assoc pageurl comp)
|
||||
@ -51,7 +51,7 @@
|
||||
[props child]
|
||||
(let [p (:href props)
|
||||
f ((:page-map @config) p)]
|
||||
(assert (ifn? f) (str "couldn't resolve ppage " p))
|
||||
(assert (vector? f) (str "couldn't resolve page " p))
|
||||
(assert (string? p))
|
||||
[:a (assoc props
|
||||
:href p
|
||||
@ -66,9 +66,8 @@
|
||||
child]))
|
||||
|
||||
(defn page-content []
|
||||
[(get-in @config [:page-map @page]
|
||||
(get-in @config [:page-map "index.html"]))])
|
||||
|
||||
(get-in @config [:page-map @page]
|
||||
(get-in @config [:page-map "index.html"])))
|
||||
|
||||
|
||||
|
||||
@ -155,8 +154,8 @@
|
||||
|
||||
(defn body []
|
||||
(let [b (:body @config)]
|
||||
(assert (fn? b))
|
||||
[b]))
|
||||
(assert (vector? b) (str "body is not a vector: " b))
|
||||
b))
|
||||
|
||||
(defn danger [t s]
|
||||
[t {:dangerouslySetInnerHTML {:__html s}}])
|
||||
|
Loading…
x
Reference in New Issue
Block a user