Skip to content

Commit

Permalink
Status bar placement
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin-ward committed Feb 27, 2024
1 parent ee5c780 commit a1bbcee
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
10 changes: 9 additions & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
"strings"

tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/dustin-ward/termtyping/internal/character"
"github.com/dustin-ward/termtyping/internal/data"
"github.com/dustin-ward/termtyping/internal/statusbar"
"github.com/dustin-ward/termtyping/internal/styles"
)

Expand All @@ -24,6 +26,8 @@ type AppModel struct {
text string
pos int
quitting bool

status_bar statusbar.StatusBarModel
}

// Number of words to use per each test
Expand Down Expand Up @@ -112,5 +116,9 @@ func (m AppModel) View() string {
view_text = b.String()
}

return styles.TextBox.Render(view_text)
return styles.BorderStyle.Render(lipgloss.JoinVertical(
lipgloss.Left,
styles.StatusBar.Render(m.status_bar.View()),
styles.TextBox.Render(view_text),
))
}
18 changes: 18 additions & 0 deletions internal/statusbar/status_bar.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package statusbar

import tea "github.com/charmbracelet/bubbletea"

type StatusBarModel struct {
}

func (m StatusBarModel) Init() tea.Cmd {
return nil
}

func (m StatusBarModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, nil
}

func (m StatusBarModel) View() string {
return "TEST"
}
4 changes: 3 additions & 1 deletion internal/styles/styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ var (
RemainingText = lipgloss.NewStyle().Foreground(LightGrey)
ActiveText = lipgloss.NewStyle().Foreground(White)

TextBox = lipgloss.NewStyle().BorderStyle(lipgloss.RoundedBorder()).Width(APP_WIDTH).Padding(1, 2).Margin(0, 2).Foreground(White)
TextBox = lipgloss.NewStyle().Width(APP_WIDTH).Margin(0, 2)
StatusBar = lipgloss.NewStyle().Width(APP_WIDTH).Margin(0, 2).Border(lipgloss.NormalBorder()).BorderForeground(LightGrey).BorderTop(false).BorderLeft(false).BorderRight(false)
BorderStyle = lipgloss.NewStyle().BorderStyle(lipgloss.RoundedBorder()).Foreground(White)
)

0 comments on commit a1bbcee

Please sign in to comment.