chore(phase-0): struktur repo + hello TUI Bubble Tea v2 (T-0.1, T-0.2)

This commit is contained in:
oxpoe committed 2026-10-15 06:47:55 +07:00
1 parent ca45f67b0c
commit db75653e3d
8 files changed
+314

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
package app
import (
"fmt"
tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
)
// Model root sementara (T-0.2, Phase 0).
// Tujuannya membuktikan Bubble Tea v2 (View struct, mouse, resize) sebelum
// layout penuh Phase 1 menggantikannya.
type Model struct {
width, height int
clicks int
lastClick string
}
func New() Model {
return Model{lastClick: "belum ada klik"}
}
func (m Model) Init() tea.Cmd { return nil }
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.WindowSizeMsg:
m.width, m.height = msg.Width, msg.Height
case tea.KeyPressMsg:
switch msg.String() {
case "q", "ctrl+c", "esc":
return m, tea.Quit
}
case tea.MouseClickMsg:
if msg.Button == tea.MouseLeft {
m.clicks++
m.lastClick = fmt.Sprintf("klik #%d di (%d, %d)", m.clicks, msg.X, msg.Y)
}
}
return m, nil
}
func (m Model) View() tea.View {
title := lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#cba6f7")).
Render("tia — Terminal Is A My Way")
tagline := lipgloss.NewStyle().
Foreground(lipgloss.Color("#a6adc8")).
Render("Just Work · Phase 0 · skeleton TUI")
box := lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
BorderForeground(lipgloss.Color("#6c7086")).
Padding(0, 2).
Render(m.lastClick + "\n\nklik mouse di mana saja · tekan q untuk keluar")
content := fmt.Sprintf("%s\n%s\n\n%s\n\nukuran jendela: %dx%d",
title, tagline, box, m.width, m.height)
v := tea.NewView(content)
v.AltScreen = true
v.MouseMode = tea.MouseModeCellMotion
return v
}