2014-01-02 13:04:30 +00:00
|
|
|
(ns demo
|
2014-01-17 10:12:11 +00:00
|
|
|
(:require [reagent.core :as reagent :refer [atom]]
|
2014-01-06 11:46:58 +00:00
|
|
|
[clojure.string :as string]
|
2014-01-17 11:35:40 +00:00
|
|
|
[reagentdemo.page :as rpage]
|
|
|
|
[reagentdemo.news :as news]
|
2014-01-18 10:31:43 +00:00
|
|
|
[reagentdemo.intro :as intro]
|
2014-01-17 14:22:49 +00:00
|
|
|
[reagentdemo.common :as common :refer [demo-component]]
|
2014-01-17 10:12:11 +00:00
|
|
|
[reagent.debug :refer-macros [dbg println]]))
|
2014-01-02 13:04:30 +00:00
|
|
|
|
2014-01-17 11:35:40 +00:00
|
|
|
(def page rpage/page)
|
|
|
|
|
|
|
|
(defn link [props children]
|
|
|
|
(apply vector :a (assoc props
|
|
|
|
:on-click (if rpage/history
|
|
|
|
(fn [e]
|
|
|
|
(.preventDefault e)
|
|
|
|
(reset! page (:href props)))
|
|
|
|
identity))
|
|
|
|
children))
|
|
|
|
|
2014-01-07 16:01:28 +00:00
|
|
|
(defn github-badge []
|
|
|
|
[:a.github-badge
|
2014-01-17 10:12:11 +00:00
|
|
|
{:href "https://github.com/holmsand/reagent"}
|
2014-01-07 16:01:28 +00:00
|
|
|
[:img {:style {:position "absolute" :top 0 :left 0 :border 0}
|
|
|
|
:src "https://s3.amazonaws.com/github/ribbons/forkme_left_orange_ff7600.png"
|
|
|
|
:alt "Fork me on GitHub"}]])
|
|
|
|
|
2014-01-02 13:04:30 +00:00
|
|
|
(defn demo []
|
2014-01-06 18:16:53 +00:00
|
|
|
[:div
|
2014-01-17 11:35:40 +00:00
|
|
|
[:div
|
|
|
|
[:ul
|
|
|
|
[:li [link {:href "news.html"} "News"]]
|
|
|
|
[:li [link {:href "index.html"} "Intro"]]]]
|
|
|
|
(case (dbg @page)
|
2014-01-18 10:31:43 +00:00
|
|
|
"index.html" [intro/main]
|
2014-01-17 11:35:40 +00:00
|
|
|
"news.html" [news/main]
|
2014-01-18 10:31:43 +00:00
|
|
|
[intro/main])
|
2014-01-09 13:37:11 +00:00
|
|
|
[github-badge]])
|
2014-01-05 10:16:01 +00:00
|
|
|
|
|
|
|
(defn ^:export mountdemo []
|
2014-01-17 10:12:11 +00:00
|
|
|
(reagent/render-component [demo] (.-body js/document)))
|
2014-01-05 10:16:01 +00:00
|
|
|
|
|
|
|
(defn ^:export genpage []
|
2014-01-17 10:12:11 +00:00
|
|
|
(reagent/render-component-to-string [demo]))
|