stylist-traits-0.1.2.0: Traits, datatypes, & parsers for Haskell Stylist
Safe HaskellNone
LanguageHaskell2010

Stylist

Synopsis

Documentation

cssPriorityAgent :: StyleSheet s => s -> s Source #

Set the priority for a CSS stylesheet being parsed.

cssPriorityUser :: StyleSheet s => s -> s Source #

Set the priority for a CSS stylesheet being parsed.

cssPriorityAuthor :: StyleSheet s => s -> s Source #

Set the priority for a CSS stylesheet being parsed.

class PropertyParser a where Source #

Defines how to parse CSS properties into an output "style" format.

Minimal complete definition

temp, longhand

Methods

temp :: a Source #

Default styles.

inherit :: a -> a Source #

Creates a style inherited from a parent style.

shorthand :: a -> Text -> [Token] -> [(Text, [Token])] Source #

Expand a shorthand property into longhand properties.

longhand :: a -> a -> Text -> [Token] -> Maybe a Source #

Mutates self to store the given CSS property, if it's syntax is valid. longhand parent self name value

getVars :: a -> Props Source #

Retrieve stored variables, optional.

setVars :: Props -> a -> a Source #

Save variable values, optional.

pseudoEl :: a -> Text -> (a -> Maybe a -> a) -> a Source #

Mutates self to store the given pseudoelement styles, passing a callback so you can alter the parent & (for interactive pseudoclasses) base styles.

class StyleSheet s where Source #

Describes how to store, and to some extent parse, CSS stylesheets. These methods are used to construct the results from parse, etc.

Minimal complete definition

addRule

Methods

setPriority :: Int -> s -> s Source #

Sets the stylesheet priority (useragent vs user vs author), optional. Favor setPriorities for richer API.

setPriorities :: [Int] -> s -> s Source #

Sets the multi-layered stylesheet priority (for the sake of @layer rules), optional.

addRule :: s -> StyleRule -> s Source #

Stores a parsed selector+properties rule.

addAtRule :: s -> Text -> [Token] -> (s, [Token]) Source #

Stores and parses an identified at-rule.

Instances

Instances details
StyleSheet () Source #

In case an indirect caller doesn't actually want to use Haskell Stylist.

Instance details

Defined in Stylist.Parse

Methods

setPriority :: Int -> () -> () Source #

setPriorities :: [Int] -> () -> () Source #

addRule :: () -> StyleRule -> () Source #

addAtRule :: () -> Text -> [Token] -> ((), [Token]) Source #

StyleSheet TrivialStyleSheet Source # 
Instance details

Defined in Stylist.Parse

data TrivialStyleSheet Source #

Gathers StyleRules into a list, mainly for testing.

type Props = [(Text, [Token])] Source #

"key: value;" entries to be parsed into an output type.

data Element Source #

An inversely-linked tree of elements, to apply CSS selectors to.

Constructors

ElementNode 

Fields

data Attribute Source #

A key-value attribute.

Constructors

Attribute Text Text String 

Instances

Instances details
Eq Attribute Source # 
Instance details

Defined in Stylist

Methods

(==) :: Attribute -> Attribute -> Bool

(/=) :: Attribute -> Attribute -> Bool

Ord Attribute Source # 
Instance details

Defined in Stylist

Methods

compare :: Attribute -> Attribute -> Ordering

(<) :: Attribute -> Attribute -> Bool

(<=) :: Attribute -> Attribute -> Bool

(>) :: Attribute -> Attribute -> Bool

(>=) :: Attribute -> Attribute -> Bool

max :: Attribute -> Attribute -> Attribute

min :: Attribute -> Attribute -> Attribute

compileAttrTest :: PropertyTest -> String -> Bool Source #

matched :: t -> Bool Source #

attrTest :: Maybe Text -> Text -> PropertyTest -> Element -> Bool Source #

hasWord :: String -> String -> Bool Source #

hasLang :: [Char] -> [Char] -> Bool Source #

parseUnorderedShorthand :: PropertyParser a => a -> [Text] -> [Token] -> [(Text, [Token])] Source #

parseUnorderedShorthand' :: PropertyParser a => a -> [Text] -> [[Token]] -> [(Text, [Token])] Source #