css-simple-0.1.0.0: eDSL for CSS
Copyright(c) Alexey Seledkov 2022
LicenseGPL-3
Maintainerqyutou@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Css.Internal

Description

 
Synopsis

Types

data Rule Source #

AST-like CSS Rule representation

Constructors

Rule !Text !Rule !Rule

Rule: selector, inner rules/declarations, next

Declaration !Text !Text !Rule

Declaration: property, value, next

Leaf !Text

Leaf: text This is used to allow creating the declarations without using of functions

Empty

Empty

Instances

Instances details
Monoid Rule Source #

Monoid instance for CSS Rule

Instance details

Defined in Css.Internal

Methods

mempty :: Rule #

mappend :: Rule -> Rule -> Rule #

mconcat :: [Rule] -> Rule #

Semigroup Rule Source #

Semigroup instance for CSS Rule

Instance details

Defined in Css.Internal

Methods

(<>) :: Rule -> Rule -> Rule #

sconcat :: NonEmpty Rule -> Rule #

stimes :: Integral b => b -> Rule -> Rule #

Show Rule Source #

Show instance for the CSS Rule

Instance details

Defined in Css.Internal

Methods

showsPrec :: Int -> Rule -> ShowS #

show :: Rule -> String #

showList :: [Rule] -> ShowS #

MonadWriter Rule Css Source #

MonadWriter instance for the Css monad

Instance details

Defined in Css.Internal

Methods

writer :: (a, Rule) -> Css a #

tell :: Rule -> Css () #

listen :: Css a -> Css (a, Rule) #

pass :: Css (a, Rule -> Rule) -> Css a #

newtype Css a Source #

Css monad - newtype wrapper around Control.Monad.Writer.Writer monad

Constructors

Css 

Fields

Instances

Instances details
Applicative Css Source # 
Instance details

Defined in Css.Internal

Methods

pure :: a -> Css a #

(<*>) :: Css (a -> b) -> Css a -> Css b #

liftA2 :: (a -> b -> c) -> Css a -> Css b -> Css c #

(*>) :: Css a -> Css b -> Css b #

(<*) :: Css a -> Css b -> Css a #

Functor Css Source # 
Instance details

Defined in Css.Internal

Methods

fmap :: (a -> b) -> Css a -> Css b #

(<$) :: a -> Css b -> Css a #

Monad Css Source # 
Instance details

Defined in Css.Internal

Methods

(>>=) :: Css a -> (a -> Css b) -> Css b #

(>>) :: Css a -> Css b -> Css b #

return :: a -> Css a #

MonadWriter Rule Css Source #

MonadWriter instance for the Css monad

Instance details

Defined in Css.Internal

Methods

writer :: (a, Rule) -> Css a #

tell :: Rule -> Css () #

listen :: Css a -> Css (a, Rule) #

pass :: Css (a, Rule -> Rule) -> Css a #

IsString (Css ()) Source #

IsString instance used to allow the creation of declarations NOTE: This is only for creating the Declarations, it doesn't do anything else.

Instance details

Defined in Css.Internal

Methods

fromString :: String -> Css () #

Monoid (Css ()) Source #

Monoid instance for the Css monad

Instance details

Defined in Css.Internal

Methods

mempty :: Css () #

mappend :: Css () -> Css () -> Css () #

mconcat :: [Css ()] -> Css () #

Semigroup (Css ()) Source #

Semigroup instance for the Css monad

Instance details

Defined in Css.Internal

Methods

(<>) :: Css () -> Css () -> Css () #

sconcat :: NonEmpty (Css ()) -> Css () #

stimes :: Integral b => b -> Css () -> Css () #

Show (Css ()) Source #

Show instance for the Css monad

Instance details

Defined in Css.Internal

Methods

showsPrec :: Int -> Css () -> ShowS #

show :: Css () -> String #

showList :: [Css ()] -> ShowS #

Rendering

data Config Source #

Rendering configuration

Constructors

Config 

Fields

pretty :: Config Source #

Pretty render configuration

compact :: Config Source #

Compact render configuration

renderRule Source #

Arguments

:: Rule

Rule to render

-> Text

Return as a Text

Used to render the Css Rules with pretty config

renderRuleWith Source #

Arguments

:: Rule

Rule to render

-> Config

Rendering configuration

-> Text

Return as a Text

Render the Css Rules with certain configuration

renderRuleWith' Source #

Arguments

:: Rule

Rule to render

-> Config

Rendering configuration

-> Builder

Prefix

-> Builder

Return as a Builder

Helper function for render rules Actually this is the main rendering functions, while the rest of the functions are something like front-end

renderCss Source #

Arguments

:: Css ()

Css to render

-> Text

Return as a Text

Render the Css Monad with pretty config as Text

renderCssWith Source #

Arguments

:: Css ()

Css to render

-> Config

Configuration

-> Text

Return as a Text

Render the Css Monad with certain config as Text

putCss Source #

Arguments

:: Css ()

Css to render

-> IO ()

Print to stdoup

Render the Css Monad and print it to stdout

putCssWith Source #

Arguments

:: Css ()

Css to render

-> Config

Configuration

-> IO ()

Print to stdout

Render the CSS with certain configuration and print it to stdout

renderCssToFile Source #

Arguments

:: Css ()

Css to render

-> FilePath

Pathtofile

-> IO ()

Save the rendered Css to the file path

Render the Css Monad and save it to the filePath

renderCssToFileWith Source #

Arguments

:: Css ()

Css to render

-> Config

Configuration

-> FilePath

Pathtofile

-> IO ()

Save the Css to the file

Render the Css Monad with certain config and save it to the filepath

eDSL

(?) Source #

Arguments

:: Text

Selector

-> Css ()

Inner Css

-> Css ()

Return in Css Monad

Infix version of rule

rule Source #

Arguments

:: Text

Selector

-> Css ()

Inner Css

-> Css ()

Return in Css Monad

Create new rule

Examples

Expand
>>> rule "body" (background "#000000") <> rule ".wrapper" (width "90vw" <> maxWidth "72rem")
body {
    background: #000000;
}
.wrapper {
    width: 90vw;
    max-width: 72rem;
}

(|>) Source #

Arguments

:: Text

Property

-> Text

Value

-> Css ()

Return in Css Monad

Infix version of declaration

declaration Source #

Arguments

:: Text

Property

-> Text

Value

-> Css ()

Return in Css Monad

Create new declaration

Examples

Expand
>>> declaration "width" "90vw"
width: 90vw;

Utility

getRules :: Css () -> Rule Source #

Utility function to extract the Css Rule from Css Monad

Orphan instances

(a ~ Css (), b ~ Css ()) => IsString (a -> b) Source #

IsString instance used to create the rules

Instance details

Methods

fromString :: String -> a -> b #