Skip to content

Commit

Permalink
style change
Browse files Browse the repository at this point in the history
  • Loading branch information
szktkfm committed Feb 18, 2024
1 parent 6f208d0 commit fdd07e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
18 changes: 9 additions & 9 deletions root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
20 changes: 16 additions & 4 deletions table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fdd07e8

Please sign in to comment.