Created
July 30, 2016 10:34
-
-
Save HusseinMorsy/5de5c5af66d2b054f57142a7ff57ed62 to your computer and use it in GitHub Desktop.
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 exposing (..) | |
import Html.Attributes exposing (style) | |
type alias Model = | |
{ title : String, items : List Item } | |
type alias Item = | |
{ name : String, done : Bool } | |
model : Model | |
model = | |
{ title = "Shoppting List", items = [ { name = "Apples", done = False }, { name = "Tomatos", done = True }, { name = "Banana", done = False } ] } | |
main : Html a | |
main = | |
view model | |
view : Model -> Html a | |
view model = | |
div [] | |
[ viewTitle model.title | |
, viewList model.items | |
] | |
viewTitle : String -> Html a | |
viewTitle title = | |
h1 [] [ text title ] | |
viewList : List Item -> Html a | |
viewList list = | |
ul [] (List.map viewItem list) | |
viewItem : Item -> Html a | |
viewItem item = | |
if item.done then | |
li [ style [ ( "text-decoration", "line-through" ) ] ] [ text item.name ] | |
else | |
li [] [ text item.name ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment