2014-01-17 14:22:49 +00:00
|
|
|
(ns reagentdemo.common
|
2015-07-31 13:13:27 +00:00
|
|
|
(:require [reagent.core :as r]
|
2014-12-07 20:07:32 +00:00
|
|
|
[reagent.debug :refer-macros [dbg println]]))
|
2014-01-17 14:22:49 +00:00
|
|
|
|
2015-10-07 11:55:16 +00:00
|
|
|
(defn demo-component [{:keys [comp src complete no-heading]}]
|
|
|
|
(r/with-let [showing (r/atom true)]
|
|
|
|
[:div
|
|
|
|
(when comp
|
|
|
|
[:div.demo-example.clearfix
|
|
|
|
[:a.demo-example-hide {:on-click (fn [e]
|
|
|
|
(.preventDefault e)
|
|
|
|
(swap! showing not)
|
|
|
|
nil)}
|
|
|
|
(if @showing "hide" "show")]
|
|
|
|
(when-not no-heading
|
|
|
|
[:h3.demo-heading "Example "])
|
|
|
|
(when @showing
|
|
|
|
(if-not complete
|
|
|
|
[:div.simple-demo [comp]]
|
|
|
|
[comp]))])
|
|
|
|
(if @showing
|
|
|
|
(if src
|
|
|
|
[:div.demo-source.clearfix
|
2014-02-22 16:24:22 +00:00
|
|
|
(when-not no-heading
|
2015-10-07 11:55:16 +00:00
|
|
|
[:h3.demo-heading "Source"])
|
|
|
|
src]
|
|
|
|
[:div.clearfix]))]))
|