~alcinnz/Mondrian

ref: a3455462990dddadf8213c9e45a5fe5ec6bee475 Mondrian/lib/Graphics/Rendering/Rect/CSS.hs -rw-r--r-- 869 bytes
a3455462 — Adrian Cochrane Parse background-colour CSS property. 1 year, 4 months ago
                                                                                
a3455462 Adrian Cochrane
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
module Graphics.Rendering.Rect.CSS(CSSRect(..)) where

import Stylist (PropertyParser(..))
import Graphics.Rendering.Rect.CSS.Colour (ColourPallet(foreground))
import Graphics.Rendering.Rect.CSS.Background (Backgrounds(..))

data CSSRect = CSSRect { colours :: ColourPallet, backgrounds :: Backgrounds }
colour = foreground . colours

instance PropertyParser CSSRect where
    temp = CSSRect { colours = temp, backgrounds = temp }
    inherit CSSRect {..} = CSSRect { 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 (colours parent) (colours self) key value =
            Just self { colours = ret }
        | otherwise = Nothing