{-# LANGUAGE OverloadedStrings #-}
{- |
Helpers and CSS styles for HTML output.
-}
module Hledger.Write.Html.Attribute (
    stylesheet,
    concatStyles,
    tableStylesheet,
    tableStyle,
    bold,
    doubleborder,
    topdoubleborder,
    bottomdoubleborder,
    alignright,
    alignleft,
    aligncenter,
    collapse,
    lpad,
    rpad,
    hpad,
    vpad,
    ) where

import qualified Data.Text as Text
import Data.Text (Text)


stylesheet :: [(Text,Text)] -> Text
stylesheet :: [(Text, Text)] -> Text
stylesheet [(Text, Text)]
elstyles =
    [Text] -> Text
Text.unlines ([Text] -> Text) -> [Text] -> Text
forall a b. (a -> b) -> a -> b
$
        Text
"" Text -> [Text] -> [Text]
forall a. a -> [a] -> [a]
: [Text
elText -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>Text
" {"Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>Text
stylesText -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>Text
"}" | (Text
el,Text
styles) <- [(Text, Text)]
elstyles]

concatStyles :: [Text] -> Text
concatStyles :: [Text] -> Text
concatStyles = Text -> [Text] -> Text
Text.intercalate Text
"; "


tableStylesheet :: Text
tableStylesheet :: Text
tableStylesheet = [(Text, Text)] -> Text
stylesheet [(Text, Text)]
tableStyle

tableStyle :: [(Text, Text)]
tableStyle :: [(Text, Text)]
tableStyle =
  [(Text
"table", Text
collapse),
   (Text
"th, td", Text
lpad),
   (Text
"th.account, td.account", Text
"padding-left:0;")]

bold, doubleborder, topdoubleborder, bottomdoubleborder :: Text
bold :: Text
bold = Text
"font-weight:bold"
doubleborder :: Text
doubleborder = Text
"double black"
topdoubleborder :: Text
topdoubleborder    = Text
"border-top:"Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>Text
doubleborder
bottomdoubleborder :: Text
bottomdoubleborder = Text
"border-bottom:"Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>Text
doubleborder

alignright, alignleft, aligncenter :: Text
alignright :: Text
alignright  = Text
"text-align:right"
alignleft :: Text
alignleft   = Text
"text-align:left"
aligncenter :: Text
aligncenter = Text
"text-align:center"

collapse :: Text
collapse :: Text
collapse = Text
"border-collapse:collapse"

lpad, rpad, hpad, vpad :: Text
lpad :: Text
lpad = Text
"padding-left:1em"
rpad :: Text
rpad = Text
"padding-right:1em"
hpad :: Text
hpad = Text
"padding-left:1em; padding-right:1em"
vpad :: Text
vpad = Text
"padding-top:1em;  padding-bottom:1em"