2014-01-17 15:22:49 +01:00
|
|
|
(ns reagentdemo.common
|
2015-07-31 15:13:27 +02:00
|
|
|
(:require [reagent.core :as r]
|
2014-12-07 21:07:32 +01:00
|
|
|
[reagent.debug :refer-macros [dbg println]]))
|
2014-01-17 15:22:49 +01:00
|
|
|
|
2015-10-07 13:55:16 +02: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 17:24:22 +01:00
|
|
|
(when-not no-heading
|
2015-10-07 13:55:16 +02:00
|
|
|
[:h3.demo-heading "Source"])
|
|
|
|
src]
|
|
|
|
[:div.clearfix]))]))
|