package main import ( "bytes" "context" "git.dev.alexdunmow.com/block/core/blocks" ) // ImpactMetricsBlockMeta defines metadata for the impact metrics block. var ImpactMetricsBlockMeta = blocks.BlockMeta{ Key: "impact_metrics", Title: "Impact Metrics", Description: "Numerical impact metrics with optional botanical illustration", Source: "earthen", Category: blocks.CategoryContent, } // ImpactMetricsBlock renders a row of impact metrics. // Content shape: {title, metrics:[{value,label,suffix}], illustration} func ImpactMetricsBlock(ctx context.Context, content map[string]any) string { rawMetrics := getSlice(content, "metrics") items := make([]ImpactMetric, 0, len(rawMetrics)) for _, m := range rawMetrics { items = append(items, ImpactMetric{ Value: getString(m, "value"), Label: getString(m, "label"), Suffix: getString(m, "suffix"), }) } data := ImpactMetricsData{ Title: getString(content, "title"), Illustration: getString(content, "illustration"), Metrics: items, Empty: len(content) == 0, } var buf bytes.Buffer _ = impactMetricsComponent(data).Render(ctx, &buf) return buf.String() } // ImpactMetricsData contains data for the impact metrics component. type ImpactMetricsData struct { Title string Illustration string Metrics []ImpactMetric Empty bool } // ImpactMetric is one numerical metric tile. type ImpactMetric struct { Value string Label string Suffix string }