Skip to content

Commit

Permalink
🚧 Add a flag to hide filter list border
Browse files Browse the repository at this point in the history
Future changes require the border of the filter list to be hidden.

This change defaults the border to being displayed to maintain
compatibility with existing components.
  • Loading branch information
mikelorant committed Feb 28, 2023
1 parent 559fc69 commit 5a3817e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/ui/filterlist/filterlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Model struct {
Height int
Width int
CharLimit int
Border bool

focus bool
state *commit.State
Expand All @@ -36,6 +37,7 @@ func New(state *commit.State) Model {
Height: defaultHeight,
Width: defaultWidth,
CharLimit: defaultCharLimit,
Border: true,
state: state,
styles: defaultStyles(state.Theme),
}
Expand Down Expand Up @@ -119,6 +121,10 @@ func (m Model) View() string {
p := m.styles.paginatorBoundary.Render(m.stylePaginatorColumn())
ep := lipgloss.JoinHorizontal(lipgloss.Top, e, p)

if !m.Border {
return ep
}

if m.focus || !m.state.Config.View.HighlightActive {
return m.styles.focusBoundary.Height(m.Height - 1).Render(ep)
}
Expand Down
17 changes: 17 additions & 0 deletions internal/ui/filterlist/filterlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,23 @@ func TestModel(t *testing.T) {
m.SetHeight(5)
m, _ = filterlist.ToModel(m.Update(nil))

return m
},
},
},
{
name: "no_border",
args: args{
items: []MockItem{
{title: "item 1"},
{title: "item 2"},
{title: "item 3"},
},
title: "test",
model: func(m filterlist.Model) filterlist.Model {
m.Border = false
m, _ = filterlist.ToModel(m.Update(nil))

return m
},
},
Expand Down
3 changes: 3 additions & 0 deletions internal/ui/filterlist/testdata/no_border.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
? test ●
❯ item 1 ○
item 2

0 comments on commit 5a3817e

Please sign in to comment.