web-view-0.3.1: Type-safe HTML and CSS with intuitive layouts and composable styles.
Safe HaskellSafe-Inferred
LanguageGHC2021

Web.View.Element

Synopsis

Documentation

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

A basic element

el (bold . pad 10) "Hello"

el_ :: View c () -> View c () Source #

A basic element, with no modifiers

el_ "Hello"

text :: Text -> View c () Source #

Add text to a view. Not required for string literals

el_ $ do
  "Hello: "
  text user.name

raw :: Text -> View c () Source #

Embed static, unescaped HTML or SVG. Take care not to use raw with user-generated content.

spinner = raw "<svg>...</svg>"

none :: View c () Source #

Do not show any content

if isVisible
 then content
 else none

pre :: Mod -> Text -> View c () Source #

link :: Url -> Mod -> View c () -> View c () Source #

A hyperlink to the given url

Inputs

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

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

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

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

Document Metadata

script :: Text -> View c () Source #

style :: Text -> View c () Source #

Tables

table :: Mod -> [dt] -> Eff '[Writer [TableColumn c dt]] () -> View c () Source #

Create a type safe data table by specifying columns

usersTable :: [User] -> View c ()
usersTable us = do
  table id us $ do
    tcol (th hd "Name") $ \u -> td cell $ text u.name
    tcol (th hd "Email") $ \u -> td cell $ text u.email
 where
  hd = cell . bold
  cell = pad 4 . border 1

tcol :: forall dt c. View (TableHead c) () -> (dt -> View dt ()) -> Eff '[Writer [TableColumn c dt]] () Source #

th :: Mod -> View c () -> View (TableHead c) () Source #

td :: Mod -> View () () -> View dt () Source #

newtype TableHead a Source #

Constructors

TableHead a 

data TableColumn c dt Source #

Constructors

TableColumn 

Fields