summaryrefslogtreecommitdiff
path: root/pkg/ui/views/tabs.go
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2025-04-08 14:37:33 +0200
committerSanto Cariotti <santo@dcariotti.me>2025-04-08 14:39:13 +0200
commit1f0d9ec8452f15c27cd33c4e3874454c35993743 (patch)
treec453a31ae5eb823aaf48868eea9fc4daf65f108b /pkg/ui/views/tabs.go
parentc5b10e28b358308d8349b940af09f64368172f2e (diff)
Use internal/pkg structure
Diffstat (limited to 'pkg/ui/views/tabs.go')
-rw-r--r--pkg/ui/views/tabs.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/ui/views/tabs.go b/pkg/ui/views/tabs.go
new file mode 100644
index 0000000..13e3672
--- /dev/null
+++ b/pkg/ui/views/tabs.go
@@ -0,0 +1,32 @@
+package views
+
+import (
+ "fmt"
+
+ "github.com/charmbracelet/lipgloss"
+)
+
+type TabType int
+
+var (
+ tabStyle = lipgloss.NewStyle().Border(lipgloss.RoundedBorder()).BorderForeground(highlightColor).Padding(0, 2)
+ inactiveTabStyle = tabStyle
+ activeTabStyle = tabStyle
+)
+
+func getTabsRow(tabsText []string, activeTab TabType) string {
+ tabs := make([]string, len(tabsText))
+
+ for i, tab := range tabsText {
+ if TabType(i) == activeTab {
+ tabs[i] = fmt.Sprintf("%s %s", altCodeStyle.Render(fmt.Sprintf("Alt+%d", i+1)), lipgloss.NewStyle().Bold(true).Foreground(highlightColor).Render(tab))
+ tabs[i] = activeTabStyle.Foreground(highlightColor).Render(tabs[i])
+ } else {
+ tabs[i] = fmt.Sprintf("%s %s", altCodeStyle.Render(fmt.Sprintf("Alt+%d", i+1)), lipgloss.NewStyle().Render(tab))
+ tabs[i] = inactiveTabStyle.Foreground(highlightColor).Render(tabs[i])
+ }
+ }
+
+ return lipgloss.JoinHorizontal(lipgloss.Top, tabs...)
+
+}