Skip to content

Commit fc9126b

Browse files
authored
Add Row to StyleFuncInput (#209)
1 parent 4eff1bf commit fc9126b

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

table/cell.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ type StyledCellFuncInput struct {
2828

2929
// Column is the column that the cell belongs to.
3030
Column Column
31+
32+
// Row is the row that the cell belongs to.
33+
Row Row
3134
}
3235

3336
// StyledCellFunc is a function that takes various information about the cell and

table/row.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func (m Model) renderRowColumnData(row Row, column Column, rowStyle lipgloss.Sty
9696
cellStyle = entry.StyleFunc(StyledCellFuncInput{
9797
Column: column,
9898
Data: entry.Data,
99+
Row: row,
99100
}).Copy().Inherit(cellStyle)
100101
} else {
101102
cellStyle = entry.Style.Copy().Inherit(cellStyle)

table/view_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,7 @@ func TestSimple3x3CellStyleFuncOverridesAsBaseColumnRowCell(t *testing.T) {
825825
// Do some checks to make sure we're given the right information as a bonus test
826826
assert.Equal(t, "2", input.Column.Key(), "Wrong column key given to style func")
827827
assert.Equal(t, "R", input.Data, "Wrong data given to style func")
828+
assert.Equal(t, "1,1", input.Row.Data["1"], "Wrong row given to style func")
828829

829830
return lipgloss.NewStyle().Align(lipgloss.Right)
830831
})

0 commit comments

Comments
 (0)