Adv build material-ui example & infer externs

This commit is contained in:
Juho Teperi 2019-09-12 11:24:09 +03:00
parent bb8bcc414e
commit b6a380f69e
2 changed files with 27 additions and 7 deletions

View File

@ -28,7 +28,20 @@
:output-dir "target/cljsbuild/client/public/js/out" :output-dir "target/cljsbuild/client/public/js/out"
:output-to "target/cljsbuild/client/public/js/main.js" :output-to "target/cljsbuild/client/public/js/main.js"
:asset-path "js/out" :asset-path "js/out"
:npm-deps false}} :npm-deps false
:infer-externs true}}
:adv
{:source-paths ["src"]
:compiler {:parallel-build true
:source-map "target/cljsbuild/adv/public/js/main.js.map"
:optimizations :advanced
:main "example.core"
:output-dir "target/cljsbuild/adv/public/js/out"
:output-to "target/cljsbuild/adv/public/js/main.js"
:asset-path "js/out"
:npm-deps false
:infer-externs true}}
;; FIXME: Doesn't work due to Closure bug with scoped npm packages ;; FIXME: Doesn't work due to Closure bug with scoped npm packages
:client-npm :client-npm

View File

@ -8,6 +8,13 @@
[goog.object :as gobj] [goog.object :as gobj]
[reagent.impl.template :as rtpl])) [reagent.impl.template :as rtpl]))
(set! *warn-on-infer* true)
(defn event-value
[^js/Event e]
(let [^js/HTMLInputElement el (.-target e)]
(.-value el)))
;; TextField cursor fix: ;; TextField cursor fix:
(def ^:private input-component (def ^:private input-component
@ -51,9 +58,9 @@
(def custom-theme (def custom-theme
(createMuiTheme (createMuiTheme
#js {:palette #js {:primary #js {:main (gobj/get (.-red mui-colors) 100)}}})) #js {:palette #js {:primary #js {:main (gobj/get (.-red ^js/Mui.Colors mui-colors) 100)}}}))
(defn custom-styles [theme] (defn custom-styles [^js/Mui.Theme theme]
#js {:button #js {:margin (.spacing theme 1)} #js {:button #js {:margin (.spacing theme 1)}
:textField #js {:width 200 :textField #js {:width 200
:marginLeft (.spacing theme 1) :marginLeft (.spacing theme 1)
@ -97,7 +104,7 @@
:helper-text "Helper text" :helper-text "Helper text"
:class (.-textField classes) :class (.-textField classes)
:on-change (fn [e] :on-change (fn [e]
(reset! text-state (.. e -target -value))) (reset! text-state (event-value e)))
:inputRef #(js/console.log "input-ref" %)}]] :inputRef #(js/console.log "input-ref" %)}]]
[:> mui/Grid {:item true} [:> mui/Grid {:item true}
@ -107,8 +114,8 @@
:placeholder "Placeholder" :placeholder "Placeholder"
:helper-text "Helper text" :helper-text "Helper text"
:class (.-textField classes) :class (.-textField classes)
:on-change (fn [e] :on-change (fn [^js/DomEvent e]
(reset! text-state (.. e -target -value))) (reset! text-state (event-value e)))
:multiline true :multiline true
;; TODO: Autosize textarea is broken. ;; TODO: Autosize textarea is broken.
:rows 10}]] :rows 10}]]
@ -121,7 +128,7 @@
:helper-text "Helper text" :helper-text "Helper text"
:class (.-textField classes) :class (.-textField classes)
:on-change (fn [e] :on-change (fn [e]
(reset! text-state (.. e -target -value))) (reset! text-state (event-value e)))
:select true} :select true}
[:> mui/MenuItem [:> mui/MenuItem
{:value 1} {:value 1}