ssm-browse: header styling

This commit is contained in:
Leon Mika 2022-03-30 22:52:26 +11:00
parent 798150a403
commit 1b8518b6e4
9 changed files with 76 additions and 28 deletions

View file

@ -10,21 +10,28 @@ import (
"github.com/lmika/awstools/internal/slog-view/models"
)
var (
activeHeaderStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#ffffff")).
Background(lipgloss.Color("#9c9c9c"))
)
type Model struct {
frameTitle frame.FrameTitle
viewport viewport.Model
w, h int
// model state
focused bool
selectedItem *models.LogLine
focused bool
selectedItem *models.LogLine
}
func New() *Model {
viewport := viewport.New(0, 0)
viewport.SetContent("")
return &Model{
frameTitle: frame.NewFrameTitle("Item", false),
frameTitle: frame.NewFrameTitle("Item", false, activeHeaderStyle),
viewport: viewport,
}
}

View file

@ -10,6 +10,13 @@ import (
"path/filepath"
)
var (
activeHeaderStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#ffffff")).
Background(lipgloss.Color("#9c9c9c"))
)
type Model struct {
frameTitle frame.FrameTitle
table table.Model
@ -20,12 +27,12 @@ type Model struct {
}
func New() *Model {
frameTitle := frame.NewFrameTitle("File: ", true)
frameTitle := frame.NewFrameTitle("File: ", true, activeHeaderStyle)
table := table.New([]string{"level", "error", "message"}, 0, 0)
return &Model{
frameTitle: frameTitle,
table: table,
table: table,
}
}
@ -92,7 +99,6 @@ func (m *Model) View() string {
func (m *Model) Resize(w, h int) layout.ResizingModel {
m.w, m.h = w, h
m.frameTitle.Resize(w, h)
m.table.SetSize(w, h - m.frameTitle.HeaderHeight())
m.table.SetSize(w, h-m.frameTitle.HeaderHeight())
return m
}