wip: multiple profiles (drop colours also)

This commit is contained in:
2023-07-16 10:21:35 +02:00
parent d926f3888a
commit 115aad7b37
4 changed files with 27 additions and 10 deletions

View File

@ -13,8 +13,7 @@ const (
) )
var mainStyle = lipgloss.NewStyle(). var mainStyle = lipgloss.NewStyle().
BorderStyle(lipgloss.NormalBorder()). BorderStyle(lipgloss.NormalBorder())
BorderForeground(lipgloss.Color("#F7B3DA"))
type mainModel struct { type mainModel struct {
username string username string
@ -39,7 +38,7 @@ func NewMainModel(username, homeDir string) mainModel {
// TODO(d1): programmatically fill in profile names // TODO(d1): programmatically fill in profile names
profileBarModel := newProfileBarModel([]string{ profileBarModel := newProfileBarModel([]string{
"status", "status", "profile1", "profile2", "profile3",
}) })
statusPaneModel := newStatusPaneModel() statusPaneModel := newStatusPaneModel()

View File

@ -7,9 +7,10 @@ import (
"github.com/charmbracelet/lipgloss" "github.com/charmbracelet/lipgloss"
) )
var profileBarStyle = lipgloss.NewStyle(). var profileNameButtonStyle = lipgloss.NewStyle().
BorderStyle(lipgloss.NormalBorder()). BorderStyle(lipgloss.NormalBorder()).
MarginLeft(1) Padding(0, 1).
Bold(true)
type profileBarModel struct { type profileBarModel struct {
state int state int
@ -33,8 +34,8 @@ func (m profileBarModel) Init() tea.Cmd {
} }
func (m profileBarModel) Update(msg tea.Msg) (profileBarModel, tea.Cmd) { func (m profileBarModel) Update(msg tea.Msg) (profileBarModel, tea.Cmd) {
// TODO(d1): bubblezone handle clicks, fire msgs to mainModel to switch
switch msg := msg.(type) { switch msg := msg.(type) {
//TODO(d1): bubblezone handle clicks, fire msgs to mainModel to switch
case tea.WindowSizeMsg: case tea.WindowSizeMsg:
m.width = msg.Width m.width = msg.Width
} }
@ -43,7 +44,26 @@ func (m profileBarModel) Update(msg tea.Msg) (profileBarModel, tea.Cmd) {
func (m profileBarModel) View() string { func (m profileBarModel) View() string {
body := strings.Builder{} body := strings.Builder{}
//TODO(d1): render profile names, nice colours etc.
body.WriteString(profileBarStyle.Render("...profileBar...")) var profileNames []string
for idx, profileName := range m.profileNames {
rendered := profileNameButtonStyle.Render(profileName)
if idx > 0 {
rendered = profileNameButtonStyle.
MarginLeft(1).
Render(profileName)
}
profileNames = append(profileNames, rendered)
}
body.WriteString(
lipgloss.JoinHorizontal(
lipgloss.Left,
profileNames...,
),
)
return body.String() return body.String()
} }

View File

@ -10,7 +10,6 @@ import (
var viewportStyle = lipgloss.NewStyle(). var viewportStyle = lipgloss.NewStyle().
BorderStyle(lipgloss.NormalBorder()). BorderStyle(lipgloss.NormalBorder()).
BorderForeground(lipgloss.Color("#BBFFFF")).
MarginLeft(1) MarginLeft(1)
type statusPaneModel struct { type statusPaneModel struct {

View File

@ -13,7 +13,6 @@ var titleStyle = lipgloss.NewStyle().
Bold(true) Bold(true)
var backgroundStyle = lipgloss.NewStyle(). var backgroundStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#EE00EE")).
Align(lipgloss.Center) Align(lipgloss.Center)
type titleModel struct { type titleModel struct {