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 (Attributes, makeAttributes)
hxGet_ :: Text -> Attributes
hxGet_ :: Text -> Attributes
hxGet_ = Text -> Text -> Attributes
makeAttributes Text
"hx-get"
hxPost_ :: Text -> Attributes
hxPost_ :: Text -> Attributes
hxPost_ = Text -> Text -> Attributes
makeAttributes Text
"hx-post"
hxPushUrl_ :: Text -> Attributes
hxPushUrl_ :: Text -> Attributes
hxPushUrl_ = Text -> Text -> Attributes
makeAttributes Text
"hx-push-url"
hxSelect_ :: Text -> Attributes
hxSelect_ :: Text -> Attributes
hxSelect_ = Text -> Text -> Attributes
makeAttributes Text
"hx-select"
hxSelectOob_ :: Text -> Attributes
hxSelectOob_ :: Text -> Attributes
hxSelectOob_ = Text -> Text -> Attributes
makeAttributes Text
"hx-select-oob"
hxSwap_ :: Text -> Attributes
hxSwap_ :: Text -> Attributes
hxSwap_ = Text -> Text -> Attributes
makeAttributes Text
"hx-swap"
hxSwapS_ :: Swap -> Attributes
hxSwapS_ :: Swap -> Attributes
hxSwapS_ = Text -> Text -> Attributes
makeAttributes Text
"hx-swap" (Text -> Attributes) -> (Swap -> Text) -> Swap -> Attributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Swap -> Text
forall a. Render a => a -> Text
render
hxSwapOob_ :: Text -> Attributes
hxSwapOob_ :: Text -> Attributes
hxSwapOob_ = Text -> Text -> Attributes
makeAttributes Text
"hx-swap-oob"
hxTarget_ :: Text -> Attributes
hxTarget_ :: Text -> Attributes
hxTarget_ = Text -> Text -> Attributes
makeAttributes Text
"hx-target"
hxTrigger_ :: Text -> Attributes
hxTrigger_ :: Text -> Attributes
hxTrigger_ = Text -> Text -> Attributes
makeAttributes Text
"hx-trigger"
hxVals_ :: Text -> Attributes
hxVals_ :: Text -> Attributes
hxVals_ = Text -> Text -> Attributes
makeAttributes Text
"hx-vals"
data OnEvent = DomOnEvent Text | HtmxOnEvent HtmxEvent
hxOn_ :: OnEvent -> Text -> Attributes
hxOn_ :: OnEvent -> Text -> Attributes
hxOn_ = \case
DomOnEvent Text
event -> Text -> Text -> Attributes
makeAttributes (Text -> Text -> Attributes) -> Text -> Text -> Attributes
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 -> Attributes
makeAttributes (Text -> Text -> Attributes) -> Text -> Text -> Attributes
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