module Hydra.TUI.Style where

import Brick (
  AttrMap,
  AttrName,
  attrMap,
  attrName,
  fg,
  on,
 )
import Brick.Forms (focusedFormInputAttr, invalidFormInputAttr)
import Brick.Widgets.Border (borderAttr)
import Brick.Widgets.List (listSelectedAttr)
import Graphics.Vty (
  black,
  blue,
  bold,
  brightBlue,
  brightMagenta,
  brightRed,
  brightWhite,
  brightYellow,
  cyan,
  defAttr,
  green,
  italic,
  magenta,
  red,
  white,
  withForeColor,
  withStyle,
 )
import Hydra.TUI.Logging.Types (Severity (..))

severityToAttr :: Severity -> AttrName
severityToAttr :: Severity -> AttrName
severityToAttr = \case
  Severity
Success -> AttrName
positive
  Severity
Info -> AttrName
infoA
  Severity
Error -> AttrName
negative

infoA :: AttrName
infoA :: AttrName
infoA = String -> AttrName
attrName String
"info"

positive :: AttrName
positive :: AttrName
positive = String -> AttrName
attrName String
"positive"

negative :: AttrName
negative :: AttrName
negative = String -> AttrName
attrName String
"negative"

neutral :: AttrName
neutral :: AttrName
neutral = String -> AttrName
attrName String
"neutral"

own :: AttrName
own :: AttrName
own = String -> AttrName
attrName String
"own"

activeTabA :: AttrName
activeTabA :: AttrName
activeTabA = String -> AttrName
attrName String
"activeTab"

keyA :: AttrName
keyA :: AttrName
keyA = String -> AttrName
attrName String
"key"

pendingA :: AttrName
pendingA :: AttrName
pendingA = String -> AttrName
attrName String
"pending"

headStateA :: AttrName
headStateA :: AttrName
headStateA = String -> AttrName
attrName String
"headState"

actionDescA :: AttrName
actionDescA :: AttrName
actionDescA = String -> AttrName
attrName String
"actionDesc"

sectionHeaderA :: AttrName
sectionHeaderA :: AttrName
sectionHeaderA = String -> AttrName
attrName String
"sectionHeader"

-- | Dark theme — optimised for dark terminal backgrounds. We deliberately use
-- the bright ANSI palette for foreground colours so that text stays legible
-- on a true-black background, where the dim variants (e.g. plain @blue@ or
-- @brightBlack@) blend into the background.
darkStyle :: s -> AttrMap
darkStyle :: forall s. s -> AttrMap
darkStyle s
_ =
  Attr -> [(AttrName, Attr)] -> AttrMap
attrMap
    Attr
defAttr
    [ (AttrName
infoA, Color -> Attr
fg Color
brightBlue)
    , (AttrName
negative, Color -> Attr
fg Color
brightRed)
    , (AttrName
positive, Color -> Attr
fg Color
green)
    , (AttrName
neutral, Color -> Attr
fg Color
brightWhite)
    , (AttrName
own, Color -> Attr
fg Color
brightYellow)
    , (AttrName
activeTabA, Color
brightWhite Color -> Color -> Attr
`on` Color
blue)
    , (AttrName
keyA, Attr -> Style -> Attr
withStyle (Attr -> Style -> Attr
withStyle Attr
defAttr Style
bold) Style
italic)
    , (AttrName
pendingA, Color -> Attr
fg Color
brightMagenta)
    , (AttrName
headStateA, Attr -> Style -> Attr
withStyle (Color -> Attr
fg Color
brightMagenta) Style
bold)
    , (AttrName
actionDescA, Attr -> Style -> Attr
withStyle Attr
defAttr Style
italic)
    , (AttrName
sectionHeaderA, Color
brightWhite Color -> Color -> Attr
`on` Color
blue)
    , (AttrName
listSelectedAttr, Color
brightWhite Color -> Color -> Attr
`on` Color
blue)
    , (AttrName
borderAttr, Color -> Attr
fg Color
white)
    , (AttrName
focusedFormInputAttr, Color -> Attr
fg Color
brightBlue)
    , (AttrName
invalidFormInputAttr, Color -> Attr
fg Color
brightRed)
    ]

-- | Light theme — optimised for light terminal backgrounds.
lightStyle :: s -> AttrMap
lightStyle :: forall s. s -> AttrMap
lightStyle s
_ =
  Attr -> [(AttrName, Attr)] -> AttrMap
attrMap
    (Attr -> Color -> Attr
withForeColor Attr
defAttr Color
black)
    [ (AttrName
infoA, Color -> Attr
fg Color
blue)
    , (AttrName
negative, Color -> Attr
fg Color
red)
    , (AttrName
positive, Color -> Attr
fg Color
green)
    , (AttrName
neutral, Color -> Attr
fg Color
black)
    , (AttrName
own, Color -> Attr
fg Color
cyan)
    , (AttrName
activeTabA, Color
brightWhite Color -> Color -> Attr
`on` Color
blue)
    , (AttrName
keyA, Attr -> Style -> Attr
withStyle (Attr -> Style -> Attr
withStyle Attr
defAttr Style
bold) Style
italic)
    , (AttrName
pendingA, Color -> Attr
fg Color
magenta)
    , (AttrName
headStateA, Attr -> Style -> Attr
withStyle (Color -> Attr
fg Color
blue) Style
bold)
    , (AttrName
actionDescA, Attr -> Style -> Attr
withStyle Attr
defAttr Style
italic)
    , (AttrName
sectionHeaderA, Color
brightWhite Color -> Color -> Attr
`on` Color
blue)
    , (AttrName
listSelectedAttr, Color
brightWhite Color -> Color -> Attr
`on` Color
blue)
    , (AttrName
borderAttr, Color -> Attr
fg Color
black)
    , (AttrName
focusedFormInputAttr, Color -> Attr
fg Color
blue)
    , (AttrName
invalidFormInputAttr, Color -> Attr
fg Color
red)
    ]