Skip to content

Commit

Permalink
Add application-level margin
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Aug 19, 2021
1 parent eabf167 commit e939038
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
28 changes: 14 additions & 14 deletions tui/bubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,37 +142,36 @@ func (b *Bubble) viewForBox(i int) string {
box := b.boxes[i]
isActive := i == b.activeBox
var s lipgloss.Style
var menuHeightFix int // TODO: figure out why we need this
switch box.(type) {
case *selection.Bubble:
menuHeightFix = 1
if isActive {
s = menuActiveStyle
break
} else {
s = menuStyle
}
s = menuStyle
h := b.height -
lipgloss.Height(b.headerView()) -
lipgloss.Height(b.footerView()) -
s.GetVerticalFrameSize() -
appBoxStyle.GetVerticalFrameSize() +
1 // TODO: figure out why we need this
s = s.Copy().Height(h)
case *repo.Bubble:
if isActive {
s = contentBoxActiveStyle
} else {
s = contentBoxStyle
}
const repoWidthFix = 1 // TODO: figure out why we need this
w := b.width -
lipgloss.Width(b.viewForBox(0)) -
appBoxStyle.GetHorizontalFrameSize() -
s.GetHorizontalFrameSize() + repoWidthFix
s.GetHorizontalFrameSize() +
1 // TODO: figure out why we need this
s = s.Copy().Width(w)
default:
panic(fmt.Sprintf("unknown box type %T", box))
}
h := b.height -
lipgloss.Height(b.headerView()) -
lipgloss.Height(b.footerView()) -
s.GetVerticalFrameSize() -
appBoxStyle.GetVerticalFrameSize() +
menuHeightFix
return s.Copy().Height(h).Render(box.View())
return s.Render(box.View())
}

func (b Bubble) headerView() string {
Expand Down Expand Up @@ -202,7 +201,7 @@ func (b Bubble) footerView() string {
fmt.Fprint(w, helpDivider)
}
}
return footerStyle.Render(w.String())
return footerStyle.Copy().Width(b.width).Render(w.String())
}

func (b Bubble) errorView() string {
Expand Down Expand Up @@ -232,6 +231,7 @@ func (b Bubble) View() string {
case errorState:
s.WriteString(b.errorView())
}
s.WriteRune('\n')
s.WriteString(b.footerView())
return appBoxStyle.Render(s.String())
}
Expand Down
3 changes: 2 additions & 1 deletion tui/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func (b *Bubble) setupCmd() tea.Msg {
// TODO: also send this along with a tea.WindowSizeMsg
var heightMargin = lipgloss.Height(b.headerView()) +
lipgloss.Height(b.footerView()) +
contentBoxStyle.GetVerticalFrameSize()
contentBoxStyle.GetVerticalFrameSize() +
appBoxStyle.GetVerticalMargins()
rb := repo.NewBubble(b.repoSource, me.Repo, width, boxLeftWidth, b.height, heightMargin, tmplConfig)
initCmd := rb.Init()
msg := initCmd()
Expand Down
4 changes: 3 additions & 1 deletion tui/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import (
var activeBorderColor = lipgloss.Color("62")
var inactiveBorderColor = lipgloss.Color("236")

var appBoxStyle = lipgloss.NewStyle()
var appBoxStyle = lipgloss.NewStyle().
Margin(1, 2)

var headerStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("62")).
Align(lipgloss.Right).
PaddingRight(1).
Bold(true)

var menuStyle = lipgloss.NewStyle().
Expand Down

0 comments on commit e939038

Please sign in to comment.