Prettified with Bootstrap

This commit is contained in:
Anthony Cicchetti 2019-09-29 16:07:12 -04:00
parent c6f5df7b31
commit 85b0ec9e56
2 changed files with 37 additions and 26 deletions

View file

@ -11,9 +11,12 @@ install:
debug: debug:
elm-live src/Leaderboard.elm --open -- --debug --output=leaderboard.js elm-live src/Leaderboard.elm --open -- --debug --output=leaderboard.js
build_release: build_release: format
elm make src/Leaderboard.elm --optimize --output=leaderboard.opt.js elm make src/Leaderboard.elm --optimize --output=leaderboard.opt.js
uglifyjs leaderboard.opt.js --compress "pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe" | uglifyjs --mangle --output=leaderboard.js uglifyjs leaderboard.opt.js --compress "pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe" | uglifyjs --mangle --output=leaderboard.js
deploy: build_release deploy: build_release
rsync index.html leaderboard.js anthonycicchetti.com:/var/www/crossword.anthonycicchetti.com/public rsync index.html leaderboard.js anthonycicchetti.com:/var/www/crossword.anthonycicchetti.com/public
format:
elm-format --yes src

View file

@ -1,5 +1,11 @@
module Leaderboard exposing (main) module Leaderboard exposing (main)
import Bootstrap.Form.Input as Input
import Bootstrap.Form.InputGroup as InputGroup
import Bootstrap.Grid as Grid
import Bootstrap.Grid.Col as Col
import Bootstrap.Grid.Row as Row
import Bootstrap.ListGroup as ListGroup
import Browser import Browser
import Date import Date
import Debug exposing (toString) import Debug exposing (toString)
@ -84,7 +90,6 @@ update msg model =
( { model | entries = List.sortBy .score newEntries }, Cmd.none ) ( { model | entries = List.sortBy .score newEntries }, Cmd.none )
NewEntries (Err err) -> NewEntries (Err err) ->
-- ( { model | alertMessage = Just (toString err) }, Cmd.none)
( model, Cmd.none ) ( model, Cmd.none )
@ -109,38 +114,41 @@ getScores newDate =
--- VIEW --- VIEW
viewDate : String -> Html Msg viewEntry : Entry -> ListGroup.Item Msg
viewDate date = viewEntry entry =
h2 [] ListGroup.li []
[ text date ] [ div [] [ text entry.name ]
, div [] [ text entry.score ]
]
viewEntryList : List Entry -> Html Msg viewEntryList : List Entry -> Html Msg
viewEntryList entries = viewEntryList entries =
ul [] div [ class "container-fluid" ]
(List.map [ ListGroup.ul
(\entry -> (List.map viewEntry entries)
li [] ]
[ div [] [ text entry.name ]
, div [] [ text entry.score ]
] viewDatePicker : Model -> Grid.Column Msg
viewDatePicker model =
Grid.col []
[ InputGroup.config
(InputGroup.date
[ Input.placeholder model.date
, Input.onInput NewDate
, Input.value model.date
]
) )
entries |> InputGroup.predecessors [ InputGroup.span [] [ text "Date: " ] ]
) |> InputGroup.view
]
view : Model -> Html Msg view : Model -> Html Msg
view model = view model =
div [] Grid.containerFluid []
[ div [] [ Grid.row [] [ viewDatePicker model ]
[ input
[ type_ "date"
, placeholder model.date
, onInput NewDate
, value model.date
]
[]
]
, viewEntryList model.entries , viewEntryList model.entries
, text (Maybe.withDefault "" model.alertMessage) , text (Maybe.withDefault "" model.alertMessage)
] ]