-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.elm
65 lines (46 loc) · 1012 Bytes
/
Main.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
module Main exposing (..)
import Html exposing (Html, div, text)
import Table exposing (table, Cell, Row)
type Msg
= Msg
type alias Fruit =
{ id : Int
, name : String
, colour : String
, available : Bool
}
idCell : Fruit -> Html Msg
idCell fruit =
Html.div [] [ text (toString fruit.id) ]
nameCell : Fruit -> Html Msg
nameCell fruit =
Html.div [] [ text fruit.name ]
colourCell : Fruit -> Html Msg
colourCell fruit =
Html.div [] [ text fruit.colour ]
availableCell : Cell Fruit Msg
availableCell fruit =
Html.div []
[ text
(if fruit.available then
"Yes"
else
" No"
)
]
fruitRow : Row Fruit Msg
fruitRow =
[ idCell
, nameCell
, colourCell
, availableCell
]
fruits : List Fruit
fruits =
[ Fruit 1 "Apple" "Red" True
, Fruit 2 "Banana" "Yellow" False
, Fruit 3 "Orange" "Orange" True
]
main : Html Msg
main =
table fruitRow fruits