Skip to content

Commit

Permalink
fix(tui): show error on empty readme and empty tree
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Mar 3, 2022
1 parent 8a57c24 commit 0b3479f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/tui/bubbles/git/about/bubble.go
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions internal/tui/bubbles/git/tree/bubble.go
Expand Up @@ -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{},
Expand Down
12 changes: 12 additions & 0 deletions internal/tui/style/style.go
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"))
Expand Down

0 comments on commit 0b3479f

Please sign in to comment.