-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bring back macro & provide support for Rum, Reagent and Om
- Loading branch information
Showing
12 changed files
with
217 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/resources/public/js/compiled/** | ||
figwheel_server.log | ||
pom.xml | ||
*jar | ||
/lib/ | ||
/classes/ | ||
/out/ | ||
/target/ | ||
.lein-deps-sum | ||
.lein-repl-history | ||
.lein-plugins/ | ||
.repl | ||
.nrepl-port |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
(defproject example "0.1.0-SNAPSHOT" | ||
:description "FIXME: write this!" | ||
:url "http://example.com/FIXME" | ||
:license {:name "Eclipse Public License" | ||
:url "http://www.eclipse.org/legal/epl-v10.html"} | ||
|
||
:min-lein-version "2.7.1" | ||
|
||
:dependencies [[org.clojure/clojure "1.8.0"] | ||
[org.clojure/clojurescript "1.9.671"] | ||
[rum "0.10.8"] | ||
[reagent "0.7.0"] | ||
[org.omcljs/om "1.0.0-beta1"]] | ||
|
||
:plugins [[lein-cljsbuild "1.1.6" :exclusions [[org.clojure/clojure]]]] | ||
|
||
:source-paths ["src"] | ||
|
||
:cljsbuild {:builds | ||
[{:id "dev" | ||
:source-paths ["src" "../src"] | ||
:compiler {:main example.core | ||
:asset-path "js/compiled/out" | ||
:output-to "resources/public/js/compiled/example.js" | ||
:output-dir "resources/public/js/compiled/out" | ||
:source-map-timestamp true | ||
:preloads [devtools.preload]}} | ||
|
||
{:id "min" | ||
:source-paths ["src" "../src"] | ||
:compiler {:output-to "resources/public/js/compiled/example.js" | ||
:main example.core | ||
:optimizations :advanced | ||
:pretty-print false}}]} | ||
|
||
:profiles {:dev {:dependencies [[binaryage/devtools "0.9.2"] | ||
[com.cemerick/piggieback "0.2.1"]] | ||
:source-paths ["src"] | ||
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]} | ||
:clean-targets ^{:protect false} ["resources/public/js/compiled" | ||
:target-path]}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
<body> | ||
<div id="rum-app"></div> | ||
<div id="reagent-app"></div> | ||
<div id="om-app"></div> | ||
<script src="js/compiled/example.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
(ns example.core | ||
(:require [rum.core :as rum] | ||
[reagent.core :as r] | ||
[om.dom :as dom] | ||
[om.next :as om :refer [defui]] | ||
[goog.dom :as gdom] | ||
[cljss.core :refer [defstyles]] | ||
[cljss.rum :as rumss] | ||
[cljss.reagent :as rss] | ||
[cljss.om :as omss])) | ||
|
||
(defstyles wrapper [width] | ||
{:padding "8px 16px" | ||
:margin "0 auto" | ||
:text-align "center" | ||
:font "normal 18px sans-serif" | ||
:width width}) | ||
|
||
;; Rum | ||
(rumss/defstyled RumH1 :h1 | ||
{:font-size "32px" | ||
:color "#242424" | ||
:margin-top :v-margin | ||
:margin-bottom :v-margin}) | ||
|
||
(rum/defc RumApp [] | ||
[:div {:class (wrapper "600px")} | ||
(RumH1 {:v-margin "8px"} "Clojure Style Sheets for Rum")]) | ||
|
||
(rum/mount (RumApp) (gdom/getElement "rum-app")) | ||
|
||
|
||
;; Reagent | ||
(rss/defstyled ReagentH1 :h1 | ||
{:font-size "32px" | ||
:color "#242424" | ||
:margin-top :v-margin | ||
:margin-bottom :v-margin}) | ||
|
||
(defn ReagentApp [] | ||
[:div {:class (wrapper "600px")} | ||
(ReagentH1 {:v-margin "8px"} "Clojure Style Sheets for Reagent")]) | ||
|
||
(r/render [ReagentApp] (gdom/getElement "reagent-app")) | ||
|
||
|
||
;; Om | ||
(omss/defstyled OmH1 :h1 | ||
{:font-size "32px" | ||
:color "#242424" | ||
:margin-top :v-margin | ||
:margin-bottom :v-margin}) | ||
|
||
(defui OmApp | ||
Object | ||
(render [this] | ||
(dom/div #js {:className (wrapper "600px")} | ||
(OmH1 {:v-margin "8px"} "Clojure Style Sheets for Om")))) | ||
|
||
(.render js/ReactDOM ((om/factory OmApp)) (gdom/getElement "om-app")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(ns cljss.om | ||
(:require [cljss.core :refer [->styled]])) | ||
|
||
(defmacro defstyled [var tag styles] | ||
(let [tag# (name tag) | ||
[id# static# vals# attrs#] (->styled styles) | ||
create-element# `#(apply js/React.createElement ~tag# (cljs.core/clj->js %1) %2)] | ||
`(def ~var | ||
(cljss.rum/styled ~id# ~static# ~vals# ~attrs# ~create-element#)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(ns cljss.om | ||
(:require [cljss.core :refer [make-styled]])) | ||
|
||
(make-styled) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(ns cljss.reagent | ||
(:require [cljss.core :refer [->styled]])) | ||
|
||
(defmacro defstyled [var tag styles] | ||
(let [tag# tag | ||
[id# static# vals# attrs#] (->styled styles) | ||
create-element# `#(apply vector ~tag# %1 %2)] | ||
`(def ~var | ||
(cljss.rum/styled ~id# ~static# ~vals# ~attrs# ~create-element#)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(ns cljss.reagent | ||
(:require [cljss.core :refer [make-styled]])) | ||
|
||
(make-styled) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(ns cljss.rum | ||
(:require [cljss.core :refer [->styled]])) | ||
|
||
(defmacro defstyled [var tag styles] | ||
(let [tag# (name tag) | ||
[id# static# vals# attrs#] (->styled styles) | ||
create-element# `#(apply js/React.createElement ~tag# (cljs.core/clj->js %1) %2)] | ||
`(def ~var | ||
(cljss.rum/styled ~id# ~static# ~vals# ~attrs# ~create-element#)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(ns cljss.rum | ||
(:require [cljss.core :refer [make-styled]])) | ||
|
||
(make-styled) |