reagent/demo/reagentdemo/common.cljs

29 lines
954 B
Plaintext
Raw Normal View History

2014-01-17 15:22:49 +01:00
(ns reagentdemo.common
(:require [reagent.core :as r]
[reagent.debug :refer-macros [dbg println]]))
2014-01-17 15:22:49 +01:00
(defn demo-component []
(let [showing (r/atom true)]
(fn [{:keys [comp src complete no-heading]}]
2014-01-17 15:22:49 +01:00
[:div
(when comp
2014-01-30 22:29:42 +01:00
[:div.demo-example.clearfix
2014-01-17 15:22:49 +01:00
[:a.demo-example-hide {:on-click (fn [e]
(.preventDefault e)
(swap! showing not)
false)}
2014-01-17 15:22:49 +01:00
(if @showing "hide" "show")]
2014-02-22 17:24:22 +01:00
(when-not no-heading
[:h3.demo-heading "Example "])
2014-01-17 15:22:49 +01:00
(when @showing
(if-not complete
[:div.simple-demo [comp]]
[comp]))])
2014-02-15 17:29:37 +01:00
(if @showing
(if src
[:div.demo-source.clearfix
2014-02-22 17:24:22 +01:00
(when-not no-heading
[:h3.demo-heading "Source"])
2014-02-15 17:29:37 +01:00
src]
[:div.clearfix]))])))