mirror of https://github.com/status-im/reagent.git
Include examples and tests in demo page
This commit is contained in:
parent
4099c00838
commit
c159984024
|
@ -14,7 +14,8 @@
|
|||
<h1>This will become an example when compiled</h1>
|
||||
<script type="text/javascript" src="../target/cljs-client.js"></script>
|
||||
<script type="text/javascript">
|
||||
runtests.run();
|
||||
//runtests.run();
|
||||
demo.mountdemo();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
(defn src-for [defs]
|
||||
[:pre (-> defs src-for-names demoutil/syntaxify)])
|
||||
|
||||
(defn demo-component [{:keys [comp defs]}]
|
||||
(defn demo-component [{:keys [comp defs src]}]
|
||||
[:div
|
||||
(when comp
|
||||
[:div.demo-example
|
||||
|
@ -38,7 +38,9 @@
|
|||
[comp]])
|
||||
[:div.demo-source
|
||||
[:h3.demo-heading "Source"]
|
||||
(src-for defs)]])
|
||||
(if src
|
||||
(demoutil/syntaxify src)
|
||||
(src-for defs))]])
|
||||
|
||||
(defn simple-component []
|
||||
[:div
|
||||
|
@ -232,14 +234,37 @@
|
|||
:defs [:ns :calc-bmi :bmi-data :set-bmi :slider
|
||||
:bmi-component]}]])
|
||||
|
||||
(defn test-results []
|
||||
[:div
|
||||
[:h2 "Test results"]
|
||||
[runtests/test-output]])
|
||||
|
||||
(defn complete-simple-demo []
|
||||
[:div
|
||||
[:h2 "Another demo"]
|
||||
[demo-component {:comp simpleexample/simple-example
|
||||
:src (get-source "simpleexample.cljs")}]])
|
||||
|
||||
(defn todomvc-demo []
|
||||
[:div
|
||||
[:h2 "Todomvc"]
|
||||
[demo-component {:comp todomvc/todo-app
|
||||
:src (get-source "todomvc.cljs")}]])
|
||||
|
||||
(defn demo []
|
||||
[:div.cloact-demo
|
||||
[:h1 "This will become a demo"]
|
||||
[intro]
|
||||
[managing-state]
|
||||
[essential-api]
|
||||
[bmi-demo]
|
||||
[:p "WIP"]])
|
||||
[:div
|
||||
[:div.test-output-mini
|
||||
[runtests/test-output-mini]]
|
||||
[:div.cloact-demo
|
||||
[:h1 "This will become a demo"]
|
||||
[intro]
|
||||
[managing-state]
|
||||
[essential-api]
|
||||
[bmi-demo]
|
||||
[test-results]
|
||||
[complete-simple-demo]
|
||||
[todomvc-demo]
|
||||
[:p "WIP"]]])
|
||||
|
||||
(defn ^:export mountdemo []
|
||||
(cloact/render-component [demo] (.-body js/document)))
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
:refer (is deftest with-test run-tests testing)]
|
||||
[cloact.debug :refer [dbg println]])
|
||||
(:require [cemerick.cljs.test :as t]
|
||||
[cloact.core :as cloact :refer [atom]]
|
||||
[demo :as demo]
|
||||
[todomvc :as todomvc]))
|
||||
[cloact.core :as cloact :refer [atom]]))
|
||||
|
||||
(defn ^:export console-print [x]
|
||||
(when (not= x "\n")
|
||||
|
@ -34,23 +32,11 @@
|
|||
" assertions.")]
|
||||
[:p (:fail res) " failues, " (:error res) " errors."]])]))
|
||||
|
||||
(defn examples []
|
||||
(let [p {:style {:color "#aaa"}}]
|
||||
[:div.runtests
|
||||
[demo/demo]
|
||||
[:div
|
||||
[:h2 p "Test results:"]
|
||||
[test-output]]
|
||||
[:div
|
||||
[:h2 p "Simple example:"]
|
||||
[simpleexample/simple-example]]
|
||||
[:div
|
||||
[:h2 p "Todomvc:"]
|
||||
[todomvc/todo-app]]]))
|
||||
(defn test-output-mini []
|
||||
(let [res @test-results]
|
||||
(if res
|
||||
(if (zero? (+ (:fail res) (:error res)))
|
||||
[:div "Tests ok"]
|
||||
[test-output])
|
||||
[:div "."])))
|
||||
|
||||
(defn test-main []
|
||||
[examples])
|
||||
|
||||
(defn ^:export run []
|
||||
(cloact/render-component [test-main]
|
||||
(.-body js/document)))
|
||||
|
|
Loading…
Reference in New Issue