reagent/demo/reagentdemo/common.cljs

28 lines
905 B
Plaintext
Raw Permalink Normal View History

2014-01-17 14:22:49 +00:00
(ns reagentdemo.common
(:require [reagent.core :as r]
[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]))]))