summaryrefslogtreecommitdiff
path: root/Miso/Extend.hs
blob: 9ebdd08f7b5f672efbaf97551179c2c685d6dae9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}

module Miso.Extend
  ( crossorigin_,
    onPreventClick,
  )
where

import Alpha
import Miso
import Miso.String

-- | HTML crossorigin attribute
--
-- https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin
crossorigin_ :: MisoString -> Attribute action
crossorigin_ = textProp "crossorigin"

-- | Like 'onClick' but prevents the default action from triggering. Use this to
-- overide 'a_' links, for example.
onPreventClick :: action -> Attribute action
onPreventClick action =
  onWithOptions
    Miso.defaultOptions {preventDefault = True}
    "click"
    emptyDecoder
    (\() -> action)