--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
; -- SOME CONCRETE COMPONENTS
; a component taking a String as a model
(defn hello-component [name]
[:p "Hello, " name "!"])
; a stateless component using another component
(defn say-hello []
[hello-component "world"])
; a component taking a ratom (it's a signal in elm speak) as a model
(defn reactive-hello-component [name]
[:p "Hello, " @name "!"])
; a component taking list of Strings as a model
(defn list-hellos [names]
(for [n names]
[hello-component (str "hello " n)]))
; -- GENERIC WRAPPING COMPONENT
; a wrapping components. take list of components as a parameter and wraps them in pages
(defn wrap-components [components]
(fn []
[:div {:class "components-wrapped-in-pages-so-we-can-swipe-them"}
(for [c components]
[:div {:class "page"} c])]))
; -- MAIN VIEW GLUING ALL TOGETHER
(defn main-view []
(let [reactive-name (ratom "initial-name")
input-state (ratom "")]
[:div {:class "some-boilerplate"}
; the two lines below are not following re-frame pattern. There are there just to express I have the state which changes.
[:input {:onchange (fn [value] (!reset input-state value))}] ; react to inout changes and pass the value to model (in re-frame instead of directly updating the model we would send a signal (as in elm) and have subscription react to the signal but for simplicity I ommit the patern)
[:button {:onclick #(!reset reactive-name @input-state)}] ; copy the states on button click
[:span {:class "here-come-generic-swipe-able-pages-wrapping-any-components"}
; here is the usage of the wrapping container
(wrap-components [
say-hello ; stateless component
#(hello-component "some-fancy-name") ; #(...) is lambda in clojure, here we close over some static state
#(reactive-hello-component reactive-name) ; #(...) here we close over some reactive state, so the component re-renders when the model (state) changes
#(list-hellos ["a" "b" "c"]) ; component taking list as a state (model)
])]]))
; -- MOUNT VIEW TO DOM
; bind the main-view to DOM and start observing deltas to render if needed
(defn ^:export run []
(r/render [main-view] (js/document.body)))
You received this message because you are subscribed to a topic in the Google Groups "Elm Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elm-discuss/sJl8iB_3EXQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elm-discuss...@googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "Elm Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elm-discuss/sJl8iB_3EXQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elm-discuss...@googlegroups.com.
"dependencies": {
"elm-lang/core": "4.0.0 <= v < 5.0.0",
"elm-lang/html": "1.0.0 <= v < 2.0.0",
"elm-lang/window": "1.0.0 <= v < 2.0.0",
"debois/elm-dom": "1.2.0 <= v < 2.0.0",
"debois/elm-parts": "2.0.0 <= v < 3.0.0"
},I cannot find module 'Material'
Module 'Main' is trying to import it