From 17bf5843492860d1d31b41f90b228534f9f59292 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Tue, 8 Nov 2022 12:51:33 -0500 Subject: [PATCH] fix(ui): hide tabs while filtering Fixes: https://github.com/charmbracelet/soft-serve/issues/172 --- ui/pages/repo/repo.go | 4 +--- ui/pages/selection/selection.go | 19 ++++++++++++------- ui/styles/styles.go | 3 ++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ui/pages/repo/repo.go b/ui/pages/repo/repo.go index 6469fe6d4..808ae9286 100644 --- a/ui/pages/repo/repo.go +++ b/ui/pages/repo/repo.go @@ -111,9 +111,7 @@ func (r *Repo) SetSize(width, height int) { hm := r.common.Styles.Repo.Body.GetVerticalFrameSize() + r.common.Styles.Repo.Header.GetHeight() + r.common.Styles.Repo.Header.GetVerticalFrameSize() + - r.common.Styles.StatusBar.GetHeight() + - r.common.Styles.Tabs.GetHeight() + - r.common.Styles.Tabs.GetVerticalFrameSize() + r.common.Styles.StatusBar.GetHeight() r.tabs.SetSize(width, height-hm) r.statusbar.SetSize(width, height-hm) for _, p := range r.panes { diff --git a/ui/pages/selection/selection.go b/ui/pages/selection/selection.go index 52cd06cc5..c0957fcdd 100644 --- a/ui/pages/selection/selection.go +++ b/ui/pages/selection/selection.go @@ -81,10 +81,10 @@ func New(cfg *config.Config, pk ssh.PublicKey, common common.Common) *Selection func (s *Selection) getMargins() (wm, hm int) { wm = 0 hm = s.common.Styles.Tabs.GetVerticalFrameSize() + - s.common.Styles.Tabs.GetHeight() + - 2 // tabs margin see View() - if s.activePane == readmePane { - hm += 1 // readme statusbar + s.common.Styles.Tabs.GetHeight() + if s.activePane == selectorPane && s.FilterState() == list.Filtering { + // hide tabs when filtering + hm = 0 } return } @@ -100,7 +100,7 @@ func (s *Selection) SetSize(width, height int) { wm, hm := s.getMargins() s.tabs.SetSize(width, height-hm) s.selector.SetSize(width-wm, height-hm) - s.readme.SetSize(width-wm, height-hm) + s.readme.SetSize(width-wm, height-hm-1) // -1 for readme status line } // ShortHelp implements help.KeyMap. @@ -287,7 +287,6 @@ func (s *Selection) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (s *Selection) View() string { var view string wm, hm := s.getMargins() - hm++ // tabs margin switch s.activePane { case selectorPane: ss := lipgloss.NewStyle(). @@ -308,9 +307,15 @@ func (s *Selection) View() string { readmeStatus, )) } + if s.activePane != selectorPane || s.FilterState() != list.Filtering { + tabs := s.common.Styles.Tabs.Render(s.tabs.View()) + view = lipgloss.JoinVertical(lipgloss.Left, + tabs, + view, + ) + } return lipgloss.JoinVertical( lipgloss.Left, - s.common.Styles.Tabs.Render(s.tabs.View()), view, ) } diff --git a/ui/styles/styles.go b/ui/styles/styles.go index a55a28f2d..4e1c14440 100644 --- a/ui/styles/styles.go +++ b/ui/styles/styles.go @@ -439,7 +439,8 @@ func DefaultStyles() *Styles { Background(lipgloss.Color("237")). Foreground(lipgloss.Color("243")) - s.Tabs = lipgloss.NewStyle() + s.Tabs = lipgloss.NewStyle(). + Height(1) s.TabInactive = lipgloss.NewStyle()