diff --git a/public/style.css b/public/style.css index 5ffe62f..c069eb4 100644 --- a/public/style.css +++ b/public/style.css @@ -15,3 +15,14 @@ i.fas, i.fab { display: inline-block; margin-right: 0.3rem; } + +@media (min-width: 768px) { + .card-body p { + height: 2.5rem; + } +} + +@media (max-width: 768px) { + .card-body p { + } +} diff --git a/src/Pages/App_String.elm b/src/Pages/App_String.elm index d82243b..969c542 100644 --- a/src/Pages/App_String.elm +++ b/src/Pages/App_String.elm @@ -40,6 +40,7 @@ type alias App = , slug : String , default_branch : String , website : Maybe String + , description : Maybe String } type alias Model = @@ -293,6 +294,7 @@ appDecoder = |> andMap (Decode.succeed "") |> andMap (Decode.field "default_branch" Decode.string) |> andMap (Decode.maybe (Decode.field "website" Decode.string)) + |> andMap (Decode.maybe (Decode.field "description" Decode.string)) appListDecoder : Decode.Decoder (List App) diff --git a/src/Pages/Top.elm b/src/Pages/Top.elm index 5366a63..197a93b 100644 --- a/src/Pages/Top.elm +++ b/src/Pages/Top.elm @@ -4,7 +4,9 @@ import Html exposing (Html, button, div, h2, h5, img, text, ul, li, a, p, span, import Html.Attributes exposing (src, style, class, alt, href) import Html.Events exposing (onClick) import Http +import Maybe exposing (withDefault) import Json.Decode as Decode +import Json.Decode.Extra as Decode exposing (andMap) import Spa.Generated.Route as Route import Spa.Document exposing (Document) import Spa.Page as Page exposing (Page) @@ -35,7 +37,9 @@ type alias App = , icon : Maybe String , status : Int , slug : String + , default_branch : String , website : Maybe String + , description : Maybe String } @@ -99,20 +103,6 @@ body model = [ viewApps model ] -appScore : App -> Int -appScore app = - case app.status of - 1 -> - 1 - 2 -> - 2 - 3 -> - 3 - 4 -> - 4 - _ -> - 5 - viewStatusBadge : App -> Html Msg viewStatusBadge app = let @@ -173,6 +163,7 @@ viewApp app = , div [ class "card-body" ] [ h5 [ class "card-title" ] [ a [ href app_href ] [ text app.name ] ] + , p [] [ text (withDefault "" app.description) ] , repository_link , website_link , a [ class "card-link", href app_href ] @@ -205,7 +196,7 @@ viewApps model = div [] [ div [ class "row" ] (List.map viewApp (apps |> List.sortWith - (by appScore ASC + (by .status ASC |> andThen .name ASC)) ) ] @@ -230,16 +221,17 @@ featuresDecoder = appDecoder : Decode.Decoder App appDecoder = - Decode.map8 - App - (Decode.field "name" Decode.string) - (Decode.field "category" Decode.string) - (Decode.maybe (Decode.field "repository" Decode.string)) - (Decode.succeed Nothing) - (Decode.maybe (Decode.field "icon" Decode.string)) - (Decode.at [ "features" ] featuresDecoder) - (Decode.succeed "") - (Decode.maybe (Decode.field "website" Decode.string)) + Decode.succeed App + |> andMap (Decode.field "name" Decode.string) + |> andMap (Decode.field "category" Decode.string) + |> andMap (Decode.maybe (Decode.field "repository" Decode.string)) + |> andMap (Decode.succeed Nothing) + |> andMap (Decode.maybe (Decode.field "icon" Decode.string)) + |> andMap (Decode.at [ "features" ] featuresDecoder) + |> andMap (Decode.succeed "") + |> andMap (Decode.field "default_branch" Decode.string) + |> andMap (Decode.maybe (Decode.field "website" Decode.string)) + |> andMap (Decode.maybe (Decode.field "description" Decode.string)) appListDecoder : Decode.Decoder (List App)