From c7e890cfe7117547d205f4b64105d79480f932a9 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Fri, 8 Jul 2022 20:12:32 -0700 Subject: [PATCH] chore: adjust top-level tab style --- ui/components/tabs/tabs.go | 7 +++++++ ui/pages/selection/selection.go | 26 ++++++++------------------ ui/styles/styles.go | 16 ++++++++++++++-- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/ui/components/tabs/tabs.go b/ui/components/tabs/tabs.go index 4fdb9b1d76207f485120848555311b47692b7675..c893b92624bdf54e25bef38d4d60c1c16b410035 100644 --- a/ui/components/tabs/tabs.go +++ b/ui/components/tabs/tabs.go @@ -22,6 +22,8 @@ type Tabs struct { TabSeparator lipgloss.Style TabInactive lipgloss.Style TabActive lipgloss.Style + TabDot lipgloss.Style + UseDot bool } // New creates a new Tabs component. @@ -76,8 +78,13 @@ func (t *Tabs) View() string { sep := t.TabSeparator for i, tab := range t.tabs { style := t.TabInactive.Copy() + prefix := " " if i == t.activeTab { style = t.TabActive.Copy() + prefix = t.TabDot.Render("• ") + } + if t.UseDot { + s.WriteString(prefix) } s.WriteString(style.Render(tab)) if i != len(t.tabs)-1 { diff --git a/ui/pages/selection/selection.go b/ui/pages/selection/selection.go index 47ea1624548983b1c284ecc92436ab7686dc402b..0e965a7f7006f2c51f9a5c08f199e93a61e00aba 100644 --- a/ui/pages/selection/selection.go +++ b/ui/pages/selection/selection.go @@ -52,14 +52,10 @@ func New(cfg *config.Config, pk ssh.PublicKey, common common.Common) *Selection } t := tabs.New(common, ts) t.TabSeparator = lipgloss.NewStyle() - t.TabInactive = lipgloss.NewStyle(). - Bold(true). - UnsetBackground(). - Foreground(common.Styles.InactiveBorderColor). - Padding(0, 1) - t.TabActive = t.TabInactive.Copy(). - Background(lipgloss.Color("62")). - Foreground(lipgloss.Color("230")) + t.TabInactive = common.Styles.TopLevelTabNormal.Copy() + t.TabActive = common.Styles.TopLevelActiveTab.Copy() + t.TabDot = common.Styles.TopLevelActiveTabDot.Copy() + t.UseDot = true sel := &Selection{ cfg: cfg, pk: pk, @@ -86,9 +82,7 @@ func (s *Selection) getMargins() (wm, hm int) { hm = s.common.Styles.Tabs.GetVerticalFrameSize() + s.common.Styles.Tabs.GetHeight() + 2 // tabs margin see View() - switch s.activePane { - case selectorPane: - case readmePane: + if s.activePane == readmePane { hm += 1 // readme statusbar } return @@ -303,15 +297,11 @@ func (s *Selection) View() string { Width(s.common.Width - wm). Foreground(s.common.Styles.InactiveBorderColor). Render(status) - view = rs.Render(lipgloss.JoinVertical(lipgloss.Top, + view = rs.Render(lipgloss.JoinVertical(lipgloss.Left, s.readme.View(), readmeStatus, )) } - ts := s.common.Styles.Tabs.Copy(). - MarginBottom(1) - return lipgloss.JoinVertical(lipgloss.Top, - ts.Render(s.tabs.View()), - view, - ) + ts := s.common.Styles.Tabs.Copy() + return lipgloss.JoinVertical(lipgloss.Left, ts.Render(s.tabs.View()), view) } diff --git a/ui/styles/styles.go b/ui/styles/styles.go index 9d0883991ae4187564e43b1563a2fe409a66312d..5b079bbfb0c20d7f1a36fef2b3ae16e3567aa220 100644 --- a/ui/styles/styles.go +++ b/ui/styles/styles.go @@ -12,8 +12,11 @@ type Styles struct { ActiveBorderColor lipgloss.Color InactiveBorderColor lipgloss.Color - App lipgloss.Style - ServerName lipgloss.Style + App lipgloss.Style + ServerName lipgloss.Style + TopLevelNormalTab lipgloss.Style + TopLevelActiveTab lipgloss.Style + TopLevelActiveTabDot lipgloss.Style MenuItem lipgloss.Style MenuLastUpdate lipgloss.Style @@ -142,6 +145,15 @@ func DefaultStyles() *Styles { Foreground(lipgloss.Color("229")). Bold(true) + s.TopLevelNormalTab = lipgloss.NewStyle(). + MarginRight(2) + + s.TopLevelActiveTab = s.TopLevelNormalTab.Copy(). + Foreground(lipgloss.Color("42")) + + s.TopLevelActiveTabDot = lipgloss.NewStyle(). + Foreground(lipgloss.Color("29")) + s.MenuItem = lipgloss.NewStyle(). PaddingLeft(1). Border(lipgloss.Border{