hyperbole-0.5.0: Interactive HTML apps using type-safe serverside Haskell
Safe HaskellSafe-Inferred
LanguageGHC2021

Web.Hyperbole.HyperView.Input

Synopsis

Documentation

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

<button> HTML tag which sends the action when pressed

messageView :: Text -> View Message ()
messageView msg = do
  button (Louder msg) ~ border 1 $ text msg

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

Type-safe dropdown. Sends (opt -> Action id) when selected. The default will be selected.

▶️ Filter

familyDropdown :: Filters -> View Languages ()
familyDropdown filters =
  dropdown SetFamily filters.family ~ border 1 . pad 10 $ do
    option Nothing "Any"
    option (Just ObjectOriented) "Object Oriented"
    option (Just Functional) "Functional"

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

An option for a dropdown or select

selected :: Attributable h => Bool -> Attributes h -> Attributes h Source #

sets selected = true if the dropdown predicate returns True

data Option opt id Source #

The view context for an option

Constructors

Option 

Fields

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

A live search field. Set a DelayMs to avoid hitting the server on every keystroke

viewSearchUsers :: View Users ()
viewSearchUsers = do
  el "Search for a user by id"
  search SearchUser 250 ~ border 1 . pad 10 @ placeholder "2"

checked :: Attributable a => Bool -> Attributes a -> Attributes a Source #

Set checkbox = checked via the client (VDOM doesn't work)

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

A hyperlink to another route

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