Skip to content

Commit 5ac7530

Browse files
committed
Split up view{Early|Later}Entries
1 parent 84eb8b1 commit 5ac7530

File tree

1 file changed

+41
-28
lines changed

1 file changed

+41
-28
lines changed

src/Picker.elm

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -117,48 +117,61 @@ subscriptions model =
117117

118118
view : Model -> Html Msg
119119
view { running, entries } =
120+
div [] <|
121+
(viewEarlyEntries running entries)
122+
++ (viewLaterEntries running entries)
123+
++ [ button
124+
[ style [ ( "width", "100%" ) ]
125+
, disabled running
126+
, onClick Start
127+
]
128+
[ text "Run" ]
129+
]
130+
131+
132+
viewEarlyEntries : Bool -> List Entry -> List (Html Msg)
133+
viewEarlyEntries running entries =
120134
let
121135
earlyEntries =
122136
entries |> List.filter (\entry -> not entry.impl.afterBlogPost)
123137

124138
laterEntries =
125139
entries |> List.filter (\entry -> entry.impl.afterBlogPost)
126140
in
127-
div [] <|
128-
[ h2 [] [ text "Before Blog Post" ]
141+
(if List.isEmpty laterEntries then
142+
[]
143+
else
144+
[ h2 [] [ text "Before Blog Post" ] ]
145+
)
146+
++ [ ul
147+
(if running then
148+
[ style [ ( "color", "#aaa" ) ] ]
149+
else
150+
[]
151+
)
152+
(List.map (viewEntry running) earlyEntries)
153+
]
154+
155+
156+
viewLaterEntries : Bool -> List Entry -> List (Html Msg)
157+
viewLaterEntries running entries =
158+
let
159+
laterEntries =
160+
entries |> List.filter (\entry -> entry.impl.afterBlogPost)
161+
in
162+
if List.isEmpty laterEntries then
163+
[]
164+
else
165+
[ hr [] []
166+
, h2 [] [ text "After Blog Post" ]
129167
, ul
130168
(if running then
131169
[ style [ ( "color", "#aaa" ) ] ]
132170
else
133171
[]
134172
)
135-
(List.map (viewEntry running) earlyEntries)
173+
(List.map (viewEntry running) laterEntries)
136174
]
137-
++ (viewLaterEntries running laterEntries)
138-
++ [ button
139-
[ style [ ( "width", "100%" ) ]
140-
, disabled running
141-
, onClick Start
142-
]
143-
[ text "Run" ]
144-
]
145-
146-
147-
viewLaterEntries : Bool -> List Entry -> List (Html Msg)
148-
viewLaterEntries running entries =
149-
if List.isEmpty entries then
150-
[]
151-
else
152-
[ hr [] []
153-
, h2 [] [ text "After Blog Post" ]
154-
, ul
155-
(if running then
156-
[ style [ ( "color", "#aaa" ) ] ]
157-
else
158-
[]
159-
)
160-
(List.map (viewEntry running) entries)
161-
]
162175

163176

164177
viewEntry : Bool -> Entry -> Html Msg

0 commit comments

Comments
 (0)