~alcinnz/haskell-stylist

ref: 8492d01f58f80e2a4b251e9dc38cec99128e8e0d haskell-stylist/src/Stylish/Style.hs -rw-r--r-- 647 bytes
8492d01f — Adrian Cochrane Implement CSS selector interpretor. 5 years ago
                                                                                
b26bb3d1 Adrian Cochrane
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Stylish.Style(
        style,
        Style(..),
        Element(..),
        Attribute(..),
    ) where

style :: Style a => Stylist a -> Element -> a
-- Stylist consists of internal types, implements StyleSheet.

class Style s where
    initial :: s
    shorthand :: Text -> [Token] -> [(Text, [Token])]
    shorthand name value
        | Just _ <- longhand initial initial name value = (name, value)
        | otherwise = []
    longhand :: s -> s -> Text -> [Token] -> Maybe s

data Element = Element {
    prev :: Maybe Element,
    parent :: Maybe Element,
    name :: Text,
    attrs :: [Attribute]
}
data Attribute = Attr Text Text