43 lines
1.2 KiB
Plaintext
43 lines
1.2 KiB
Plaintext
package site
|
|
|
|
import datastar "github.com/starfederation/datastar/sdk/go"
|
|
|
|
type DialogBrowserSignals struct {
|
|
Prompt string `json:"prompt"`
|
|
Confirm bool `json:"confirm"`
|
|
}
|
|
|
|
templ DialogBrowserView(signals *DialogBrowserSignals) {
|
|
<button
|
|
id="dialogs"
|
|
class="flex items-center btn btn-primary"
|
|
data-signals={ templ.JSONString(signals) }
|
|
data-on-click="$prompt = prompt('Enter a string',$prompt);$confirm = confirm('Are you sure?');$confirm && @get('/examples/dialogs_browser/sure')"
|
|
>
|
|
Click Me
|
|
@icon("material-symbols:question-mark")
|
|
</button>
|
|
}
|
|
|
|
templ DialogBrowserSure(signals *DialogBrowserSignals) {
|
|
<div id="dialogs" class="flex flex-col gap-4">
|
|
if signals.Confirm {
|
|
<div>
|
|
You clicked the button and confirmed with prompt of <span id="confirmation" class="font-bold text-accent">{ signals.Prompt }</span>!
|
|
</div>
|
|
<button
|
|
class="flex items-center gap-2 btn btn-accent"
|
|
data-on-click={ datastar.GetSSE("/examples/dialogs_browser/data") }
|
|
>
|
|
@icon("material-symbols:arrow-back")
|
|
Reset
|
|
</button>
|
|
} else {
|
|
<div class="alert alert-error">
|
|
@icon("material-symbols:error-icon")
|
|
You clicked the button and did not confirm! Should not see this
|
|
</div>
|
|
}
|
|
</div>
|
|
}
|