themes-pastel-dream/testimonial_soft.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

51 lines
1.2 KiB
Go

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/blocks"
)
// TestimonialSoftMeta defines the soft testimonial card.
var TestimonialSoftMeta = blocks.BlockMeta{
Key: "testimonial-soft",
Title: "Soft Testimonial",
Description: "Quote card with a deckle paper edge, avatar, and rating.",
Source: "pastel-dream",
Category: blocks.CategoryTheme,
}
// TestimonialSoftBlock renders the testimonial card.
// Content shape: {quote, name, role, avatar, rating}
func TestimonialSoftBlock(ctx context.Context, content map[string]any) string {
rating := getFloat(content, "rating", 0)
if rating < 0 {
rating = 0
}
if rating > 5 {
rating = 5
}
data := TestimonialSoftData{
Quote: getString(content, "quote"),
Name: getString(content, "name"),
Role: getString(content, "role"),
Avatar: getString(content, "avatar"),
Rating: int(rating),
}
var buf bytes.Buffer
_ = testimonialSoftComponent(data).Render(ctx, &buf)
return buf.String()
}
// TestimonialSoftData is the rendered view of the testimonial-soft block.
type TestimonialSoftData struct {
Quote string
Name string
Role string
Avatar string
Rating int
}