Change style package, new components, ...

Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-08-18 20:10:32 +02:00
parent 499d61bddf
commit 21b574eb6f
56 changed files with 2741 additions and 363 deletions
+48
View File
@@ -0,0 +1,48 @@
package main
import (
"fmt"
"os"
"charm.land/bubbles/v2/spinner"
"charm.land/bubbles/v2/textinput"
tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
"github.com/anotherhadi/ilovetui/bubbles"
)
type model struct {
input textinput.Model
spinner spinner.Model
}
func newModel() model {
ti := bubbles.NewTextInput()
ti.Placeholder = "type something"
ti.Focus()
return model{input: ti, spinner: bubbles.NewSpinner()}
}
func (m model) Init() tea.Cmd { return m.spinner.Tick }
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if k, ok := msg.(tea.KeyPressMsg); ok && k.String() == "ctrl+c" {
return m, tea.Quit
}
var inputCmd, spinnerCmd tea.Cmd
m.input, inputCmd = m.input.Update(msg)
m.spinner, spinnerCmd = m.spinner.Update(msg)
return m, tea.Batch(inputCmd, spinnerCmd)
}
func (m model) View() tea.View {
return tea.NewView(lipgloss.JoinHorizontal(lipgloss.Center, m.spinner.View(), " ", m.input.View()))
}
func main() {
if _, err := tea.NewProgram(newModel()).Run(); err != nil {
fmt.Println("Error running program:", err)
os.Exit(1)
}
}