File tree 1 file changed +10
-12
lines changed 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -24,30 +24,28 @@ const (
24
24
func (t * Table ) ViewTable (value [][]string , headers []string ) * table.Table {
25
25
render := lipgloss .NewRenderer (os .Stdout )
26
26
27
- HeaderStyle := render .NewStyle ().Foreground (t .HeaderStyle ).Bold (true ).Align (lipgloss .Center )
28
- CellStyle := render .NewStyle ().Padding (TopPadding , RightPadding ).Width (CellWidth ).Align (lipgloss .Center )
27
+ CellStyle := render .NewStyle ().
28
+ Width (CellWidth ).
29
+ Align (lipgloss .Center ).
30
+ Padding (TopPadding , RightPadding )
29
31
30
32
OddRowStyle := CellStyle .Foreground (t .OddCellStyle )
31
33
EvenRowStyle := CellStyle .Foreground (t .EvenRowStyle )
34
+ HeaderColumnsStyle := CellStyle .Foreground (t .HeaderStyle )
32
35
33
36
BorderStyle := lipgloss .NewStyle ().Foreground (t .BorderStyle )
34
37
35
38
viewTable := table .New ().
36
39
Border (lipgloss .NormalBorder ()).
37
40
BorderStyle (BorderStyle ).
38
41
StyleFunc (func (row , col int ) lipgloss.Style {
39
- var style lipgloss.Style
40
-
41
- switch {
42
- case row == 0 :
43
- return HeaderStyle
44
- case row % 2 == 0 :
45
- style = EvenRowStyle
46
- default :
47
- style = OddRowStyle
42
+ if row == - 1 {
43
+ return HeaderColumnsStyle
44
+ } else if row % 2 == 0 {
45
+ return OddRowStyle
48
46
}
49
47
50
- return style
48
+ return EvenRowStyle
51
49
}).
52
50
Headers (headers ... ).
53
51
Rows (value ... ).
You can’t perform that action at this time.
0 commit comments