1package styles
2
3import (
4 "fmt"
5 "strings"
6
7 "github.com/charmbracelet/lipgloss"
8
9 "github.com/bnema/dumber/internal/domain/build"
10)
11
12// AboutRenderer renders build info in fastfetch style.
13type AboutRenderer struct {
14 theme *Theme
15}
16
17// NewAboutRenderer creates a new about renderer with the given theme.
18func NewAboutRenderer(theme *Theme) *AboutRenderer {
19 return &AboutRenderer{theme: theme}
20}
21
22// Render renders build info with ASCII logo and styled info lines.
23func (r *AboutRenderer) Render(info build.Info) string {
24 logo := r.renderLogo()
25 lines := r.renderInfoLines(info)
26
27 // Combine horizontally: logo | info
28 return lipgloss.JoinHorizontal(lipgloss.Top, logo, " ", lines)
29}
30
31func (r *AboutRenderer) renderLogo() string {
32 // ASCII art: Lightning bolt + D (matches pixel logo)
33 // All in accent color (green)
34 logoStyle := lipgloss.NewStyle().Foreground(r.theme.Accent).Bold(true)
35
36 // Simple bold D
37 logo := `██████▄
38██ ██
39██ ██
40██ ██
41██████▀`
42
43 return logoStyle.MarginTop(1).MarginLeft(2).Render(logo)
44}
45
46func (r *AboutRenderer) renderInfoLines(info build.Info) string {
47 keyStyle := r.theme.Subtle
48 valStyle := r.theme.Highlight
49 iconStyle := lipgloss.NewStyle().Foreground(r.theme.Accent)
50
51 lines := []string{
52 fmt.Sprintf("%s %s %s", iconStyle.Render(IconVersion), keyStyle.Render("Version"), valStyle.Render(info.Version)),
53 fmt.Sprintf("%s %s %s", iconStyle.Render(IconGitBranch), keyStyle.Render("Commit"), valStyle.Render(info.Commit)),
54 fmt.Sprintf("%s %s %s", iconStyle.Render(IconCalendar), keyStyle.Render("Built"), valStyle.Render(info.BuildDate)),
55 fmt.Sprintf("%s %s %s", iconStyle.Render(IconGo), keyStyle.Render("Go"), valStyle.Render(info.GoVersion)),
56 "",
57 fmt.Sprintf("%s %s", iconStyle.Render(IconGithub), keyStyle.Render(build.RepoURL())),
58 fmt.Sprintf(
59 "%s %s %s",
60 iconStyle.Render(IconHeart),
61 keyStyle.Render("Made with love by"),
62 valStyle.Render(strings.Join(build.Contributors(), ", ")),
63 ),
64 }
65
66 return strings.Join(lines, "\n")
67}