From 0b3479fc61764be89c7bad8ded9df801933e3c7f Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Wed, 2 Mar 2022 17:01:24 -0500 Subject: [PATCH] fix(tui): show error on empty readme and empty tree --- internal/tui/bubbles/git/about/bubble.go | 6 +++++- internal/tui/bubbles/git/tree/bubble.go | 1 + internal/tui/style/style.go | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/internal/tui/bubbles/git/about/bubble.go b/internal/tui/bubbles/git/about/bubble.go index 1bb36e9e071348ef856bb7879811f31f2e25ea0c..4740246b670a001a93b59c4425a34cc4820877c2 100644 --- a/internal/tui/bubbles/git/about/bubble.go +++ b/internal/tui/bubbles/git/about/bubble.go @@ -88,7 +88,11 @@ func (b *Bubble) Help() []types.HelpEntry { func (b *Bubble) glamourize() (string, error) { w := b.width - b.widthMargin - b.styles.RepoBody.GetHorizontalFrameSize() - return types.Glamourize(w, b.repo.GetReadme()) + rm := b.repo.GetReadme() + if rm == "" { + return b.styles.AboutNoReadme.Render("No readme found."), nil + } + return types.Glamourize(w, rm) } func (b *Bubble) setupCmd() tea.Msg { diff --git a/internal/tui/bubbles/git/tree/bubble.go b/internal/tui/bubbles/git/tree/bubble.go index 94c4b43eac5cd832b37a5c6fdbdadbc003b24c42..1876df204b6901eeed52f690d665fa8ef69f4d85 100644 --- a/internal/tui/bubbles/git/tree/bubble.go +++ b/internal/tui/bubbles/git/tree/bubble.go @@ -142,6 +142,7 @@ func NewBubble(repo types.Repo, styles *style.Styles, width, widthMargin, height l.DisableQuitKeybindings() l.KeyMap.NextPage = types.NextPage l.KeyMap.PrevPage = types.PrevPage + l.Styles.NoItems = styles.TreeNoItems b := &Bubble{ fileViewport: &vp.ViewportBubble{ Viewport: &viewport.Model{}, diff --git a/internal/tui/style/style.go b/internal/tui/style/style.go index e7c386fc4fa2cc00b05a3ca735dfc81d3afefb73..ab2063e27124d16bdf97126c87286ef01d38b3bf 100644 --- a/internal/tui/style/style.go +++ b/internal/tui/style/style.go @@ -40,6 +40,8 @@ type Styles struct { ErrorTitle lipgloss.Style ErrorBody lipgloss.Style + AboutNoReadme lipgloss.Style + LogItemSelector lipgloss.Style LogItemActive lipgloss.Style LogItemInactive lipgloss.Style @@ -67,6 +69,8 @@ type Styles struct { TreeFileMode lipgloss.Style TreeFileSize lipgloss.Style TreeFileContent lipgloss.Style + TreePaginator lipgloss.Style + TreeNoItems lipgloss.Style Spinner lipgloss.Style } @@ -193,6 +197,10 @@ func DefaultStyles() *Styles { MarginLeft(2). Width(52) // for now + s.AboutNoReadme = lipgloss.NewStyle(). + MarginLeft(1). + Foreground(lipgloss.Color("#626262")) + s.LogItemInactive = lipgloss.NewStyle(). MarginLeft(1) @@ -262,6 +270,10 @@ func DefaultStyles() *Styles { s.TreeFileContent = lipgloss.NewStyle() + s.TreePaginator = s.LogPaginator.Copy() + + s.TreeNoItems = s.AboutNoReadme.Copy() + s.Spinner = lipgloss.NewStyle(). MarginLeft(1). Foreground(lipgloss.Color("205"))