-
-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- requires shims (marked and create-react-class) - and bhauman/devcards#156 - see https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs closes #6
- Loading branch information
Showing
9 changed files
with
1,964 additions
and
7 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/out/ | ||
/resources/public/js/compiled/ | ||
/resources/public/js/ | ||
/target/ | ||
/*-init.clj | ||
/*.log | ||
|
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,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset='utf-8'> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<title>Athens Cards</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script src="js/devcards/main.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
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,53 @@ | ||
(ns athens.devcards | ||
(:require | ||
[cljsjs.react] | ||
[cljsjs.react.dom] | ||
[reagent.core :as r :include-macros true] | ||
[devcards.core :as devcards :include-macros true :refer [defcard]])) | ||
|
||
(def bmi-data (r/atom {:height 180 :weight 80})) | ||
|
||
(defn calc-bmi [bmi-data] | ||
(let [{:keys [height weight bmi] :as data} bmi-data | ||
h (/ height 100)] | ||
(if (nil? bmi) | ||
(assoc data :bmi (/ weight (* h h))) | ||
(assoc data :weight (* bmi h h))))) | ||
|
||
(defn slider [bmi-data param value min max] | ||
[:input {:type "range" :value value :min min :max max | ||
:style {:width "100%"} | ||
:on-change (fn [e] | ||
(swap! bmi-data assoc param (.. e -target -value)) | ||
(when (not= param :bmi) | ||
(swap! bmi-data assoc :bmi nil)))}]) | ||
|
||
(defn bmi-component [bmi-data] | ||
(let [{:keys [weight height bmi]} (calc-bmi @bmi-data) | ||
[color diagnose] (cond | ||
(< bmi 18.5) ["orange" "underweight"] | ||
(< bmi 25) ["inherit" "normal"] | ||
(< bmi 30) ["orange" "overweight"] | ||
:else ["red" "obese"])] | ||
[:div | ||
[:h3 "BM calculator"] | ||
[:div | ||
"Height: " (int height) "cm" | ||
[slider bmi-data :height height 100 220]] | ||
[:div | ||
"Weight: " (int weight) "kg" | ||
[slider bmi-data :weight weight 30 150]] | ||
[:div | ||
"BMI: " (int bmi) " " | ||
[:span {:style {:color color}} diagnose] | ||
[slider bmi-data :bmi bmi 10 50]]])) | ||
|
||
(defcard bmi-calculator | ||
"*Code taken from the Reagent readme.*" | ||
(devcards/reagent bmi-component) | ||
bmi-data | ||
{:inspect-data true | ||
:frame true | ||
:history true}) | ||
|
||
(defn ^:export main [] (devcards.core/start-devcard-ui!)) |
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,7 @@ | ||
(ns cljsjs.create-react-class | ||
(:require | ||
["react" :as react] | ||
["create-react-class" :as create-react-class])) | ||
|
||
(js/goog.object.set react "createClass" create-react-class) | ||
(js/goog.exportSymbol "createReactClass" create-react-class) |
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 cljsjs.marked | ||
(:require ["marked" :as marked])) | ||
|
||
(js/goog.exportSymbol "marked" marked) |
Oops, something went wrong.