aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-11-22 16:38:14 +0000
committerAkshay <[email protected]>2020-11-22 16:38:14 +0000
commitdea97903678804c9b82039dddf7b3c461dfa514e (patch)
tree28e698078f60ffcb59cb0fb874d962f4e756a8e9
parent589a9c03eeee61b6e1bc9b6ac145c177a59258be (diff)
begin work on basic styling
-rw-r--r--elm.json6
-rw-r--r--src/Styles.elm67
-rw-r--r--src/Views.elm35
3 files changed, 103 insertions, 5 deletions
diff --git a/elm.json b/elm.json
index ba0c4ba..5b9c9c4 100644
--- a/elm.json
+++ b/elm.json
@@ -10,12 +10,14 @@
10 "elm/core": "1.0.5", 10 "elm/core": "1.0.5",
11 "elm/html": "1.0.0", 11 "elm/html": "1.0.0",
12 "elm/random": "1.0.0", 12 "elm/random": "1.0.0",
13 "elm/time": "1.0.0" 13 "elm/time": "1.0.0",
14 "rtfeldman/elm-css": "16.1.0"
14 }, 15 },
15 "indirect": { 16 "indirect": {
16 "elm/json": "1.1.3", 17 "elm/json": "1.1.3",
17 "elm/url": "1.0.0", 18 "elm/url": "1.0.0",
18 "elm/virtual-dom": "1.0.2" 19 "elm/virtual-dom": "1.0.2",
20 "rtfeldman/elm-hex": "1.0.0"
19 } 21 }
20 }, 22 },
21 "test-dependencies": { 23 "test-dependencies": {
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 @@
1module Styles exposing (..)
2
3import Css exposing (..)
4import Css.Global exposing (global, selector)
5import Html
6import Html.Styled exposing (..)
7
8
9styledButton : List (Attribute msg) -> List (Html msg) -> Html msg
10styledButton =
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
23styledInput : List (Attribute msg) -> List (Html msg) -> Html msg
24styledInput =
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
37styledListItem : List (Attribute msg) -> List (Html msg) -> Html msg
38styledListItem =
39 styled
40 li
41 [ display inline
42 ]
43
44
45styledUnorderedList : List (Attribute msg) -> List (Html msg) -> Html msg
46styledUnorderedList =
47 styled
48 ul
49 [ listStyle Css.none
50 , padding (px 0)
51 ]
52
53
54styledTextBox : List (Attribute msg) -> List (Html msg) -> Html msg
55styledTextBox =
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 @@
1module Views exposing (viewAccuracy, viewProgress, viewWpm) 1module Views exposing (viewAccuracy, viewProgress, viewWordLengthOptions, viewWpm)
2 2
3import Array exposing (..) 3import Array exposing (..)
4import Base exposing (..) 4import Base exposing (..)
5import Css exposing (..)
6import Html
7import Html.Styled exposing (..)
8import Html.Styled.Events exposing (onClick)
9import Styles exposing (styledListItem, styledUnorderedList)
5import Time exposing (Posix, toHour, toMinute, toSecond, utc) 10import Time exposing (Posix, toHour, toMinute, toSecond, utc)
6import Utils exposing (diffDuration, wordCountWith) 11import 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
45viewProgress : Int -> Int -> String 50viewProgress : Model -> String
46viewProgress soFar total = 51viewProgress 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
86viewWordLengthOptions : Html Msg
87viewWordLengthOptions =
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 )