diff options
author | Akshay <[email protected]> | 2020-11-22 16:38:14 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2020-11-22 16:38:14 +0000 |
commit | dea97903678804c9b82039dddf7b3c461dfa514e (patch) | |
tree | 28e698078f60ffcb59cb0fb874d962f4e756a8e9 /src | |
parent | 589a9c03eeee61b6e1bc9b6ac145c177a59258be (diff) |
begin work on basic styling
Diffstat (limited to 'src')
-rw-r--r-- | src/Styles.elm | 67 | ||||
-rw-r--r-- | src/Views.elm | 35 |
2 files changed, 99 insertions, 3 deletions
diff --git a/src/Styles.elm b/src/Styles.elm new file mode 100644 index 0000000..57c124b --- /dev/null +++ b/src/Styles.elm | |||
@@ -0,0 +1,67 @@ | |||
1 | module Styles exposing (..) | ||
2 | |||
3 | import Css exposing (..) | ||
4 | import Css.Global exposing (global, selector) | ||
5 | import Html | ||
6 | import Html.Styled exposing (..) | ||
7 | |||
8 | |||
9 | styledButton : List (Attribute msg) -> List (Html msg) -> Html msg | ||
10 | styledButton = | ||
11 | styled | ||
12 | button | ||
13 | [ margin (px 12) | ||
14 | , color (hex "#000") | ||
15 | , fontFamily monospace | ||
16 | , backgroundColor (hex "#ddd") | ||
17 | , border (px 0) | ||
18 | , borderRadius (px 4) | ||
19 | , padding (px 12) | ||
20 | ] | ||
21 | |||
22 | |||
23 | styledInput : List (Attribute msg) -> List (Html msg) -> Html msg | ||
24 | styledInput = | ||
25 | styled | ||
26 | input | ||
27 | [ margin (px 12) | ||
28 | , color (hex "#000") | ||
29 | , fontFamily monospace | ||
30 | , backgroundColor (hex "#eee") | ||
31 | , border (px 0) | ||
32 | , borderRadius (px 4) | ||
33 | , padding (px 12) | ||
34 | ] | ||
35 | |||
36 | |||
37 | styledListItem : List (Attribute msg) -> List (Html msg) -> Html msg | ||
38 | styledListItem = | ||
39 | styled | ||
40 | li | ||
41 | [ display inline | ||
42 | ] | ||
43 | |||
44 | |||
45 | styledUnorderedList : List (Attribute msg) -> List (Html msg) -> Html msg | ||
46 | styledUnorderedList = | ||
47 | styled | ||
48 | ul | ||
49 | [ listStyle Css.none | ||
50 | , padding (px 0) | ||
51 | ] | ||
52 | |||
53 | |||
54 | styledTextBox : List (Attribute msg) -> List (Html msg) -> Html msg | ||
55 | styledTextBox = | ||
56 | styled | ||
57 | div | ||
58 | [ margin (px 12) | ||
59 | , color (hex "#000") | ||
60 | , fontFamily monospace | ||
61 | , backgroundColor (hex "#eee") | ||
62 | , border (px 0) | ||
63 | , borderRadius (px 4) | ||
64 | , padding (px 12) | ||
65 | , width (px 500) | ||
66 | , display inlineBlock | ||
67 | ] | ||
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 | ) | ||