Skip to content

Instantly share code, notes, and snippets.

Created August 31, 2017 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/55e5a3b2096b89142f0beffd7536940c to your computer and use it in GitHub Desktop.
Save anonymous/55e5a3b2096b89142f0beffd7536940c to your computer and use it in GitHub Desktop.
Untitled
{
"version": "1.0.0",
"summary": "Tell the world about your project!",
"repository": "https://github.com/user/project.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "5.1.1 <= v < 5.1.1",
"elm-lang/html": "2.0.0 <= v < 2.0.0"
},
"elm-version": "0.18.0 <= v < 0.19.0"
}
<html>
<head>
<style>
html {
background: #F7F7F7;
color: red;
}
</style>
</head>
<body>
<script>
var app = Elm.Main.fullscreen()
</script>
</body>
</html>
module Main exposing (..)
import Html exposing (Html, text, input, div)
import Html.Attributes as Attr exposing (type_, step)
import Html.Events exposing (onInput)
dateInput : List (Html.Attribute msg) -> List (Html msg) -> Html msg
dateInput attr children =
input (attr ++ [ type_ "date", step "1", Attr.min "2017-01-01" ]) children
timeInput : List (Html.Attribute msg) -> List (Html msg) -> Html msg
timeInput attr children =
input (attr ++ [ type_ "time", step "5", Attr.min "00:00" ]) children
type Msg
= DateUpdated String
| TimeUpdated String
type alias Model =
{ date : String
, time : String
}
model : Model
model =
{ date = ""
, time = ""
}
main =
Html.beginnerProgram
{ model = model
, view = view
, update = update
}
update msg model =
case msg of
DateUpdated to ->
{ model | date = to }
TimeUpdated to ->
{ model | time = to }
view model =
div []
[ dateInput [ onInput DateUpdated ] []
, div [] [ text model.date ]
, timeInput [ onInput TimeUpdated ] []
, div [] [ text model.time ]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment