Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously an unversioned directory inside ~/src/blockninja-themes/terminal. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// BootLogBlockMeta defines metadata for the boot log hero block.
|
|
var BootLogBlockMeta = blocks.BlockMeta{
|
|
Key: "boot_log",
|
|
Title: "Boot Log Hero",
|
|
Description: "Sequential dmesg-style boot lines revealed one after another",
|
|
Source: "terminal",
|
|
Category: blocks.CategoryContent,
|
|
}
|
|
|
|
// BootLogData is the parsed content for the boot_log block.
|
|
type BootLogData struct {
|
|
Lines []string
|
|
Cursor string
|
|
}
|
|
|
|
// BootLogBlock renders a sequential boot-log style hero.
|
|
// Content shape: {lines: []string, cursor: "block"|"underscore"|"pipe"|"none"}.
|
|
func BootLogBlock(ctx context.Context, content map[string]any) string {
|
|
data := BootLogData{
|
|
Lines: getStringSlice(content, "lines"),
|
|
Cursor: getStringDefault(content, "cursor", "block"),
|
|
}
|
|
if len(data.Lines) == 0 {
|
|
return ""
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
_ = bootLogComponent(data).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|
|
|
|
// cursorGlyph maps the cursor selector to its rendered character.
|
|
func cursorGlyph(name string) string {
|
|
switch name {
|
|
case "underscore":
|
|
return "_"
|
|
case "pipe":
|
|
return "|"
|
|
case "none":
|
|
return ""
|
|
case "block":
|
|
fallthrough
|
|
default:
|
|
return "█" // full block
|
|
}
|
|
}
|