Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously an unversioned directory inside ~/src/blockninja-themes/art-deco. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// GalleryFanBlockMeta defines the mirrored fan gallery block.
|
|
var GalleryFanBlockMeta = blocks.BlockMeta{
|
|
Key: "gallery_fan",
|
|
Title: "Fan Gallery",
|
|
Description: "Mirrored gallery framed by sunburst — collapses to single column under 640px.",
|
|
Source: "art-deco",
|
|
}
|
|
|
|
// GalleryImage is a single image in the gallery.
|
|
type GalleryImage struct {
|
|
Src string
|
|
Caption string
|
|
}
|
|
|
|
// GalleryFanData is the typed view for the gallery component.
|
|
type GalleryFanData struct {
|
|
Images []GalleryImage
|
|
Columns int
|
|
}
|
|
|
|
// GalleryFanBlock renders a mirrored fan gallery.
|
|
// Content: {"images": [{"src": "...", "caption": "..."}], "columns": 3}
|
|
func GalleryFanBlock(ctx context.Context, content map[string]any) string {
|
|
items := getSlice(content, "images")
|
|
images := make([]GalleryImage, 0, len(items))
|
|
for _, item := range items {
|
|
images = append(images, GalleryImage{
|
|
Src: getString(item, "src"),
|
|
Caption: getString(item, "caption"),
|
|
})
|
|
}
|
|
|
|
cols := getInt(content, "columns", 3)
|
|
cols = clampInt(cols, 2, 4)
|
|
|
|
var buf bytes.Buffer
|
|
_ = galleryFanComponent(GalleryFanData{Images: images, Columns: cols}).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|