-
Notifications
You must be signed in to change notification settings - Fork 0
/
DefBar.go
67 lines (55 loc) · 1.28 KB
/
DefBar.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"strings"
"github.com/charmbracelet/lipgloss"
)
func max(a, b int) int {
if a > b {
return a
} else {
return b
}
}
func RenderBar() string {
highlight := lipgloss.AdaptiveColor{Light: "#8E3ED7", Dark: "#7F21D7"}
width := 72
activeTabBorder := lipgloss.Border {
Top: "─",
Bottom: " ",
Left: "│",
Right: "│",
TopLeft: "╭",
TopRight: "╮",
BottomLeft: "┘",
BottomRight: "└",
}
tabBorder := lipgloss.Border {
Top: "─",
Bottom: "─",
Left: "│",
Right: "│",
TopLeft: "╭",
TopRight: "╮",
BottomLeft: "┴",
BottomRight: "┴",
}
tab := lipgloss.NewStyle().
Border(tabBorder, true).
BorderForeground(highlight).
Padding(0, 1)
activeTab := tab.Copy().Border(activeTabBorder, true)
tabGap := tab.Copy().
BorderTop(false).
BorderLeft(false).
BorderRight(false)
row := lipgloss.JoinHorizontal(
lipgloss.Top,
activeTab.Render("Fetch"),
tab.Render("Cats"),
tab.Render("Are"),
tab.Render("Cute"),
)
gap := tabGap.Render(strings.Repeat(" ", max(0, width-lipgloss.Width(row)-2)))
row = lipgloss.JoinHorizontal(lipgloss.Bottom, row, gap)
return row
}