clay-0.15.0: CSS preprocessor as embedded Haskell.

Safe Haskell | None
Language | Haskell2010

Clay.Stylesheet

Synopsis

- newtype MediaType = MediaType Value
- data NotOrOnly
  - = Not
  - | Only
- data MediaQuery = MediaQuery (Maybe NotOrOnly) MediaType [Feature]
- data Feature = Feature Text (Maybe Value)
- newtype CommentText = CommentText {
  - unCommentText :: Text
  }
- data Modifier
  - = Important
  - | Comment CommentText
- _Important :: Modifier -> Maybe Text
- _Comment :: Modifier -> Maybe CommentText
- data App
  - = Self Refinement
  - | Root Selector
  - | Pop Int
  - | Child Selector
  - | Sub Selector
- data Keyframes = Keyframes Text [(Number, [Rule])]
- data Rule
  - = Property [Modifier] (Key ()) Value
  - | Nested App [Rule]
  - | Query MediaQuery [Rule]
  - | Face [Rule]
  - | Keyframe Keyframes
  - | Import Text
- newtype StyleM a = S (Writer [Rule] a)
- runS :: Css -> [Rule]
- rule :: Rule -> Css
- type Css = StyleM ()
- key :: Val a => Key a -> a -> Css
- prefixed :: Val a => Prefixed -> a -> Css
- (-:) :: Key Text -> Text -> Css
- (?) :: Selector -> Css -> Css
- (<?) :: Selector -> Css -> Css
- (&) :: Refinement -> Css -> Css
- root :: Selector -> Css -> Css
- pop :: Int -> Css -> Css
- query :: MediaType -> [Feature] -> Css -> Css
- queryNot :: MediaType -> [Feature] -> Css -> Css
- queryOnly :: MediaType -> [Feature] -> Css -> Css
- keyframes :: Text -> [(Number, Css)] -> Css
- keyframesFromTo :: Text -> Css -> Css -> Css
- fontFace :: Css -> Css
- importUrl :: Text -> Css
- important :: Css -> Css
- addImportant :: Rule -> Rule

# Documentation

newtype MediaType #

Constructors

MediaType Value |

#### Instances

Instances details

Show MediaType # |
Instance details Defined in Clay.Stylesheet Methods showsPrec :: Int -> MediaType -> ShowS # show :: MediaType -> String # showList :: [MediaType] -> ShowS #
All MediaType # |
Instance details Defined in Clay.Stylesheet Methods all :: MediaType #
Other MediaType # |
Instance details Defined in Clay.Stylesheet Methods other :: Value -> MediaType #
Val MediaType # |
Instance details Defined in Clay.Stylesheet Methods value :: MediaType -> Value #

data NotOrOnly #

Constructors

Not |
Only |

#### Instances

Instances details

Show NotOrOnly # |
Instance details Defined in Clay.Stylesheet Methods showsPrec :: Int -> NotOrOnly -> ShowS # show :: NotOrOnly -> String # showList :: [NotOrOnly] -> ShowS #

data MediaQuery #

Constructors

MediaQuery (Maybe NotOrOnly) MediaType [Feature] |

#### Instances

Instances details

Show MediaQuery # |
Instance details Defined in Clay.Stylesheet Methods showsPrec :: Int -> MediaQuery -> ShowS # show :: MediaQuery -> String # showList :: [MediaQuery] -> ShowS #

data Feature #

Constructors

Feature Text (Maybe Value) |

#### Instances

Instances details

Show Feature # |
Instance details Defined in Clay.Stylesheet Methods showsPrec :: Int -> Feature -> ShowS # show :: Feature -> String # showList :: [Feature] -> ShowS #

newtype CommentText #

Constructors

CommentText |
Fields unCommentText :: Text

#### Instances

Instances details

IsString CommentText # |
Instance details Defined in Clay.Stylesheet Methods fromString :: String -> CommentText #
Monoid CommentText # |
Instance details Defined in Clay.Stylesheet Methods mempty :: CommentText # mappend :: CommentText -> CommentText -> CommentText # mconcat :: [CommentText] -> CommentText #
Semigroup CommentText # |
Instance details Defined in Clay.Stylesheet Methods (<>) :: CommentText -> CommentText -> CommentText # sconcat :: NonEmpty CommentText -> CommentText # stimes :: Integral b => b -> CommentText -> CommentText #
Show CommentText # |
Instance details Defined in Clay.Stylesheet Methods showsPrec :: Int -> CommentText -> ShowS # show :: CommentText -> String # showList :: [CommentText] -> ShowS #

data Modifier #

Constructors

Important |
Comment CommentText |

#### Instances

Instances details

Show Modifier # |
Instance details Defined in Clay.Stylesheet Methods showsPrec :: Int -> Modifier -> ShowS # show :: Modifier -> String # showList :: [Modifier] -> ShowS #

_Important :: Modifier -> Maybe Text #

_Comment :: Modifier -> Maybe CommentText #

data App #

Constructors

Self Refinement |
Root Selector |
Pop Int |
Child Selector |
Sub Selector |

#### Instances

Instances details

Show App # |
Instance details Defined in Clay.Stylesheet Methods showsPrec :: Int -> App -> ShowS # show :: App -> String # showList :: [App] -> ShowS #

data Keyframes #

Constructors

Keyframes Text [(Number, [Rule])] |

#### Instances

Instances details

Show Keyframes # |
Instance details Defined in Clay.Stylesheet Methods showsPrec :: Int -> Keyframes -> ShowS # show :: Keyframes -> String # showList :: [Keyframes] -> ShowS #

data Rule #

Constructors

Property [Modifier] (Key ()) Value |
Nested App [Rule] |
Query MediaQuery [Rule] |
Face [Rule] |
Keyframe Keyframes |
Import Text |

#### Instances

Instances details

Show Rule # |
Instance details Defined in Clay.Stylesheet Methods showsPrec :: Int -> Rule -> ShowS # show :: Rule -> String # showList :: [Rule] -> ShowS #

newtype StyleM a #

Constructors

S (Writer [Rule] a) |

#### Instances

Instances details

Applicative StyleM # |
Instance details Defined in Clay.Stylesheet Methods pure :: a -> StyleM a # (<*>) :: StyleM (a -> b) -> StyleM a -> StyleM b # liftA2 :: (a -> b -> c) -> StyleM a -> StyleM b -> StyleM c # (*>) :: StyleM a -> StyleM b -> StyleM b # (<*) :: StyleM a -> StyleM b -> StyleM a #
Functor StyleM # |
Instance details Defined in Clay.Stylesheet Methods fmap :: (a -> b) -> StyleM a -> StyleM b # (<$) :: a -> StyleM b -> StyleM a #
Monad StyleM # |
Instance details Defined in Clay.Stylesheet Methods (>>=) :: StyleM a -> (a -> StyleM b) -> StyleM b # (>>) :: StyleM a -> StyleM b -> StyleM b # return :: a -> StyleM a #
Monoid Css # |
Instance details Defined in Clay.Stylesheet Methods mempty :: Css # mappend :: Css -> Css -> Css # mconcat :: [Css] -> Css #
Semigroup Css # |
Instance details Defined in Clay.Stylesheet Methods (<>) :: Css -> Css -> Css # sconcat :: NonEmpty Css -> Css # stimes :: Integral b => b -> Css -> Css #

runS :: Css -> [Rule] #

rule :: Rule -> Css #

type Css = StyleM () #

The `Css` context is used to collect style rules which are mappings from selectors to style properties. The `Css` type is a computation in the `StyleM` monad that just collects and doesn't return anything.

key :: Val a => Key a -> a -> Css #

Add a new style property to the stylesheet with the specified `Key` and value. The value can be any type that is in the `Val` typeclass, with other words: can be converted to a `Value`.

prefixed :: Val a => Prefixed -> a -> Css #

Add a new style property to the stylesheet with the specified `Key` and value, like `key` but use a `Prefixed` key.

(-:) :: Key Text -> Text -> Css infix 4 #

The colon operator can be used to add style rules to the current context for which there is no embedded version available. Both the key and the value are plain text values and rendered as is to the output CSS.

(?) :: Selector -> Css -> Css infixr 5 #

Assign a stylesheet to a selector. When the selector is nested inside an outer scope it will be composed with `deep`.

(<?) :: Selector -> Css -> Css infixr 5 #

Assign a stylesheet to a selector. When the selector is nested inside an outer scope it will be composed with `|>`.

(&) :: Refinement -> Css -> Css infixr 5 #

Assign a stylesheet to a filter selector. When the selector is nested inside an outer scope it will be composed with the `with` selector.

root :: Selector -> Css -> Css #

Root is used to add style rules to the top scope.

pop :: Int -> Css -> Css #

Pop is used to add style rules to selectors defined in an outer scope. The counter specifies how far up the scope stack we want to add the rules.

query :: MediaType -> [Feature] -> Css -> Css #

Apply a set of style rules when the media type and feature queries apply.

queryNot :: MediaType -> [Feature] -> Css -> Css #

Apply a set of style rules when the media type and feature queries do not apply.

queryOnly :: MediaType -> [Feature] -> Css -> Css #

Apply a set of style rules only when the media type and feature queries apply.

keyframes :: Text -> [(Number, Css)] -> Css #

keyframesFromTo :: Text -> Css -> Css -> Css #

fontFace :: Css -> Css #

Define a new font-face.

importUrl :: Text -> Css #

Import a CSS file from a URL

important :: Css -> Css #

Indicate the supplied css should override css declarations that would otherwise take precedence.

Use sparingly.

addImportant :: Rule -> Rule #