{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
module Graphics.Rendering.Rect.CSS(RectStyle(..), colour) where
import Stylist (PropertyParser(..))
import Graphics.Rendering.Rect.CSS.Colour (ColourPallet(foreground))
import Graphics.Rendering.Rect.CSS.Background (Backgrounds(..))
data RectStyle = RectStyle { colours :: ColourPallet, backgrounds :: Backgrounds }
colour = foreground . colours
instance PropertyParser RectStyle where
temp = RectStyle { colours = temp, backgrounds = temp }
inherit RectStyle {..} = RectStyle {
colours = inherit colours, backgrounds = temp
}
shorthand self key value
| Just _ <- longhand self self key value = [(key, value)]
| otherwise = []
longhand parent self key value
| Just ret <- longhand (backgrounds parent) { pallet = colours parent }
(backgrounds self) { pallet = colours self } key value =
Just self { backgrounds = ret }
| Just ret <- longhand (colours parent) (colours self) key value =
Just self { colours = ret }
| otherwise = Nothing