From d8b2192240aa9498ffb7af53bce8eaa47522b8e0 Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Sun, 26 Mar 2023 18:47:47 -0400 Subject: [PATCH] Reinstate score badges, fix sorting --- public/style.css | 1 + src/Pages/App_String.elm | 18 ++++++++---------- src/Pages/Top.elm | 21 +++++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/public/style.css b/public/style.css index c0b0b5b..e6078af 100644 --- a/public/style.css +++ b/public/style.css @@ -46,6 +46,7 @@ i.fas, i.fab { .app-category { background-color: var(--light-blue); color: var(--white); + margin-left: 0.5rem; } .card-description { diff --git a/src/Pages/App_String.elm b/src/Pages/App_String.elm index 3b77d4d..71cddd3 100644 --- a/src/Pages/App_String.elm +++ b/src/Pages/App_String.elm @@ -39,7 +39,7 @@ type alias App = , repository : Maybe String , versions : Maybe (List String) , icon : Maybe String - , status : String + , status : Int , slug : String , default_branch : String , website : Maybe String @@ -192,23 +192,23 @@ viewStatusBadge app = let status_class = case app.status of - "1" -> + 5 -> "badge-success" - "2" -> + 4 -> "badge-info" - "3" -> + 3 -> "badge-warning" - "4" -> + 2 -> "badge-danger" _ -> "badge-dark" in span [ class ("card-link badge " ++ status_class) ] - [ text ("Score: " ++ app.status) ] + [ text ("Score: " ++ String.fromInt app.status) ] viewApp : App -> String -> Html Msg @@ -309,12 +309,10 @@ loadREADME app = } -featuresDecoder : Decode.Decoder String featuresDecoder = - -- get features.status if it's there Decode.oneOf - [ Decode.at [ "status" ] Decode.string - , Decode.succeed "" + [ Decode.at [ "status" ] Decode.int + , Decode.succeed 5 ] diff --git a/src/Pages/Top.elm b/src/Pages/Top.elm index cbe9507..1552549 100644 --- a/src/Pages/Top.elm +++ b/src/Pages/Top.elm @@ -114,7 +114,7 @@ filterAppsScore apps score = case score of Just s -> List.filter (\app -> - app.status <= s + app.status >= s ) apps Nothing -> apps @@ -231,23 +231,23 @@ viewStatusBadge app = let status_class = case app.status of - 1 -> + 5 -> "badge-success" - 2 -> + 4 -> "badge-info" 3 -> "badge-warning" - 4 -> + 2 -> "badge-danger" _ -> "badge-dark" in span [ class ("card-link badge " ++ status_class) ] - [ text ("Score: " ++ String.fromInt app.status) ] + [ text ("Status: " ++ String.fromInt app.status) ] viewApp : App -> Html Msg @@ -303,7 +303,7 @@ viewApp app = , p [ class "card-description" ] [ text (ellipsis 100 (withDefault "" app.description)) ] ] , div [ class "footer" ] - [ span [ class "badge app-category" ] [ text app.category ]] + [ viewStatusBadge app, span [ class "badge app-category" ] [ text app.category ]] ] ] @@ -349,10 +349,11 @@ viewApps model = , label [ for "level" ] [ text " and show only items that have at least " ] , select [ class "search-dropdown", id "level", onInput FilterScore ] [ option [ ] [ text "any" ] - , option [ value "1" ] [ text "1 (production)" ] - , option [ value "2" ] [ text "2 (beta)" ] + , option [ value "5" ] [ text "5 (production)" ] + , option [ value "4" ] [ text "4 (beta)" ] , option [ value "3" ] [ text "3 (alpha)" ] - , option [ value "4" ] [ text "4 (pre-alpha)" ] + , option [ value "2" ] [ text "2 (pre-alpha)" ] + , option [ value "1" ] [ text "1 (work-in-progress)" ] ] , text "builds " ] @@ -364,7 +365,7 @@ viewApps model = (List.map viewApp (model.results |> List.sortWith - (by .status ASC + (by .status DESC |> andThen (String.toLower << .name) ASC ) )