hyperbole-0.6.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 :: forall opt id. ViewAction (Action id) => (opt -> Action id) -> opt -> View (Option id opt) () -> 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 :: forall opt id. (ViewAction (Action id), Eq opt, ToParam opt) => opt -> Text -> View (Option id opt) () 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 id opt Source #

The view context for an option

Constructors

Option 

Fields

Instances

Instances details
Generic (Option id opt) Source # 
Instance details

Defined in Web.Hyperbole.HyperView.Input

Associated Types

type Rep (Option id opt) :: Type -> Type #

Methods

from :: Option id opt -> Rep (Option id opt) x #

to :: Rep (Option id opt) x -> Option id opt #

(ToParam id, ToParam opt, FromParam id, FromParam opt) => ViewId (Option id opt) Source # 
Instance details

Defined in Web.Hyperbole.HyperView.Input

Associated Types

type ViewState (Option id opt) Source #

type Rep (Option id opt) Source # 
Instance details

Defined in Web.Hyperbole.HyperView.Input

type Rep (Option id opt) = D1 ('MetaData "Option" "Web.Hyperbole.HyperView.Input" "hyperbole-0.6.0-inplace" 'False) (C1 ('MetaCons "Option" 'PrefixI 'True) (S1 ('MetaSel ('Just "id") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 id) :*: S1 ('MetaSel ('Just "defaultOption") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 opt)))
type ViewState (Option id opt) Source # 
Instance details

Defined in Web.Hyperbole.HyperView.Input

type ViewState (Option id opt) = ViewState id

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>