-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotes.elm
More file actions
95 lines (62 loc) · 1.91 KB
/
Copy pathNotes.elm
File metadata and controls
95 lines (62 loc) · 1.91 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
module Notes exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
main =
Html.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}
-- MODEL
type alias Note =
{ id : Int, body : String, timestamp : Float }
type alias Model =
{ notes : List Note }
init : ( Model, Cmd Msg )
init =
( { notes =
[ { id = 1, body = "First note...", timestamp = 0 }
, { id = 2, body = "Second note...", timestamp = 0 }
, { id = 3, body = "Third note...", timestamp = 0 }
]
}
, Cmd.none
)
-- UPDATE
type Msg
= NoOp
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
( model, Cmd.none )
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
-- VIEW
view : Model -> Html Msg
view model =
div [ id "app" ]
[ div [ class "toolbar" ]
[ button [ class "toolbar-button" ] [ text "New" ]
, button [ class "toolbar-button" ] [ text "Delete" ]
, input [ class "toolbar-search", type_ "text", placeholder "Search..." ] []
]
, div [ class "note-container" ]
[ viewNoteSelectors model
, div [ class "note-editor" ]
[ p [ class "note-editor-info" ] [ text "Timestamp here..." ]
, textarea [ class "note-editor-input" ] [ text "First note..." ]
]
]
]
viewNoteSelectors : Model -> Html Msg
viewNoteSelectors model =
div [ class "note-selectors" ]
(model.notes |> List.map (\note -> viewNoteSelector note))
viewNoteSelector : Note -> Html Msg
viewNoteSelector note =
div [ class "note-selector" ]
[ p [ class "note-selector-title" ] [ text note.body ]
, p [ class "note-selector-timestamp" ] [ note.timestamp |> toString |> text ]
]