themes-pastel-dream/affirmation.go
Alex Dunmow de55bbebd6 initial: theme plugin pastel-dream
Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously
an unversioned directory inside ~/src/blockninja-themes/pastel-dream.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 14:11:41 +08:00

47 lines
1.1 KiB
Go

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/blocks"
)
// AffirmationMeta defines the affirmation strip block.
var AffirmationMeta = blocks.BlockMeta{
Key: "affirmation",
Title: "Affirmation Strip",
Description: "Slow-shimmer band carrying a short calming line in display type.",
Source: "pastel-dream",
Category: blocks.CategoryTheme,
}
// AffirmationBlock renders the affirmation strip.
// Content shape: {quote, author, palette}
func AffirmationBlock(ctx context.Context, content map[string]any) string {
palette := getStringOr(content, "palette", "blush")
switch palette {
case "blush", "mint", "butter", "sky":
// valid
default:
palette = "blush"
}
data := AffirmationData{
Quote: getStringOr(content, "quote", "You are doing enough."),
Author: getString(content, "author"),
Palette: palette,
}
var buf bytes.Buffer
_ = affirmationComponent(data).Render(ctx, &buf)
return buf.String()
}
// AffirmationData is the rendered view of the affirmation block.
type AffirmationData struct {
Quote string
Author string
Palette string
}