48 lines
999 B
Plaintext
48 lines
999 B
Plaintext
package site
|
|
|
|
import (
|
|
"fmt"
|
|
datastar "github.com/starfederation/datastar/sdk/go"
|
|
)
|
|
|
|
templ prefetchCarousel(currentID int) {
|
|
{{
|
|
|
|
prevID := currentID - 1
|
|
if prevID < 1 {
|
|
prevID = pokemonCount
|
|
}
|
|
prevURL := fmt.Sprintf(pokemonURLFormat, prevID)
|
|
|
|
currentURL := fmt.Sprintf(pokemonURLFormat, currentID)
|
|
|
|
nextID := currentID + 1
|
|
if nextID > pokemonCount {
|
|
nextID = 1
|
|
}
|
|
nextURL := fmt.Sprintf(pokemonURLFormat, nextID)
|
|
}}
|
|
<div
|
|
id="carousel"
|
|
class="flex items-center gap-4"
|
|
>
|
|
<button
|
|
class="w-32 h-32 ring-2 flex items-center justify-center rounded-box"
|
|
data-on-click={ datastar.GetSSE("/examples/prefetch/%d", prevID) }
|
|
>
|
|
<img src={ prevURL } alt="Previous"/>
|
|
</button>
|
|
<img
|
|
class="w-96 h-96 pixelated"
|
|
src={ currentURL }
|
|
alt="Current"
|
|
/>
|
|
<button
|
|
class="w-32 h-32 ring-2 flex items-center justify-center rounded-box"
|
|
data-on-click={ datastar.GetSSE("/examples/prefetch/%d", nextID) }
|
|
>
|
|
<img src={ nextURL } alt="Next"/>
|
|
</button>
|
|
</div>
|
|
}
|