diff options
Diffstat (limited to 'src/Views.elm')
-rw-r--r-- | src/Views.elm | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/Views.elm b/src/Views.elm index c5cc159..5e2dbcb 100644 --- a/src/Views.elm +++ b/src/Views.elm | |||
@@ -1,7 +1,12 @@ | |||
1 | module Views exposing (viewAccuracy, viewProgress, viewWpm) | 1 | module Views exposing (viewAccuracy, viewProgress, viewWordLengthOptions, viewWpm) |
2 | 2 | ||
3 | import Array exposing (..) | 3 | import Array exposing (..) |
4 | import Base exposing (..) | 4 | import Base exposing (..) |
5 | import Css exposing (..) | ||
6 | import Html | ||
7 | import Html.Styled exposing (..) | ||
8 | import Html.Styled.Events exposing (onClick) | ||
9 | import Styles exposing (styledListItem, styledUnorderedList) | ||
5 | import Time exposing (Posix, toHour, toMinute, toSecond, utc) | 10 | import Time exposing (Posix, toHour, toMinute, toSecond, utc) |
6 | import Utils exposing (diffDuration, wordCountWith) | 11 | import Utils exposing (diffDuration, wordCountWith) |
7 | 12 | ||
@@ -42,8 +47,15 @@ viewWpm model = | |||
42 | Maybe.withDefault "XX" wpm | 47 | Maybe.withDefault "XX" wpm |
43 | 48 | ||
44 | 49 | ||
45 | viewProgress : Int -> Int -> String | 50 | viewProgress : Model -> String |
46 | viewProgress soFar total = | 51 | viewProgress model = |
52 | let | ||
53 | soFar = | ||
54 | model.currentWord + 1 | ||
55 | |||
56 | total = | ||
57 | model.config.length | ||
58 | in | ||
47 | String.fromInt soFar ++ "/" ++ String.fromInt total | 59 | String.fromInt soFar ++ "/" ++ String.fromInt total |
48 | 60 | ||
49 | 61 | ||
@@ -69,3 +81,20 @@ viewAccuracy words = | |||
69 | 81 | ||
70 | Just a -> | 82 | Just a -> |
71 | String.fromInt <| truncate a | 83 | String.fromInt <| truncate a |
84 | |||
85 | |||
86 | viewWordLengthOptions : Html Msg | ||
87 | viewWordLengthOptions = | ||
88 | let | ||
89 | wl = | ||
90 | [ 10, 25, 50, 100 ] | ||
91 | in | ||
92 | styledUnorderedList [] | ||
93 | (List.map | ||
94 | (\len -> | ||
95 | styledListItem | ||
96 | [ onClick (Base.WordLengthChanged len) ] | ||
97 | [ text <| String.fromInt len ] | ||
98 | ) | ||
99 | wl | ||
100 | ) | ||