diff options
Diffstat (limited to 'internal/client/ui/ui.go')
| -rw-r--r-- | internal/client/ui/ui.go | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/internal/client/ui/ui.go b/internal/client/ui/ui.go index 425e6b1..b03df59 100644 --- a/internal/client/ui/ui.go +++ b/internal/client/ui/ui.go @@ -1,7 +1,41 @@ package ui -import tea "github.com/charmbracelet/bubbletea" +import ( + "fmt" + "strings" -type ModelTransition struct{ + tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/lipgloss" +) + +type ModelTransition struct { Model tea.Model } + +func AddBorderHeader(header string, headerOffset int, style lipgloss.Style, render string) string { + b := style.GetBorderStyle() + body := style.UnsetBorderTop().Render(render) + + bodyWidth, headerWidth := lipgloss.Width(body), lipgloss.Width(header) + leftCornerWidth, rightCornerWidth := lipgloss.Width(b.TopLeft), lipgloss.Width(b.TopRight) + topWidth := bodyWidth - leftCornerWidth - rightCornerWidth + + leftWidth := headerOffset + rightWidth := topWidth - leftWidth - headerWidth + + topStyle := lipgloss.NewStyle(). + Background(style.GetBorderTopBackground()). + Foreground(style.GetBorderTopForeground()) + + left := b.TopLeft + strings.Repeat(b.Top, leftWidth) + right := topStyle.Render(strings.Repeat(b.Top, rightWidth) + b.TopRight) + + borderTop := lipgloss.NewStyle(). + Inline(true). + MaxWidth(bodyWidth). + Background(style.GetBorderTopBackground()). + Foreground(style.GetBorderTopForeground()). + Render(fmt.Sprintf("%s%s%s", left, header, right)) + + return lipgloss.JoinVertical(lipgloss.Left, borderTop, body) +} |
