From fdd07e885de7461477352cb8de5b119eb5919d79 Mon Sep 17 00:00:00 2001 From: szktkfm Date: Sun, 18 Feb 2024 19:08:13 +0900 Subject: [PATCH] style change --- root.go | 18 +++++++++--------- table.go | 20 ++++++++++++++++---- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/root.go b/root.go index e29b1c3..4b4d4c2 100644 --- a/root.go +++ b/root.go @@ -157,15 +157,15 @@ func NewRoot() model { ) s := DefaultStyles() - s.Header = s.Header. - BorderStyle(lipgloss.NormalBorder()). - BorderForeground(lipgloss.Color("240")). - BorderBottom(true). - Bold(false) - s.Selected = s.Selected. - Foreground(lipgloss.Color("16")). - Background(lipgloss.Color("111")). - Bold(false) + // s.Header = s.Header. + // BorderStyle(lipgloss.NormalBorder()). + // BorderForeground(lipgloss.Color("240")). + // BorderBottom(true). + // Bold(false) + // s.Selected = s.Selected. + // Foreground(lipgloss.Color("16")). + // Background(lipgloss.Color("111")). + // Bold(false) t.SetStyles(s) m := model{t} diff --git a/table.go b/table.go index 07fdacc..f515d55 100644 --- a/table.go +++ b/table.go @@ -136,10 +136,15 @@ type Styles struct { func DefaultStyles() Styles { return Styles{ Selected: lipgloss.NewStyle().Bold(true). - Foreground(lipgloss.Color("225")). - Background(lipgloss.Color("34")), - Header: lipgloss.NewStyle().Bold(true).Padding(0, 1), - Cell: lipgloss.NewStyle().Padding(0, 1), + Foreground(lipgloss.Color("17")). + Background(lipgloss.Color("4")), + Header: lipgloss.NewStyle().Bold(true).Padding(0, 1). + BorderStyle(lipgloss.NormalBorder()). + BorderForeground(lipgloss.Color("240")). + BorderBottom(true). + Bold(false), + + Cell: lipgloss.NewStyle().Padding(0, 1), } } @@ -310,6 +315,12 @@ func (m TableModel) Update(msg tea.Msg) (TableModel, tea.Cmd) { func (m *TableModel) switchMode(mode int) { m.mode = mode + if mode == INSERT { + m.styles.Selected = lipgloss.NewStyle().Bold(true) + m.UpdateViewport() + } else { + m.SetStyles(DefaultStyles()) + } } func (m TableModel) UpdateWidth(msg WidthMsg) { @@ -534,6 +545,7 @@ func (m *TableModel) GotoBottom() { // } func (m TableModel) headersView() string { + // selectしたheaderをstyleをinheritしてview var s = make([]string, 0, len(m.cols)) for _, col := range m.cols { style := lipgloss.NewStyle().Width(col.Width).MaxWidth(col.Width).Inline(true)