Skip to content

Instantly share code, notes, and snippets.

@HusseinMorsy
Created July 30, 2016 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HusseinMorsy/5de5c5af66d2b054f57142a7ff57ed62 to your computer and use it in GitHub Desktop.
Save HusseinMorsy/5de5c5af66d2b054f57142a7ff57ed62 to your computer and use it in GitHub Desktop.
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