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