hyperbole-0.4.2: Interactive HTML apps using type-safe serverside Haskell
Safe HaskellNone
LanguageGHC2021

Web.Hyperbole.View.Element

Synopsis

Documentation

button :: ViewAction (Action id) => Action id -> Mod id -> View id () -> View id () Source #

<button> HTML tag which sends the action when pressed

button SomeAction (border 1) "Click Me"

dropdown :: ViewAction (Action id) => (opt -> Action id) -> (opt -> Bool) -> Mod id -> View (Option opt id (Action id)) () -> View id () Source #

Type-safe dropdown. Sends (opt -> Action id) when selected. The selection predicate (opt -> Bool) controls which option is selected. See Example.Contacts

data ContactsAction
  = Reload (Maybe Filter)
  | Delete Int
  deriving (Generic, Param)

allContactsView :: Maybe Filter -> View Contacts ()
allContactsView fil = do
  row (gap 10) $ do
    el (pad 10) "Filter: "
    dropdown Reload (== fil) id $ do
      option Nothing ""
      option (Just Active) "Active!"
      option (Just Inactive) "Inactive"
  ...

option :: (ViewAction (Action id), Eq opt) => opt -> View (Option opt id (Action id)) () -> View (Option opt id (Action id)) () Source #

An option for a dropdown. First argument is passed to (opt -> Action id) in the dropdown, and to the selected predicate

selected :: Bool -> Mod id Source #

sets selected = true if the dropdown predicate returns True

data Option opt (id :: k) action Source #

The view context for an option

Constructors

Option 

Fields

search :: ViewAction (Action id) => (Text -> Action id) -> DelayMs -> Mod id -> View id () Source #

A live search field

route :: Route a => a -> Mod c -> View c () -> View c () Source #

A hyperlink to another route

>>> route (User 100) id "View User"
<a href="/user/100">View User</a>