From 703bad4fad198d670272fd71d84912ba4dfda264 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Fri, 31 Jul 2020 21:47:54 +0200 Subject: Capitalization --- client/src/Client.elm | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'client/src') diff --git a/client/src/Client.elm b/client/src/Client.elm index aebeb8f..5170e64 100644 --- a/client/src/Client.elm +++ b/client/src/Client.elm @@ -132,16 +132,24 @@ blackCardContent cards (Messages.BlackCard idx) = blackCardBlanks : Cards -> BlackCard -> Int blackCardBlanks cards c = List.length (blackCardContent cards c) - 1 +capitalizeFirst : List String -> List String +capitalizeFirst l = case l of + x :: xs -> (String.toUpper (String.left 1 x) ++ String.dropLeft 1 x) :: xs + _ -> l + blackCard : Cards -> BlackCard -> List WhiteCard -> Html a blackCard cards black whites = - let blank mbWhite = Html.span - [Html.Attributes.class "blank"] <| - case mbWhite of - Nothing -> [] - Just w -> [Html.text <| whiteCardContent cards w] in + let blackParts = blackCardContent cards black + whiteParts = List.map (whiteCardContent cards) whites |> + case blackParts of + "" :: _ -> capitalizeFirst + _ -> identity + blank txt = Html.span + [Html.Attributes.class "blank"] + [Html.text txt] in Html.div [Html.Attributes.class "card", Html.Attributes.class "black"] <| - intersperseWith (List.map (\c -> blank (Just c)) whites) (blank Nothing) <| - List.map Html.text <| blackCardContent cards black + intersperseWith (List.map blank whiteParts) (blank "") <| + List.map Html.text blackParts whiteCardContent : Cards -> WhiteCard -> String whiteCardContent cards (Messages.WhiteCard idx) = -- cgit v1.2.3