Skip to content

Commit

Permalink
fix(ui): hide tabs while filtering
Browse files Browse the repository at this point in the history
Fixes: #172
  • Loading branch information
aymanbagabas committed Nov 8, 2022
1 parent 6dbdb43 commit 17bf584
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 1 addition & 3 deletions ui/pages/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 12 additions & 7 deletions ui/pages/selection/selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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.
Expand Down Expand Up @@ -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().
Expand All @@ -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,
)
}
3 changes: 2 additions & 1 deletion ui/styles/styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 17bf584

Please sign in to comment.