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

@ -14,6 +14,13 @@ import (
"github.com/lmika/awstools/internal/dynamo-browse/ui/teamodels/layout"
)
var (
activeHeaderStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#ffffff")).
Background(lipgloss.Color("#4479ff"))
)
type Model struct {
ready bool
frameTitle frame.FrameTitle
@ -27,7 +34,7 @@ type Model struct {
func New() *Model {
return &Model{
frameTitle: frame.NewFrameTitle("Item", false),
frameTitle: frame.NewFrameTitle("Item", false, activeHeaderStyle),
viewport: viewport.New(100, 100),
}
}

View file

@ -11,6 +11,13 @@ import (
"github.com/lmika/awstools/internal/dynamo-browse/ui/teamodels/layout"
)
var (
activeHeaderStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#ffffff")).
Background(lipgloss.Color("#4479ff"))
)
type Model struct {
frameTitle frame.FrameTitle
table table.Model
@ -26,7 +33,7 @@ func New() *Model {
rows := make([]table.Row, 0)
tbl.SetRows(rows)
frameTitle := frame.NewFrameTitle("No table", true)
frameTitle := frame.NewFrameTitle("No table", true, activeHeaderStyle)
return &Model{
frameTitle: frameTitle,

View file

@ -8,11 +8,6 @@ import (
)
var (
activeHeaderStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#ffffff")).
Background(lipgloss.Color("#4479ff"))
inactiveHeaderStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#000000")).
Background(lipgloss.Color("#d1d1d1"))
@ -22,11 +17,12 @@ var (
type FrameTitle struct {
header string
active bool
activeStyle lipgloss.Style
width int
}
func NewFrameTitle(header string, active bool) FrameTitle {
return FrameTitle{header, active, 0}
func NewFrameTitle(header string, active bool, activeStyle lipgloss.Style) FrameTitle {
return FrameTitle{header, active, activeStyle, 0}
}
func (f *FrameTitle) SetTitle(title string) {
@ -48,7 +44,7 @@ func (f FrameTitle) HeaderHeight() int {
func (f FrameTitle) headerView() string {
style := inactiveHeaderStyle
if f.active {
style = activeHeaderStyle
style = f.activeStyle
}
titleText := f.header

View file

@ -25,6 +25,11 @@ func newListController(tableNames []string, w, h int) listController {
delegate := list.NewDefaultDelegate()
delegate.ShowDescription = false
delegate.Styles.SelectedTitle = lipgloss.NewStyle().
Border(lipgloss.NormalBorder(), false, false, false, true).
BorderForeground(lipgloss.Color("#2c5fb7")).
Foreground(lipgloss.Color("#2c5fb7")).
Padding(0, 0, 0, 1)
list := list.New(items, delegate, w, h)
list.SetShowTitle(false)

View file

@ -10,6 +10,13 @@ import (
"github.com/lmika/awstools/internal/dynamo-browse/ui/teamodels/utils"
)
var (
activeHeaderStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#ffffff")).
Background(lipgloss.Color("#4479ff"))
)
type Model struct {
frameTitle frame.FrameTitle
listController listController
@ -20,7 +27,7 @@ type Model struct {
}
func New(submodel tea.Model) *Model {
frameTitle := frame.NewFrameTitle("Select table", false)
frameTitle := frame.NewFrameTitle("Select table", false, activeHeaderStyle)
return &Model{frameTitle: frameTitle, submodel: submodel}
}

View file

@ -10,6 +10,13 @@ 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
@ -24,7 +31,7 @@ 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,7 +27,7 @@ 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{
@ -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
}

View file

@ -11,6 +11,13 @@ import (
"strings"
)
var (
activeHeaderStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#ffffff")).
Background(lipgloss.Color("#c144ff"))
)
type Model struct {
frameTitle frame.FrameTitle
viewport viewport.Model
@ -25,7 +32,7 @@ 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

@ -9,6 +9,13 @@ import (
"github.com/lmika/awstools/internal/ssm-browse/models"
)
var (
activeHeaderStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#ffffff")).
Background(lipgloss.Color("#c144ff"))
)
type Model struct {
frameTitle frame.FrameTitle
table table.Model
@ -19,7 +26,7 @@ type Model struct {
}
func New() *Model {
frameTitle := frame.NewFrameTitle("SSM: /", true)
frameTitle := frame.NewFrameTitle("SSM: /", true, activeHeaderStyle)
table := table.New([]string{"name", "type", "value"}, 0, 0)
return &Model{
@ -85,7 +92,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
}