e939038287b20163f364e78e9557d05fe976bbcf

Author
Christian Rocha <christian@rocha.is>
Committer
Christian Rocha <christian@rocha.is>
Date

Message

Add application-level margin

Diff

  1diff --git a/tui/bubble.go b/tui/bubble.go
  2index 3cbd1cb3e4e07b37cf0e3ad29ff4182a1e01d36f..a699c89349723e923ad54e0549e1bb1fbe38ce77 100644
  3--- a/tui/bubble.go
  4+++ b/tui/bubble.go
  5@@ -142,37 +142,36 @@ func (b *Bubble) viewForBox(i int) string {
  6 	box := b.boxes[i]
  7 	isActive := i == b.activeBox
  8 	var s lipgloss.Style
  9-	var menuHeightFix int // TODO: figure out why we need this
 10 	switch box.(type) {
 11 	case *selection.Bubble:
 12-		menuHeightFix = 1
 13 		if isActive {
 14 			s = menuActiveStyle
 15-			break
 16+		} else {
 17+			s = menuStyle
 18 		}
 19-		s = menuStyle
 20+		h := b.height -
 21+			lipgloss.Height(b.headerView()) -
 22+			lipgloss.Height(b.footerView()) -
 23+			s.GetVerticalFrameSize() -
 24+			appBoxStyle.GetVerticalFrameSize() +
 25+			1 // TODO: figure out why we need this
 26+		s = s.Copy().Height(h)
 27 	case *repo.Bubble:
 28 		if isActive {
 29 			s = contentBoxActiveStyle
 30 		} else {
 31 			s = contentBoxStyle
 32 		}
 33-		const repoWidthFix = 1 // TODO: figure out why we need this
 34 		w := b.width -
 35 			lipgloss.Width(b.viewForBox(0)) -
 36 			appBoxStyle.GetHorizontalFrameSize() -
 37-			s.GetHorizontalFrameSize() + repoWidthFix
 38+			s.GetHorizontalFrameSize() +
 39+			1 // TODO: figure out why we need this
 40 		s = s.Copy().Width(w)
 41 	default:
 42 		panic(fmt.Sprintf("unknown box type %T", box))
 43 	}
 44-	h := b.height -
 45-		lipgloss.Height(b.headerView()) -
 46-		lipgloss.Height(b.footerView()) -
 47-		s.GetVerticalFrameSize() -
 48-		appBoxStyle.GetVerticalFrameSize() +
 49-		menuHeightFix
 50-	return s.Copy().Height(h).Render(box.View())
 51+	return s.Render(box.View())
 52 }
 53 
 54 func (b Bubble) headerView() string {
 55@@ -202,7 +201,7 @@ func (b Bubble) footerView() string {
 56 			fmt.Fprint(w, helpDivider)
 57 		}
 58 	}
 59-	return footerStyle.Render(w.String())
 60+	return footerStyle.Copy().Width(b.width).Render(w.String())
 61 }
 62 
 63 func (b Bubble) errorView() string {
 64@@ -232,6 +231,7 @@ func (b Bubble) View() string {
 65 	case errorState:
 66 		s.WriteString(b.errorView())
 67 	}
 68+	s.WriteRune('\n')
 69 	s.WriteString(b.footerView())
 70 	return appBoxStyle.Render(s.String())
 71 }
 72diff --git a/tui/commands.go b/tui/commands.go
 73index 173e1d89d2f47d0b6f0d6b8aea23291c703c6926..b8db6e08c3cc992a51698c9c008226389c272d42 100644
 74--- a/tui/commands.go
 75+++ b/tui/commands.go
 76@@ -53,7 +53,8 @@ func (b *Bubble) setupCmd() tea.Msg {
 77 		// TODO: also send this along with a tea.WindowSizeMsg
 78 		var heightMargin = lipgloss.Height(b.headerView()) +
 79 			lipgloss.Height(b.footerView()) +
 80-			contentBoxStyle.GetVerticalFrameSize()
 81+			contentBoxStyle.GetVerticalFrameSize() +
 82+			appBoxStyle.GetVerticalMargins()
 83 		rb := repo.NewBubble(b.repoSource, me.Repo, width, boxLeftWidth, b.height, heightMargin, tmplConfig)
 84 		initCmd := rb.Init()
 85 		msg := initCmd()
 86diff --git a/tui/style.go b/tui/style.go
 87index 8c419a7e4935a60d8c3be18f6e2a4d29b7500685..cd0f807a323eed3442a36cac67cffc7a0b911cde 100644
 88--- a/tui/style.go
 89+++ b/tui/style.go
 90@@ -7,11 +7,13 @@ import (
 91 var activeBorderColor = lipgloss.Color("62")
 92 var inactiveBorderColor = lipgloss.Color("236")
 93 
 94-var appBoxStyle = lipgloss.NewStyle()
 95+var appBoxStyle = lipgloss.NewStyle().
 96+	Margin(1, 2)
 97 
 98 var headerStyle = lipgloss.NewStyle().
 99 	Foreground(lipgloss.Color("62")).
100 	Align(lipgloss.Right).
101+	PaddingRight(1).
102 	Bold(true)
103 
104 var menuStyle = lipgloss.NewStyle().