    {-# LANGUAGE OverloadedStrings #-}
    {- |
    Common definitions used by both Html.Blaze and Html.Lucid.
    -}

    module Hledger.Write.Html.HtmlCommon (
        Lines(..),
        borderStyles,
        ) where

    import Data.Text (Text)

    import           Hledger.Write.Spreadsheet (Cell(..))
    import Hledger.Write.Spreadsheet qualified as Spr

    borderStyles :: Lines border => Cell border text -> [Text]
    borderStyles :: forall border text. Lines border => Cell border text -> [Text]
    borderStyles Cell border text
    cell =
        let border :: Text -> (Border border -> border) -> [Text]
    border Text
    field Border border -> border
    access =
                (Text -> Text) -> [Text] -> [Text]
    forall a b. (a -> b) -> [a] -> [b]
    map (Text
    fieldText -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>) ([Text] -> [Text]) -> [Text] -> [Text]
    forall a b. (a -> b) -> a -> b
    $ border -> [Text]
    forall border. Lines border => border -> [Text]
    borderLines (border -> [Text]) -> border -> [Text]
    forall a b. (a -> b) -> a -> b
    $ Border border -> border
    access (Border border -> border) -> Border border -> border
    forall a b. (a -> b) -> a -> b
    $ Cell border text -> Border border
    forall border text. Cell border text -> Border border
    cellBorder Cell border text
    cell in
        let leftBorder :: [Text]
    leftBorder   = Text -> (Border border -> border) -> [Text]
    forall {border}.
    Lines border =>
    Text -> (Border border -> border) -> [Text]
    border Text
    "border-left:"   Border border -> border
    forall lines. Border lines -> lines
    Spr.borderLeft   in
        let rightBorder :: [Text]
    rightBorder  = Text -> (Border border -> border) -> [Text]
    forall {border}.
    Lines border =>
    Text -> (Border border -> border) -> [Text]
    border Text
    "border-right:"  Border border -> border
    forall lines. Border lines -> lines
    Spr.borderRight  in
        let topBorder :: [Text]
    topBorder    = Text -> (Border border -> border) -> [Text]
    forall {border}.
    Lines border =>
    Text -> (Border border -> border) -> [Text]
    border Text
    "border-top:"    Border border -> border
    forall lines. Border lines -> lines
    Spr.borderTop    in
        let bottomBorder :: [Text]
    bottomBorder = Text -> (Border border -> border) -> [Text]
    forall {border}.
    Lines border =>
    Text -> (Border border -> border) -> [Text]
    border Text
    "border-bottom:" Border border -> border
    forall lines. Border lines -> lines
    Spr.borderBottom in
        [Text]
    leftBorder[Text] -> [Text] -> [Text]
    forall a. [a] -> [a] -> [a]
    ++[Text]
    rightBorder[Text] -> [Text] -> [Text]
    forall a. [a] -> [a] -> [a]
    ++[Text]
    topBorder[Text] -> [Text] -> [Text]
    forall a. [a] -> [a] -> [a]
    ++[Text]
    bottomBorder

    class (Spr.Lines border) => Lines border where
        borderLines :: border -> [Text]

    instance Lines () where
        borderLines :: () -> [Text]
    borderLines () = []

    instance Lines Spr.NumLines where
        borderLines :: NumLines -> [Text]
    borderLines NumLines
    prop =
            case NumLines
    prop of
                NumLines
    Spr.NoLine -> []
                NumLines
    Spr.SingleLine -> [Text
    "black"]
                NumLines
    Spr.DoubleLine -> [Text
    "double black"]