clay-0.13.1: CSS preprocessor as embedded Haskell.

Safe HaskellNone
LanguageHaskell98

Clay

Contents

Synopsis

Rendering stylesheets to CSS.

render :: Css -> Text Source #

Render a stylesheet with the default configuration. The pretty printer is used by default.

renderWith :: Config -> [App] -> Css -> Text Source #

Render a stylesheet with a custom configuration and an optional outer scope.

putCss :: Css -> IO () Source #

Render to CSS using the default configuration (pretty) and directly print to the standard output.

pretty :: Config Source #

Configuration to print to a pretty human readable CSS output.

compact :: Config Source #

Configuration to print to a compacted unreadable CSS output.

renderSelector :: Selector -> Text Source #

Render a single CSS Selector.

The Css monad for collecting style rules.

type Css = StyleM () Source #

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.

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

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 Source #

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 Source #

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 Source #

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

pop :: Int -> Css -> Css Source #

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.

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

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.

Comments

It is occasionally useful to output comments in the generated css. commenting appends comments (surrounded by ' /* ' and ' */') to the values of the supplied Css as

key: value /* comment */;

Placing the comments before the semicolon ensures they are obviously grouped with the preceding value when rendered compactly.

Note that every generated line in the generated content will feature the comment.

An empty comment generates '* *'.

commenting :: CommentText -> Css -> Css infixl 3 Source #

Annotate the supplied Css with the supplied comment. Comments work with OverloadedStrings. This will annotate every non-nested value.

The selector language.

Elements selectors.

star :: Selector Source #

The star selector applies to all elements. Maps to * in CSS.

element :: Text -> Selector Source #

Select elements by name. The preferred syntax is to enable OverloadedStrings and actually just use "element-name" or use one of the predefined elements from Clay.Elements.

(**) :: Selector -> Selector -> Selector Source #

The deep selector composer. Maps to sel1 sel2 in CSS.

(|>) :: Selector -> Selector -> Selector Source #

The child selector composer. Maps to sel1 > sel2 in CSS.

(#) :: Selector -> Refinement -> Selector Source #

The filter selector composer, adds a filter to a selector. Maps to something like sel#filter or sel.filter in CSS, depending on the filter.

(|+) :: Selector -> Selector -> Selector Source #

The adjacent selector composer. Maps to sel1 + sel2 in CSS.

Refining selectors.

byId :: Text -> Refinement Source #

Filter elements by id. The preferred syntax is to enable OverloadedStrings and use "#id-name".

byClass :: Text -> Refinement Source #

Filter elements by class. The preferred syntax is to enable OverloadedStrings and use ".class-name".

pseudo :: Text -> Refinement Source #

Filter elements by pseudo selector or pseudo class. The preferred syntax is to enable OverloadedStrings and use ":pseudo-selector" or use one of the predefined ones from Clay.Pseudo.

func :: Text -> [Text] -> Refinement Source #

Filter elements by pseudo selector functions. The preferred way is to use one of the predefined functions from Clay.Pseudo.

Attribute based refining.

attr :: Text -> Refinement Source #

Filter elements based on the presence of a certain attribute. The preferred syntax is to enable OverloadedStrings and use "@attr" or use one of the predefined ones from Clay.Attributes.

(@=) :: Text -> Text -> Refinement Source #

Filter elements based on the presence of a certain attribute with the specified value.

(^=) :: Text -> Text -> Refinement Source #

Filter elements based on the presence of a certain attribute that begins with the selected value.

($=) :: Text -> Text -> Refinement Source #

Filter elements based on the presence of a certain attribute that ends with the specified value.

(*=) :: Text -> Text -> Refinement Source #

Filter elements based on the presence of a certain attribute that contains the specified value as a substring.

(~=) :: Text -> Text -> Refinement Source #

Filter elements based on the presence of a certain attribute that have the specified value contained in a space separated list.

(|=) :: Text -> Text -> Refinement Source #

Filter elements based on the presence of a certain attribute that have the specified value contained in a hyphen separated list.

Apply media queries.

Because a large part of the names export by Clay.Media clash with names export by other modules we don't re-export it here and recommend you to import the module qualified.

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

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

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

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

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

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

Apply key-frame animation.

Define font-faces.

fontFace :: Css -> Css Source #

Define a new font-face.

!important

important :: Css -> Css Source #

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

Use sparingly.

Import other CSS files

importUrl :: Text -> Css Source #

Import a CSS file from a URL

Pseudo elements and classes.

HTML5 attribute and element names.

Commonly used value types.

module Clay.Size

module Clay.Color

module Clay.Time

Values shared between multiple properties.

Embedded style properties.

module Clay.Box

module Clay.Font

module Clay.List

module Clay.Text

module Clay.Mask

Writing your own properties.