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>
42 lines
991 B
Go
42 lines
991 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
)
|
|
|
|
// ButtonOverrideData is the typed view for the button override component.
|
|
type ButtonOverrideData struct {
|
|
Label string
|
|
URL string
|
|
Variant string
|
|
}
|
|
|
|
// normaliseButtonVariant returns a known variant or "primary" as default.
|
|
func normaliseButtonVariant(v string) string {
|
|
switch v {
|
|
case "primary", "secondary", "ghost":
|
|
return v
|
|
default:
|
|
return "primary"
|
|
}
|
|
}
|
|
|
|
// ArtDecoButtonBlock overrides the built-in "button" block when the Art Deco theme is active.
|
|
// Content: {"label": "...", "url": "...", "variant": "primary|secondary|ghost"}
|
|
func ArtDecoButtonBlock(ctx context.Context, content map[string]any) string {
|
|
data := ButtonOverrideData{
|
|
Label: getString(content, "label"),
|
|
URL: getString(content, "url"),
|
|
Variant: normaliseButtonVariant(getString(content, "variant")),
|
|
}
|
|
|
|
if data.Label == "" {
|
|
return ""
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
_ = artDecoButtonComponent(data).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|