Diff
1diff --git a/tui/bubble.go b/tui/bubble.go
2index 76d27945d8df3d226ff5624411f674d098feb862..8528c864e0b5244431ddfb5c91b083f6b202fb8b 100644
3--- a/tui/bubble.go
4+++ b/tui/bubble.go
5@@ -101,6 +101,13 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
6 case tea.WindowSizeMsg:
7 b.width = msg.Width
8 b.height = msg.Height
9+ if b.state == loadedState {
10+ ab, cmd := b.boxes[b.activeBox].Update(msg)
11+ b.boxes[b.activeBox] = ab
12+ if cmd != nil {
13+ cmds = append(cmds, cmd)
14+ }
15+ }
16 case selection.SelectedMsg:
17 b.activeBox = 1
18 rb := b.repoMenu[msg.Index].bubble
19@@ -121,29 +128,40 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
20 return b, tea.Batch(cmds...)
21 }
22
23-func (b *Bubble) viewForBox(i int, width int) string {
24+func (b *Bubble) viewForBox(i int, width int, height int) string {
25 var ls lipgloss.Style
26 if i == b.activeBox {
27- ls = activeBoxStyle.Width(width)
28+ ls = activeBoxStyle.Copy()
29 } else {
30- ls = inactiveBoxStyle.Width(width)
31+ ls = inactiveBoxStyle.Copy()
32+ }
33+ ls.Width(width)
34+ if height > 0 {
35+ ls.Height(height).MarginBottom(2)
36 }
37 return ls.Render(b.boxes[i].View())
38 }
39
40 func (b *Bubble) View() string {
41- h := headerStyle.Width(b.width - horizontalPadding).Render(b.config.Name)
42- f := footerStyle.Render("")
43+ w := b.width - 3
44+ f := ""
45 s := ""
46 content := ""
47+ h := headerStyle.Width(w - 2).Render(b.config.Name)
48+ f += footerHighlightStyle.Bold(true).Render("tab ")
49+ f += footerStyle.Render("section • ")
50+ f += footerHighlightStyle.Bold(true).Render("j/k ")
51+ f += footerStyle.Render("down/up • ")
52+ f += footerHighlightStyle.Bold(true).Render("q ")
53+ f += footerStyle.Render("quit")
54 switch b.state {
55 case loadedState:
56- lb := b.viewForBox(0, boxLeftWidth)
57- rb := b.viewForBox(1, boxRightWidth)
58+ lb := b.viewForBox(0, boxLeftWidth, 0)
59+ rb := b.viewForBox(1, b.width-boxLeftWidth-10, b.height-8)
60 s += lipgloss.JoinHorizontal(lipgloss.Top, lb, rb)
61 case errorState:
62 s += errorStyle.Render(fmt.Sprintf("Bummer: %s", b.error))
63 }
64- content = h + "\n\n" + s + "\n" + f
65- return appBoxStyle.Render(content)
66+ content = h + "\n" + s + "\n" + f
67+ return appBoxStyle.Width(w).Height(b.height - 2).BorderStyle(lipgloss.RoundedBorder()).Render(content)
68 }
69diff --git a/tui/bubbles/repo/bubble.go b/tui/bubbles/repo/bubble.go
70index be50cfeaff4975c0cb3aa0de59e401cf7ce5b16d..8c30c60680e66d7d348a53d81589e46267917b0a 100644
71--- a/tui/bubbles/repo/bubble.go
72+++ b/tui/bubbles/repo/bubble.go
73@@ -20,17 +20,26 @@ type Bubble struct {
74 name string
75 repo *git.Repo
76 readmeViewport *ViewportBubble
77+ readme string
78+ height int
79+ heightMargin int
80+ width int
81+ widthMargin int
82 }
83
84-func NewBubble(rs *git.RepoSource, name string, width int, height int, tmp interface{}) *Bubble {
85+func NewBubble(rs *git.RepoSource, name string, width, wm, height, hm int, tmp interface{}) *Bubble {
86 return &Bubble{
87 templateObject: tmp,
88 repoSource: rs,
89 name: name,
90+ height: height,
91+ width: width,
92+ heightMargin: hm,
93+ widthMargin: wm,
94 readmeViewport: &ViewportBubble{
95 Viewport: &viewport.Model{
96- Width: width,
97- Height: height,
98+ Width: width - wm,
99+ Height: height - hm,
100 },
101 },
102 }
103@@ -42,6 +51,16 @@ func (b *Bubble) Init() tea.Cmd {
104
105 func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
106 var cmds []tea.Cmd
107+ switch msg := msg.(type) {
108+ case tea.WindowSizeMsg:
109+ b.readmeViewport.Viewport.Width = msg.Width - b.widthMargin
110+ b.readmeViewport.Viewport.Height = msg.Height - b.heightMargin
111+ md, err := b.glamourize(b.readme)
112+ if err != nil {
113+ return b, nil
114+ }
115+ b.readmeViewport.Viewport.SetContent(md)
116+ }
117 rv, cmd := b.readmeViewport.Update(msg)
118 b.readmeViewport = rv.(*ViewportBubble)
119 if cmd != nil {
120@@ -73,12 +92,13 @@ func (b *Bubble) setupCmd() tea.Msg {
121 return ErrMsg{err}
122 }
123 }
124+ b.readme = md
125 md, err = b.glamourize(md)
126 if err != nil {
127 return ErrMsg{err}
128 }
129- b.GotoTop()
130 b.readmeViewport.Viewport.SetContent(md)
131+ b.GotoTop()
132 return nil
133 }
134
135@@ -97,9 +117,10 @@ func (b *Bubble) templatize(mdt string) (string, error) {
136
137 func (b *Bubble) glamourize(md string) (string, error) {
138 tr, err := glamour.NewTermRenderer(
139- glamour.WithAutoStyle(),
140- glamour.WithWordWrap(b.readmeViewport.Viewport.Width),
141+ glamour.WithStandardStyle("dark"),
142+ glamour.WithWordWrap(b.width-b.widthMargin),
143 )
144+
145 if err != nil {
146 return "", err
147 }
148diff --git a/tui/bubbles/repo/style.go b/tui/bubbles/repo/style.go
149deleted file mode 100644
150index 2789bdad3b05efe1bbcd4e77c8b416fc54847b4a..0000000000000000000000000000000000000000
151--- a/tui/bubbles/repo/style.go
152+++ /dev/null
153@@ -1,25 +0,0 @@
154-package repo
155-
156-import (
157- "github.com/charmbracelet/lipgloss"
158-)
159-
160-var commitBoxStyle = lipgloss.NewStyle().
161- Foreground(lipgloss.Color("#FFFFFF")).
162- BorderStyle(lipgloss.RoundedBorder()).
163- BorderForeground(lipgloss.Color("#670083")).
164- Padding(1)
165-var commitRepoNameStyle = lipgloss.NewStyle().
166- Foreground(lipgloss.Color("#8922A5"))
167-var commitAuthorStyle = lipgloss.NewStyle().
168- Foreground(lipgloss.Color("#670083"))
169-var commitAuthorEmailStyle = lipgloss.NewStyle().
170- Foreground(lipgloss.Color("#781194"))
171-var commitDateStyle = lipgloss.NewStyle().
172- Foreground(lipgloss.Color("#781194"))
173-var commitCommentStyle = lipgloss.NewStyle().
174- Foreground(lipgloss.Color("#606060")).
175- BorderStyle(lipgloss.Border{Left: ">"}).
176- PaddingLeft(1).
177- PaddingBottom(0).
178- Margin(0)
179diff --git a/tui/commands.go b/tui/commands.go
180index d249c2077e180d5f0ccf33912b9d736cd6042dcc..68f54fd6b2765436a897c948087f23babff971ec 100644
181--- a/tui/commands.go
182+++ b/tui/commands.go
183@@ -45,13 +45,11 @@ func (b *Bubble) setupCmd() tea.Msg {
184 }
185 }
186 var tmplConfig *Config
187- h := b.height - verticalPadding - viewportHeightConstant
188- w := boxRightWidth - 2
189 for _, me := range mes {
190 if me.Repo == "config" {
191 tmplConfig = b.config
192 }
193- rb := repo.NewBubble(b.repoSource, me.Repo, w, h, tmplConfig)
194+ rb := repo.NewBubble(b.repoSource, me.Repo, b.width, boxLeftWidth+12, b.height, 12, tmplConfig)
195 initCmd := rb.Init()
196 msg := initCmd()
197 switch msg := msg.(type) {
198diff --git a/tui/style.go b/tui/style.go
199index 7787deaa80d34c32041c74c752455616941365b7..1a45f6c4c55cd84194312ac59f50c164ca00cb41 100644
200--- a/tui/style.go
201+++ b/tui/style.go
202@@ -39,10 +39,10 @@ var normalStyle = lipgloss.NewStyle().
203 Foreground(lipgloss.Color("#FFFFFF"))
204
205 var footerStyle = lipgloss.NewStyle().
206- BorderForeground(lipgloss.Color("#6D6D6D")).
207- BorderLeft(true).
208- Foreground(lipgloss.Color("#373737")).
209- Bold(true)
210+ Foreground(lipgloss.Color("#373737"))
211+
212+var footerHighlightStyle = lipgloss.NewStyle().
213+ Foreground(lipgloss.Color("#DCDCDC"))
214
215 var errorStyle = lipgloss.NewStyle().
216 Foreground(lipgloss.Color("#FF00000"))