seanhess / hyperbole

Haskell interactive serverside web framework inspired by HTMX
Other
93 stars 6 forks source link

Feature Request // Add OnHover Event (to update any view) #40

Open benjaminweb opened 4 weeks ago

benjaminweb commented 4 weeks ago

Requirement: Update any view on onHover over specific element.

Web.View's hover does only apply to styles.

What would be the interface to call it? Another handler?

seanhess commented 4 weeks ago

We try to put these actions as arguments to a view function (rather than a Mod), because the views carry the view id type: View viewId ()

For example, here is button

button :: HyperView id => Action id -> Mod -> View id () -> View id ()

Can you give me a specific example here so we can think about how best to solve it? Is there a "view" analogous to button that we could create to handle this? Or is it more like onLoad, which wraps views?

benjaminweb commented 4 weeks ago
contactView :: User -> View Contact ()
contactView u = do
  col (pad 10 . gap 10) $ do
    target Contacts $ hover (ShowUid u.id) $ do
      row fld $ do
      el id (text "First Name:")
      text u.firstName

button is an onClick event. hover then is just an onHover event. target maps it to the corresponding ViewId.

Though, the specific event types might be differentiated out a little more like Elm does like onMouseEnter or onMouseLeave.

Is that what you had in mind as an example? Does that help?