{-# LANGUAGE OverloadedStrings #-} module Graphics.Rendering.Rect.CSS.Background (Backgrounds(..)) where import Stylist (PropertyParser(..), parseUnorderedShorthand) import Graphics.Rendering.Rect.CSS.Colour (ColourPallet, parseColour) import Data.Colour (AlphaColour, transparent) data Backgrounds = Backgrounds { pallet :: ColourPallet, background :: AlphaColour Double } instance PropertyParser Backgrounds where temp = Backgrounds { pallet = temp, background = transparent } inherit _ = temp priority _ = [] longhand _ self@Backgrounds{ pallet = c } "background-color" toks | Just ([], val) <- parseColour c toks = Just self { background = val } longhand _ _ _ _ = Nothing shorthand self "background" toks = parseUnorderedShorthand self [ "background-color" ] toks shorthand self key val | Just _ <- longhand self self key val = [(key, val)] | otherwise = []