Last active
August 29, 2016 19:16
-
-
Save ciwchris/45f5945611bfdfa62b418876337d5949 to your computer and use it in GitHub Desktop.
Elm demo
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
elm-stuff/ | |
*.js |
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
module Main exposing (..) | |
import Html.App | |
import Html exposing (..) | |
import Html.Attributes exposing (type', placeholder) | |
import Html.Events exposing (onInput) | |
type alias Model = | |
{ name : String } | |
type Msg | |
= Hello String | |
update : Msg -> Model -> ( Model, Cmd Msg ) | |
update msg localModel = | |
case msg of | |
Hello name -> | |
( { name = "Hello " ++ name }, Cmd.none ) | |
view : Model -> Html Msg | |
view model = | |
div [] | |
[ input [ type' "test", placeholder "type your name", onInput Hello ] [] | |
, p [] [ text model.name ] | |
] | |
type alias Flags = | |
{ message : String } | |
init : Flags -> ( Model, Cmd Msg ) | |
init flags = | |
( { name = "Hello " ++ flags.message }, Cmd.none ) | |
main : Program Flags | |
main = | |
Html.App.programWithFlags | |
{ init = init | |
, view = view | |
, update = update | |
, subscriptions = subscriptions | |
} | |
subscriptions : Model -> Sub Msg | |
subscriptions model = | |
Sub.none |
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
{ | |
"version": "1.0.0", | |
"summary": "helpful summary of your project, less than 80 characters", | |
"repository": "https://github.com/user/project.git", | |
"license": "BSD3", | |
"source-directories": [ | |
"." | |
], | |
"exposed-modules": [], | |
"dependencies": { | |
"elm-lang/core": "4.0.5 <= v < 5.0.0", | |
"elm-lang/html": "1.1.0 <= v < 2.0.0" | |
}, | |
"elm-version": "0.17.1 <= v < 0.18.0" | |
} |
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
<html> | |
<head> | |
</head> | |
<body> | |
<script src="elm.js"></script> | |
<script> | |
Elm.Main.fullscreen({message: "world"}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment