Skip to content

Commit 9996a96

Browse files
engalarako
authored andcommitted
feat(tui): responsive three-column layout with status bar
1 parent 585ac9d commit 9996a96

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

tui/layout.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package tui
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/charmbracelet/lipgloss"
7+
)
8+
9+
// columnWidths returns [modulesW, elementsW, previewW] given total terminal width.
10+
func columnWidths(totalW int) (int, int, int) {
11+
// Reserve 2 chars per border (left+right) × 3 columns = 6
12+
available := totalW - 6
13+
if available < 30 {
14+
available = 30
15+
}
16+
modulesW := available * 20 / 100
17+
elementsW := available * 30 / 100
18+
previewW := available - modulesW - elementsW
19+
return modulesW, elementsW, previewW
20+
}
21+
22+
// renderLayout assembles the three panels + status bar into the full screen.
23+
func renderLayout(
24+
totalW int,
25+
modulesView, elementsView, previewView string,
26+
statusLine string,
27+
) string {
28+
status := lipgloss.NewStyle().
29+
Background(lipgloss.Color("236")).
30+
Foreground(lipgloss.Color("252")).
31+
Width(totalW).
32+
Render(statusLine)
33+
34+
cols := lipgloss.JoinHorizontal(lipgloss.Top, modulesView, elementsView, previewView)
35+
36+
return fmt.Sprintf("%s\n%s", cols, status)
37+
}

0 commit comments

Comments
 (0)