Skip to content

Instantly share code, notes, and snippets.

@ccapndave
Created April 12, 2016 15:08
Show Gist options
  • Save ccapndave/88a7078b0fba7c4c8e7c4552707113cd to your computer and use it in GitHub Desktop.
Save ccapndave/88a7078b0fba7c4c8e7c4552707113cd to your computer and use it in GitHub Desktop.
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