module Htmx.Lucid.Core where
import Data.Text (Text, pack)
import Htmx.Event
import Htmx.Render
import Htmx.Swap (Swap)
import Lucid (Html, HtmlT, script_, src_)
import Lucid.Base (Attribute, makeAttribute)
hxGet_ :: Text -> Attribute
hxGet_ :: Text -> Attribute
hxGet_ = Text -> Text -> Attribute
makeAttribute Text
"hx-get"
hxPost_ :: Text -> Attribute
hxPost_ :: Text -> Attribute
hxPost_ = Text -> Text -> Attribute
makeAttribute Text
"hx-post"
hxPushUrl_ :: Text -> Attribute
hxPushUrl_ :: Text -> Attribute
hxPushUrl_ = Text -> Text -> Attribute
makeAttribute Text
"hx-push-url"
hxSelect_ :: Text -> Attribute
hxSelect_ :: Text -> Attribute
hxSelect_ = Text -> Text -> Attribute
makeAttribute Text
"hx-select"
hxSelectOob_ :: Text -> Attribute
hxSelectOob_ :: Text -> Attribute
hxSelectOob_ = Text -> Text -> Attribute
makeAttribute Text
"hx-select-oob"
hxSwap_ :: Text -> Attribute
hxSwap_ :: Text -> Attribute
hxSwap_ = Text -> Text -> Attribute
makeAttribute Text
"hx-swap"
hxSwapS_ :: Swap -> Attribute
hxSwapS_ :: Swap -> Attribute
hxSwapS_ = Text -> Text -> Attribute
makeAttribute Text
"hx-swap" (Text -> Attribute) -> (Swap -> Text) -> Swap -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Swap -> Text
forall a. Render a => a -> Text
render
hxSwapOob_ :: Text -> Attribute
hxSwapOob_ :: Text -> Attribute
hxSwapOob_ = Text -> Text -> Attribute
makeAttribute Text
"hx-swap-oob"
hxTarget_ :: Text -> Attribute
hxTarget_ :: Text -> Attribute
hxTarget_ = Text -> Text -> Attribute
makeAttribute Text
"hx-target"
hxTrigger_ :: Text -> Attribute
hxTrigger_ :: Text -> Attribute
hxTrigger_ = Text -> Text -> Attribute
makeAttribute Text
"hx-trigger"
hxVals_ :: Text -> Attribute
hxVals_ :: Text -> Attribute
hxVals_ = Text -> Text -> Attribute
makeAttribute Text
"hx-vals"
data OnEvent = DomOnEvent Text | HtmxOnEvent HtmxEvent
hxOn_ :: OnEvent -> Text -> Attribute
hxOn_ :: OnEvent -> Text -> Attribute
hxOn_ = \case
DomOnEvent Text
event -> Text -> Text -> Attribute
makeAttribute (Text -> Text -> Attribute) -> Text -> Text -> Attribute
forall a b. (a -> b) -> a -> b
$ Text
"hx-on:" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
event
HtmxOnEvent HtmxEvent
htmxEvent -> Text -> Text -> Attribute
makeAttribute (Text -> Text -> Attribute) -> Text -> Text -> Attribute
forall a b. (a -> b) -> a -> b
$ Text
"hx-on::" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> HtmxEvent -> Text
forall a. Render a => a -> Text
render HtmxEvent
htmxEvent