Show app description on listing pages
continuous-integration/drone/push Build is failing Details

Closes #3
This commit is contained in:
3wc 2021-04-25 15:51:39 +02:00
parent 33ddb9e390
commit 31d590c3fe
3 changed files with 30 additions and 25 deletions

View File

@ -15,3 +15,14 @@ i.fas, i.fab {
display: inline-block; display: inline-block;
margin-right: 0.3rem; margin-right: 0.3rem;
} }
@media (min-width: 768px) {
.card-body p {
height: 2.5rem;
}
}
@media (max-width: 768px) {
.card-body p {
}
}

View File

@ -40,6 +40,7 @@ type alias App =
, slug : String , slug : String
, default_branch : String , default_branch : String
, website : Maybe String , website : Maybe String
, description : Maybe String
} }
type alias Model = type alias Model =
@ -293,6 +294,7 @@ appDecoder =
|> andMap (Decode.succeed "") |> andMap (Decode.succeed "")
|> andMap (Decode.field "default_branch" Decode.string) |> andMap (Decode.field "default_branch" Decode.string)
|> andMap (Decode.maybe (Decode.field "website" Decode.string)) |> andMap (Decode.maybe (Decode.field "website" Decode.string))
|> andMap (Decode.maybe (Decode.field "description" Decode.string))
appListDecoder : Decode.Decoder (List App) appListDecoder : Decode.Decoder (List App)

View File

@ -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.Attributes exposing (src, style, class, alt, href)
import Html.Events exposing (onClick) import Html.Events exposing (onClick)
import Http import Http
import Maybe exposing (withDefault)
import Json.Decode as Decode import Json.Decode as Decode
import Json.Decode.Extra as Decode exposing (andMap)
import Spa.Generated.Route as Route import Spa.Generated.Route as Route
import Spa.Document exposing (Document) import Spa.Document exposing (Document)
import Spa.Page as Page exposing (Page) import Spa.Page as Page exposing (Page)
@ -35,7 +37,9 @@ type alias App =
, icon : Maybe String , icon : Maybe String
, status : Int , status : Int
, slug : String , slug : String
, default_branch : String
, website : Maybe String , website : Maybe String
, description : Maybe String
} }
@ -99,20 +103,6 @@ body model =
[ viewApps 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 -> Html Msg
viewStatusBadge app = viewStatusBadge app =
let let
@ -173,6 +163,7 @@ viewApp app =
, div [ class "card-body" ] , div [ class "card-body" ]
[ h5 [ class "card-title" ] [ h5 [ class "card-title" ]
[ a [ href app_href ] [ text app.name ] ] [ a [ href app_href ] [ text app.name ] ]
, p [] [ text (withDefault "" app.description) ]
, repository_link , repository_link
, website_link , website_link
, a [ class "card-link", href app_href ] , a [ class "card-link", href app_href ]
@ -205,7 +196,7 @@ viewApps model =
div [] div []
[ div [ class "row" ] [ div [ class "row" ]
(List.map viewApp (apps |> List.sortWith (List.map viewApp (apps |> List.sortWith
(by appScore ASC (by .status ASC
|> andThen .name ASC)) |> andThen .name ASC))
) )
] ]
@ -230,16 +221,17 @@ featuresDecoder =
appDecoder : Decode.Decoder App appDecoder : Decode.Decoder App
appDecoder = appDecoder =
Decode.map8 Decode.succeed App
App |> andMap (Decode.field "name" Decode.string)
(Decode.field "name" Decode.string) |> andMap (Decode.field "category" Decode.string)
(Decode.field "category" Decode.string) |> andMap (Decode.maybe (Decode.field "repository" Decode.string))
(Decode.maybe (Decode.field "repository" Decode.string)) |> andMap (Decode.succeed Nothing)
(Decode.succeed Nothing) |> andMap (Decode.maybe (Decode.field "icon" Decode.string))
(Decode.maybe (Decode.field "icon" Decode.string)) |> andMap (Decode.at [ "features" ] featuresDecoder)
(Decode.at [ "features" ] featuresDecoder) |> andMap (Decode.succeed "")
(Decode.succeed "") |> andMap (Decode.field "default_branch" Decode.string)
(Decode.maybe (Decode.field "website" Decode.string)) |> andMap (Decode.maybe (Decode.field "website" Decode.string))
|> andMap (Decode.maybe (Decode.field "description" Decode.string))
appListDecoder : Decode.Decoder (List App) appListDecoder : Decode.Decoder (List App)