web-view-0.6.2: Type-safe HTML and CSS with intuitive layouts and composable styles.
Safe HaskellNone
LanguageGHC2021

Web.View.Style

Synopsis

Styles

width :: Length -> Mod c Source #

Set to a specific width

height :: Length -> Mod c Source #

Set to a specific height

minWidth :: Length -> Mod c Source #

Allow width to grow to contents but not shrink any smaller than value

minHeight :: Length -> Mod c Source #

Allow height to grow to contents but not shrink any smaller than value

pad :: Sides Length -> Mod c Source #

Space surrounding the children of the element

To create even spacing around and between all elements:

col (pad 10 . gap 10) $ do
  el_ "one"
  el_ "two"
  el_ "three"

gap :: Length -> Mod c Source #

The space between child elements. See pad

shadow :: (Style Shadow a, ToClassName a) => a -> Mod c Source #

Add a drop shadow to an element

input (shadow Inner) "Inset Shadow"
button (shadow ()) "Click Me"

data Shadow Source #

Instances

Instances details
Style Shadow Inner Source # 
Instance details

Defined in Web.View.Style

Style Shadow None Source # 
Instance details

Defined in Web.View.Style

Style Shadow () Source # 
Instance details

Defined in Web.View.Style

Methods

styleValue :: () -> StyleValue Source #

data Inner Source #

Constructors

Inner 

Instances

Instances details
Show Inner Source # 
Instance details

Defined in Web.View.Style

Methods

showsPrec :: Int -> Inner -> ShowS #

show :: Inner -> String #

showList :: [Inner] -> ShowS #

ToClassName Inner Source # 
Instance details

Defined in Web.View.Style

Style Shadow Inner Source # 
Instance details

Defined in Web.View.Style

rounded :: Length -> Mod c Source #

Round the corners of the element

bg :: ToColor clr => clr -> Mod ctx Source #

Set the background color. See ToColor

color :: ToColor clr => clr -> Mod ctx Source #

Set the text color. See ToColor

list :: (ToClassName a, Style ListType a) => a -> Mod c Source #

Set the list style of an item

ol id $ do
  li (list Decimal) "First"
  li (list Decimal) "Second"
  li (list Decimal) "Third"

data ListType Source #

Constructors

Decimal 
Disc 

Instances

Instances details
Show ListType Source # 
Instance details

Defined in Web.View.Style

ToClassName ListType Source # 
Instance details

Defined in Web.View.Style

ToStyleValue ListType Source # 
Instance details

Defined in Web.View.Style

Style ListType ListType Source # 
Instance details

Defined in Web.View.Style

Style ListType None Source # 
Instance details

Defined in Web.View.Style

border :: Sides PxRem -> Mod c Source #

Set a border around the element

el (border 1) "all sides"
el (border (X 1)) "only left and right"

borderColor :: ToColor clr => clr -> Mod ctx Source #

Set a border color. See ToColor

pointer :: Mod c Source #

Use a button-like cursor when hovering over the element

Button-like elements:

btn = pointer . bg Primary . hover (bg PrimaryLight)

options = row id $ do
  el btn "Login"
  el btn "Sign Up"

transition :: Ms -> TransitionProperty -> Mod c Source #

Animate changes to the given property

el (transition 100 (Height 400)) "Tall"
el (transition 100 (Height 100)) "Small"

offset :: Sides Length -> Mod c Source #

Set Top, Right, Bottom and Left. Requires position Absolute or Fixed. Also see popup

position :: Position -> Mod c Source #

position:absolute. See stack and popout

data Position Source #

Constructors

Absolute 
Fixed 
Sticky 
Relative 

Instances

Instances details
Show Position Source # 
Instance details

Defined in Web.View.Style

ToClassName Position Source # 
Instance details

Defined in Web.View.Style

ToStyleValue Position Source # 
Instance details

Defined in Web.View.Style

display :: (Style Display a, ToClassName a) => a -> Mod c Source #

Set container display

el (display None) HIDDEN

data Display Source #

Constructors

Block 

Instances

Instances details
Show Display Source # 
Instance details

Defined in Web.View.Style

ToClassName Display Source # 
Instance details

Defined in Web.View.Style

ToStyleValue Display Source # 
Instance details

Defined in Web.View.Style

Style Display Display Source # 
Instance details

Defined in Web.View.Style

Style Display None Source # 
Instance details

Defined in Web.View.Style

Selector Modifiers

hover :: Mod c -> Mod c Source #

Apply when hovering over an element

el (bg Primary . hover (bg PrimaryLight)) "Hover"

active :: Mod c -> Mod c Source #

Apply when the mouse is pressed down on an element

even :: Mod c -> Mod c Source #

Apply to even-numbered children

odd :: Mod c -> Mod c Source #

Apply to odd-numbered children

media :: Media -> Mod c -> Mod c Source #

Apply when the Media matches the current window. This allows for responsive designs

el (width 100 . media (MinWidth 800) (width 400))
  "Big if window > 800"

parent :: Text -> Mod c -> Mod c Source #

Apply when the element is somewhere inside an anscestor.

For example, the HTMX library applies an "htmx-request" class to the body when a request is pending. We can use this to create a loading indicator

el (pad 10) $ do
  el (parent "htmx-request" flexRow . hide) "Loading..."
  el (parent "htmx-request" hide . flexRow) "Normal Content"

mapModClass :: (Class -> Class) -> Mod c -> Mod c Source #

Creating New Styles

addClass :: Class -> Mod c Source #

Add a single class

width :: PxRem -> Mod
width n =
  addClass
    $ cls ("w" -. n)
    & prop "width" n
    & prop @Int "flex-shrink" 0

cls :: ClassName -> Class Source #

Construct a class from a ClassName

extClass :: ClassName -> Mod c Source #

Construct a mod from a ClassName with no CSS properties. Convenience for situations where external CSS classes need to be referenced.

el (extClass "btn" . extClass "btn-primary") "Click me!"

prop :: ToStyleValue val => Name -> val -> Class -> Class Source #

Add a property to a class

(-.) :: ToClassName a => ClassName -> a -> ClassName infixl 6 Source #

Hyphenate classnames

class Style (style :: k) value where Source #

Minimal complete definition

Nothing

Methods

styleValue :: value -> StyleValue Source #

default styleValue :: ToStyleValue value => value -> StyleValue Source #

Instances

Instances details
Style Display Display Source # 
Instance details

Defined in Web.View.Style

Style Display None Source # 
Instance details

Defined in Web.View.Style

Style ListType ListType Source # 
Instance details

Defined in Web.View.Style

Style ListType None Source # 
Instance details

Defined in Web.View.Style

Style Shadow Inner Source # 
Instance details

Defined in Web.View.Style

Style Shadow None Source # 
Instance details

Defined in Web.View.Style

Style Shadow () Source # 
Instance details

Defined in Web.View.Style

Methods

styleValue :: () -> StyleValue Source #