miso
Copyright(C) 2016-2026 David M. Johnson
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <code@dmj.io>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Miso.CSS.Types

Contents

Description

Overview

Miso.CSS.Types defines the core data types that back the CSS DSL in Miso.CSS. There are three layers:

In normal usage you never construct these types directly — the smart constructors in Miso.CSS (sheet_, selector_, keyframes_, media_) build them for you. This module is exported for downstream code that inspects or extends the CSS representation.

Type hierarchy

StyleSheet          -- rendered to a <style> tag
  └─ [Styles]       -- one rule block each
       ├─ Styles    (selector → [Style])
       ├─ KeyFrame  (animation-name → [(stop, [Style])])
       └─ Media     (media-query   → [(selector, [Style])])

Style = (MisoString, MisoString)   -- property, value

See also

Synopsis

Types

type Style = (MisoString, MisoString) Source #

Type for a CSS Style

data Styles Source #

A CSS rule block. One of: a selector rule, a @keyframes animation, or a @media query.

Instances

Instances details
Show Styles Source # 
Instance details

Defined in Miso.CSS.Types

Eq Styles Source # 
Instance details

Defined in Miso.CSS.Types

Methods

(==) :: Styles -> Styles -> Bool #

(/=) :: Styles -> Styles -> Bool #

newtype StyleSheet Source #

Type for a CSS StyleSheet. Internally it maps From CSS selectors to Styles.

testSheet :: StyleSheet
testSheet =
   sheet_
   [ selector_ ".name"
       [ backgroundColor red
       , alignContent "top"
       ]
   , selector_ "#container"
       [ backgroundColor blue
       , alignContent "center"
       ]
   , keyframes_ "slide-in"
     [ from_ [ transforms [ translateX (pct 0) ] ]
     , at (pct 50)
       [ backgroundColor red
       , backgroundSize "10px"
       ]
     , to_ [ transforms [ translateX (pct 100) ] ]
     ]
   , media_ (screen_ and_ minWidth_ (px 480))
     [ rule_ "header" [ height "auto" ]
     , rule_ "ul"     [ display "block" ]
     ]
   ]

Constructors

StyleSheet 

Fields

Instances

Instances details
Show StyleSheet Source # 
Instance details

Defined in Miso.CSS.Types

Eq StyleSheet Source # 
Instance details

Defined in Miso.CSS.Types

newtype TransformFn Source #

An individual CSS transform function. Construct values with translate, rotate, scale, etc., then combine with transforms.

transforms [ translate (px 10) (pct 50), rotate (deg 45), scaleX 1.5 ]

Constructors

TransformFn 

Fields

Instances

Instances details
Show TransformFn Source # 
Instance details

Defined in Miso.CSS.Types

Eq TransformFn Source # 
Instance details

Defined in Miso.CSS.Types

newtype KeyframeStop Source #

A single stop in a '@keyframes' rule. Construct with from_, to_, or at.

Constructors

KeyframeStop 

Instances

Instances details
Show KeyframeStop Source # 
Instance details

Defined in Miso.CSS.Types

Eq KeyframeStop Source # 
Instance details

Defined in Miso.CSS.Types

newtype MediaRule Source #

A selector rule inside a '@media' block. Construct with rule_.

Constructors

MediaRule 

Fields

Instances

Instances details
Show MediaRule Source # 
Instance details

Defined in Miso.CSS.Types

Eq MediaRule Source # 
Instance details

Defined in Miso.CSS.Types

newtype MediaQuery Source #

A CSS media query. Construct with screen_, print_, all_, minWidth_, etc., and compose with and_, or_, not_.

Constructors

MediaQuery 

Instances

Instances details
Show MediaQuery Source # 
Instance details

Defined in Miso.CSS.Types

Eq MediaQuery Source # 
Instance details

Defined in Miso.CSS.Types