2014-01-17 14:22:49 +00:00
|
|
|
(ns reagentdemo.common
|
|
|
|
(:require [reagent.core :as reagent :refer [atom]]
|
2014-12-07 20:07:32 +00:00
|
|
|
[reagent.debug :refer-macros [dbg println]]))
|
2014-01-17 14:22:49 +00:00
|
|
|
|
2014-04-01 17:50:28 +00:00
|
|
|
(defn demo-component []
|
2014-01-18 10:43:56 +00:00
|
|
|
(let [showing (atom true)]
|
2014-04-01 17:50:28 +00:00
|
|
|
(fn [{:keys [comp src complete no-heading]}]
|
2014-01-17 14:22:49 +00:00
|
|
|
[:div
|
|
|
|
(when comp
|
2014-01-30 21:29:42 +00:00
|
|
|
[:div.demo-example.clearfix
|
2014-01-17 14:22:49 +00:00
|
|
|
[:a.demo-example-hide {:on-click (fn [e]
|
|
|
|
(.preventDefault e)
|
2014-01-27 12:37:59 +00:00
|
|
|
(swap! showing not)
|
|
|
|
false)}
|
2014-01-17 14:22:49 +00:00
|
|
|
(if @showing "hide" "show")]
|
2014-02-22 16:24:22 +00:00
|
|
|
(when-not no-heading
|
|
|
|
[:h3.demo-heading "Example "])
|
2014-01-17 14:22:49 +00:00
|
|
|
(when @showing
|
|
|
|
(if-not complete
|
|
|
|
[:div.simple-demo [comp]]
|
|
|
|
[comp]))])
|
2014-02-15 16:29:37 +00:00
|
|
|
(if @showing
|
|
|
|
(if src
|
|
|
|
[:div.demo-source.clearfix
|
2014-02-22 16:24:22 +00:00
|
|
|
(when-not no-heading
|
|
|
|
[:h3.demo-heading "Source"])
|
2014-02-15 16:29:37 +00:00
|
|
|
src]
|
|
|
|
[:div.clearfix]))])))
|