Skip to content

Commit 14623e3

Browse files
committed
Use more idiomatic way of defining header
1 parent 61c2454 commit 14623e3

1 file changed

Lines changed: 31 additions & 16 deletions

File tree

internal/ui/components/header.go

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
package components
22

3-
import "github.com/localstack/lstk/internal/ui/styles"
3+
import (
4+
"strings"
45

6+
"github.com/charmbracelet/lipgloss"
7+
"github.com/localstack/lstk/internal/ui/styles"
8+
)
9+
10+
const headerPadding = 3
11+
12+
// nimbo logo lines with relative offsets for the cloud shape
513
func nimboLine1() string {
6-
return " " +
14+
return " " +
715
styles.NimboDark.Render("▟") +
8-
styles.NimboLight.Render("████▖") +
9-
" "
16+
styles.NimboLight.Render("████▖")
1017
}
1118

1219
func nimboLine2() string {
13-
return " " +
14-
styles.NimboMid.Render("▟") +
20+
return styles.NimboMid.Render("▟") +
1521
styles.NimboLight.Render("██▙█▙█") +
16-
styles.NimboMid.Render("▟") +
17-
" "
22+
styles.NimboMid.Render("▟")
1823
}
1924

2025
func nimboLine3() string {
21-
return " " +
22-
styles.NimboDark.Render("▀▛▀▛▀") +
23-
" "
26+
return " " +
27+
styles.NimboDark.Render("▀▛▀▛▀")
2428
}
2529

2630
type Header struct {
@@ -32,10 +36,21 @@ func NewHeader(version string) Header {
3236
}
3337

3438
func (h Header) View() string {
35-
title := styles.Title.Render("LocalStack (lstk)")
36-
version := styles.Version.Render(h.version)
39+
logoStyle := lipgloss.NewStyle().PaddingLeft(headerPadding)
40+
41+
nimbo := logoStyle.Render(lipgloss.JoinVertical(lipgloss.Left,
42+
nimboLine1(),
43+
nimboLine2(),
44+
nimboLine3(),
45+
))
46+
47+
text := lipgloss.JoinVertical(lipgloss.Left,
48+
styles.Title.Render("LocalStack (lstk)"),
49+
styles.Version.Render(h.version),
50+
"",
51+
)
52+
53+
spacer := strings.Repeat(" ", headerPadding)
3754

38-
return "\n" + nimboLine1() + " " + title + "\n" +
39-
nimboLine2() + " " + version + "\n" +
40-
nimboLine3() + "\n"
55+
return "\n" + lipgloss.JoinHorizontal(lipgloss.Top, nimbo, spacer, text) + "\n"
4156
}

0 commit comments

Comments
 (0)