cli + tui to publish to leaflet (wip) & manage tasks, notes & watch/read lists 🍃
charm
leaflet
readability
golang
1// See https://patorjk.com/software/taag/
2//
3// NOTE: these aren't used anymore but are left in because they're cool
4package ui
5
6import (
7 _ "embed"
8 "strings"
9
10 "github.com/charmbracelet/bubbles/viewport"
11 "github.com/charmbracelet/lipgloss"
12)
13
14type Logo int
15
16const (
17 Colossal Logo = iota
18 Georgia
19 Alligator
20 ANSI
21 ANSIShadow
22)
23
24const colossal string = `
25888b 888 888 888 .d888
268888b 888 888 888 d88P"
2788888b 888 888 888 888
28888Y88b 888 .d88b. 888888 .d88b. 888 .d88b. 8888b. 888888
29888 Y88b888 d88""88b 888 d8P Y8b 888 d8P Y8b "88b 888
30888 Y88888 888 888 888 88888888 888 88888888 .d888888 888
31888 Y8888 Y88..88P Y88b. Y8b. 888 Y8b. 888 888 888
32888 Y888 "Y88P" "Y888 "Y8888 888 "Y8888 "Y888888 888
33`
34
35const alligator string = `
36:::: ::: :::::::: ::::::::::: :::::::::: ::: :::::::::: ::: ::::::::::
37:+:+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+:
38:+:+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+
39+#+ +:+ +#+ +#+ +:+ +#+ +#++:++# +#+ +#++:++# +#++:++#++: :#::+::#
40+#+ +#+#+# +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+
41#+# #+#+# #+# #+# #+# #+# #+# #+# #+# #+# #+#
42### #### ######## ### ########## ########## ########## ### ### ###
43`
44
45const ansi = `
46███ ██ ██████ ████████ ███████ ██ ███████ █████ ███████
47████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
48██ ██ ██ ██ ██ ██ █████ ██ █████ ███████ █████
49██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
50██ ████ ██████ ██ ███████ ███████ ███████ ██ ██ ██
51`
52
53const ansiShadow = `
54███╗ ██╗ ██████╗ ████████╗███████╗██╗ ███████╗ █████╗ ███████╗
55████╗ ██║██╔═══██╗╚══██╔══╝██╔════╝██║ ██╔════╝██╔══██╗██╔════╝
56██╔██╗ ██║██║ ██║ ██║ █████╗ ██║ █████╗ ███████║█████╗
57██║╚██╗██║██║ ██║ ██║ ██╔══╝ ██║ ██╔══╝ ██╔══██║██╔══╝
58██║ ╚████║╚██████╔╝ ██║ ███████╗███████╗███████╗██║ ██║██║
59╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝
60`
61
62//go:embed art/georgia.txt
63var georgia string
64
65func (l Logo) String() string {
66 switch l {
67 case Colossal:
68 return colossal
69 case Georgia:
70 return georgia
71 case Alligator:
72 return alligator
73 case ANSI:
74 return ansi
75 case ANSIShadow:
76 return ansiShadow
77 default:
78 return colossal
79 }
80}
81
82// Colored returns a colored version of the logo using lipgloss with vertical spiral design
83// Creates a vertical spiral effect by coloring character by character:
84//
85// Combine line position and character position & use modulo to build wave-like transitions
86func (l Logo) Colored() string {
87 logo := l.String()
88 lines := strings.Split(logo, "\n")
89
90 emeraldStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#10b981"))
91 skyStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#0284c7"))
92
93 var coloredLines []string
94 for lineIdx, line := range lines {
95 if strings.TrimSpace(line) == "" {
96 coloredLines = append(coloredLines, line)
97 continue
98 }
99
100 var coloredLine strings.Builder
101 for charIdx, char := range line {
102
103 spiralPos := (lineIdx*3 + charIdx) % 8
104
105 if spiralPos < 4 {
106 coloredLine.WriteString(emeraldStyle.Render(string(char)))
107 } else {
108 coloredLine.WriteString(skyStyle.Render(string(char)))
109 }
110 }
111
112 coloredLines = append(coloredLines, coloredLine.String())
113 }
114
115 return strings.Join(coloredLines, "\n")
116}
117
118// ColoredInViewport returns the colored logo rendered inside a viewport bubble
119func (l Logo) ColoredInViewport(renderer ...*lipgloss.Renderer) string {
120 coloredLogo := l.Colored()
121 lines := strings.Split(coloredLogo, "\n")
122
123 maxWidth := 0
124 for _, line := range lines {
125 stripped := lipgloss.Width(line)
126 if stripped > maxWidth {
127 maxWidth = stripped
128 }
129 }
130
131 vp := viewport.New(maxWidth+4, len(lines))
132 vp.SetContent(coloredLogo)
133
134 style := lipgloss.NewStyle().Border(lipgloss.RoundedBorder()).BorderForeground(lipgloss.Color("#6b7280")).PaddingLeft(1)
135
136 if len(renderer) > 0 && renderer[0] != nil {
137 style = style.Renderer(renderer[0])
138 }
139
140 return style.Render(vp.View())
141}