stylist-2.7.0.1: Apply CSS styles to a document tree.
Safe HaskellNone
LanguageHaskell2010

Data.CSS.Preprocessor.Conditions

Description

Evaluates conditional CSS rules. Parse a CSS stylesheet to ConditionalStyles to evaluate document & supports rules. Call loadImports to resolve any import rules to media rules. And call resolve to convert into another StyleSheet instance whilst resolving media rules.

Synopsis

Documentation

data ConditionalStyles p Source #

Collects and evaluates conditional at-rules.

Constructors

ConditionalStyles 

Fields

  • hostURL :: URI

    The URL to the webpage being styled, for `@document` rules.

  • mediaDocument :: String

    The type of document, `@document domain(...)` rules.

  • isUnstyled :: Bool

    Whether the page provided any of it's own styling (valid or not)

  • rules :: [ConditionalRule p]

    Queued style rules, to be evaluated later.

  • propertyParser :: p

    PropertyParser to test against for `@supports` rules.

  • layers :: Tree

    Known-named @layers.

  • layerNamespace :: [Text]

    The current @layer, for resolving nesting

  • layerPath' :: [Int]

    The integral path to the current @layer, for resolving nesting

data ConditionalRule p Source #

Style rules that can be queued in a ConditionalStyles.

extractImports :: (Text -> Datum) -> (Token -> Datum) -> ConditionalStyles p -> [URI] Source #

Returns `@import` URLs that need to be imported.

resolveImports :: ConditionalStyles p -> [(URI, ConditionalStyles p)] -> ConditionalStyles p Source #

Substitutes external values in for `@import` rules.

loadImports :: PropertyParser p => (URI -> IO Text) -> (Text -> Datum) -> (Token -> Datum) -> ConditionalStyles p -> [URI] -> IO (ConditionalStyles p) Source #

Evaluates a given "loader" to resolve any `@import` rules.

resolve :: StyleSheet s => (Text -> Datum) -> (Token -> Datum) -> s -> ConditionalStyles p -> s Source #

Evaluates any media queries, returning a new StyleSheet with the queued operations.

testIsStyled :: ConditionalStyles p -> ConditionalStyles p Source #

Flags whether any style rules have been applied yet, for the sake of evaluating "@document unstyled {...}".

data Datum Source #

Dynamic types for evaluating media queries.

Constructors

B Bool 
N Float 
R 

Fields

Instances

Instances details
Eq Datum Source # 
Instance details

Defined in Data.CSS.Preprocessor.Conditions.Expr

Methods

(==) :: Datum -> Datum -> Bool

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