ssm-browse: header styling
This commit is contained in:
parent
798150a403
commit
1b8518b6e4
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -8,25 +8,21 @@ 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"))
|
||||
Foreground(lipgloss.Color("#000000")).
|
||||
Background(lipgloss.Color("#d1d1d1"))
|
||||
)
|
||||
|
||||
// Frame is a frame that appears in the
|
||||
type FrameTitle struct {
|
||||
header string
|
||||
active bool
|
||||
width int
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,12 +26,12 @@ 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{
|
||||
frameTitle: frameTitle,
|
||||
table: table,
|
||||
table: table,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue