Copyright | (c) Nathaniel Symer, 2015 |
---|---|
License | MIT |
Maintainer | nate@symer.io |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Create & manipulate CSS selectors.
- data Selector
- = Child Selector Selector
- | Precedence Selector Selector
- | ImmediatePrecedence Selector Selector
- | Descendant Selector Selector
- | PseudoClass Selector Text (Maybe Selector)
- | PseudoType Selector Text (Maybe Selector)
- | AttrExistential Selector Text
- | AttrEquality Selector Text Text
- | AttrWhitespaceListContains Selector Text Text
- | AttrHyphenListContains Selector Text Text
- | AttrBeginsWith Selector Text Text
- | AttrEndsWith Selector Text Text
- | AttrSubstring Selector Text Text
- | Class Selector Text
- | Id Selector Text
- | FontFace
- | SelectorList [Selector]
- | Raw Text
- | Null
- buildSelector :: Selector -> Builder
- (<||>) :: Selector -> Selector -> Selector
- (.>.) :: Selector -> Selector -> Selector
- (.+.) :: Selector -> Selector -> Selector
- (.~.) :: Selector -> Selector -> Selector
- (#) :: Selector -> Text -> Selector
- (!) :: Selector -> Text -> Selector
- (<:>) :: Selector -> Text -> Selector
- (<::>) :: Selector -> Text -> Selector
- (|=|) :: Text -> Text -> Selector
- (|~=|) :: Text -> Text -> Selector
- (||=|) :: Text -> Text -> Selector
- (|^=|) :: Text -> Text -> Selector
- (|$=|) :: Text -> Text -> Selector
- (|*=|) :: Text -> Text -> Selector
- cls :: Text -> Selector
- ident :: Text -> Selector
- pseudoClass :: Text -> Maybe Selector -> Selector
- pseudoClass' :: Text -> Selector
- pseudoType :: Text -> Maybe Selector -> Selector
- pseudoType' :: Text -> Selector
Types
A CSS selector
Child Selector Selector | a > b |
Precedence Selector Selector | a ~ b |
ImmediatePrecedence Selector Selector | a + b |
Descendant Selector Selector | a b |
PseudoClass Selector Text (Maybe Selector) | a:hover, a:not(b) |
PseudoType Selector Text (Maybe Selector) | span::before, span::my-pseudotype(b) |
AttrExistential Selector Text | h2[foo] |
AttrEquality Selector Text Text | h2[foo="bar"] |
AttrWhitespaceListContains Selector Text Text | h2[foo~="bar"] |
AttrHyphenListContains Selector Text Text | h2[foo|="en"] |
AttrBeginsWith Selector Text Text | h2[foo^="bar"] |
AttrEndsWith Selector Text Text | h2[foo$="bar"] |
AttrSubstring Selector Text Text | h2[foo*="bar"] |
Class Selector Text | h2.myclass |
Id Selector Text | a#mylink |
FontFace | @ |
SelectorList [Selector] | a, h2, .myclass |
Raw Text | plain string to be rendered-as is in CSS |
Null | null string |
Builder
Operators
(<||>) :: Selector -> Selector -> Selector infixl 7 Source
Add aspect operator. Used to construct larger selectors
from smaller ones. Often types, Selector
s are constructed
with the first argument set to Null
, eg Class Null "myclass"
.
You can use this operator to create a selector like this: h2.myclass
by doing something like (Raw "h2") <||> (Class Null "myclass")
(which
is equivalent to Class (Raw "h2") "myclass"
).
Selector Operators
immediate precedence.
Match a pair of contiguous selectors.
Add a class to a Selector
.
Add a pseudoclass to a Selector
. Does not
allow for a parenthetial statement to be written
as part of the pseudoclass.
Add a pseudotype to a Selector
. Does not
allow for a parenthetial statement to be written
as part of the pseudoclass.
Attribute Operators
Equality.
Whitespace-separated list contains.
Hyphen-separated list contains.
:: Text | the name of the pseudoclass |
-> Maybe Selector | maybe a parenthetical statement to follow the pseudoclass |
-> Selector |
Create a pseudoclass.
pseudoClass' :: Text -> Selector Source
:: Text | the name of the pseudotype |
-> Maybe Selector | maybe a parenthetical statement to follow the pseudotype |
-> Selector |
Create a pseudotype.
pseudoType' :: Text -> Selector Source