reagent/demo/reagentdemo/common.cljs

29 lines
972 B
Plaintext
Raw Normal View History

2014-01-17 14:22:49 +00:00
(ns reagentdemo.common
(:require [reagent.core :as reagent :refer [atom]]
[reagent.debug :refer-macros [dbg println]]))
2014-01-17 14:22:49 +00:00
(defn demo-component []
2014-01-18 10:43:56 +00:00
(let [showing (atom true)]
(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)
(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]))])))