Created
April 12, 2016 15:08
-
-
Save ccapndave/88a7078b0fba7c4c8e7c4552707113cd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
instructionsHeader : Signal.Address Action -> Html | |
instructionsHeader address = | |
header | |
[] | |
[ button | |
[ onClick address StartTheTest | |
] | |
[ text "Start the test" ] | |
] | |
placementHeader : Signal.Address Action -> Html | |
placementHeader address = | |
header | |
[] | |
[ button | |
[ onClick address Enter | |
] | |
[ text "Enter" ] | |
] | |
testHeader : Context -> Signal.Address Action -> Model -> Html | |
testHeader context address model = | |
let | |
button' = | |
if (hasNextExercise model context.menu) then | |
button | |
[ onClick address ExerciseNext | |
] | |
[ text "Next exercise" ] | |
else | |
button | |
[ onClick address FinishTest | |
] | |
[ text "Finish test" ] | |
in | |
header | |
[] | |
[ button' | |
] | |
view : Context -> Signal.Address Action -> Model -> Html | |
view context address model = | |
let | |
-- Choose the header based on the exercise type | |
headerHtml = | |
case (model.exercise |> Maybe.map exerciseToExerciseType) of | |
Just Instructions -> | |
instructionsHeader address | |
Just Placement -> | |
placementHeader address | |
Just Test -> | |
testHeader context address model | |
Nothing -> | |
div [] [] | |
in | |
div | |
[] | |
[ headerHtml | |
, model.remainingTime |> Maybe.map (Time.inSeconds >> floor >> toString >> text) |> Maybe.withDefault (div [] []) | |
, ExerciseRenderer.view (Signal.forwardTo address ExerciseRendererAction) model.exerciseRendererModel | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment