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

Web.View.Layout

Synopsis

Documentation

layout :: Mod c -> View c () -> View c () Source #

We can intuitively create layouts with combinations of row, col, stack, grow, and space

Wrap main content in layout to allow the view to consume vertical screen space

holygrail :: View c ()
holygrail = layout id $ do
  row section "Top Bar"
  row grow $ do
    col section "Left Sidebar"
    col (section . grow) "Main Content"
    col section "Right Sidebar"
  row section "Bottom Bar"
  where section = border 1

root :: Mod c Source #

As layout but as a Mod

holygrail = col root $ do
  ...

col :: Mod c -> View c () -> View c () Source #

Lay out children in a column.

col grow $ do
   el_ "Top"
   space
   el_ "Bottom"

row :: Mod c -> View c () -> View c () Source #

Lay out children in a row

row id $ do
   el_ "Left"
   space
   el_ "Right"

grow :: Mod c Source #

Grow to fill the available space in the parent row or col

row id $ do
 el grow none
 el_ "Right"

space :: View c () Source #

Space that fills the available space in the parent row or col.

row id $ do
 space
 el_ "Right"

This is equivalent to an empty element with grow

space = el grow none

scroll :: Mod c Source #

Make a fixed layout by putting scroll on a child-element

document = row root $ do
  nav (width 300) "Sidebar"
  col (grow . scroll) "Main Content"

nav :: Mod c -> View c () -> View c () Source #

A Nav element

stack :: Mod c -> Layer c () -> View c () Source #

Stack children on top of each other. Each child has the full width. See popout

stack id $ do
  row id "Background"
  row (bg Black . opacity 0.5) "Overlay"

newtype Layer c a Source #

A popout does not

Constructors

Layer (View c a) 

Instances

Instances details
Applicative (Layer c) Source # 
Instance details

Defined in Web.View.Layout

Methods

pure :: a -> Layer c a #

(<*>) :: Layer c (a -> b) -> Layer c a -> Layer c b #

liftA2 :: (a -> b -> c0) -> Layer c a -> Layer c b -> Layer c c0 #

(*>) :: Layer c a -> Layer c b -> Layer c b #

(<*) :: Layer c a -> Layer c b -> Layer c a #

Functor (Layer c) Source # 
Instance details

Defined in Web.View.Layout

Methods

fmap :: (a -> b) -> Layer c a -> Layer c b #

(<$) :: a -> Layer c b -> Layer c a #

Monad (Layer c) Source # 
Instance details

Defined in Web.View.Layout

Methods

(>>=) :: Layer c a -> (a -> Layer c b) -> Layer c b #

(>>) :: Layer c a -> Layer c b -> Layer c b #

return :: a -> Layer c a #

layer :: View c () -> Layer c () Source #

A normal layer contributes to the size of the parent

popout :: Mod c -> View c () -> Layer c () Source #

This child of a stack can pop out of the parent, covering content outside of it. Only usable inside stack

stack id $ do
  layer id $ input (value "Autocomplete Box")
  layer (popout (TRBL 50 0 0 0)) $ do
    el_ "Item 1"
    el_ "Item 2"
    el_ "Item 3"
el_ "This is covered by the menu"

hide :: Mod c Source #

Hide an element. See display

flexRow :: Mod c Source #

Set container to be a row. Favor row when possible

flexCol :: Mod c Source #

Set container to be a column. Favor col when possible

truncate :: Mod c Source #

Cut off the contents of the element