Skip to content

Commit

Permalink
fix(examples): fix out of range error (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbunni authored Oct 15, 2024
1 parent 199d3c8 commit 9b809dc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/table/languages/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func main() {
var style lipgloss.Style

switch {
case row == 0:
case row == table.HeaderRow:
return HeaderStyle
case row%2 == 0:
style = EvenRowStyle
Expand All @@ -59,7 +59,7 @@ func main() {
}

// Arabic is a right-to-left language, so right align the text.
if row < len(rows) && rows[row-1][0] == "Arabic" && col != 0 {
if row < len(rows) && rows[row][0] == "Arabic" && col != 0 {
style = style.Align(lipgloss.Right)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/table/mindy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func main() {
Border(lipgloss.HiddenBorder()).
Rows(data...).
StyleFunc(func(row, col int) lipgloss.Style {
color := lipgloss.Color(fmt.Sprint(data[row-1][col-col%2]))
color := lipgloss.Color(fmt.Sprint(data[row][col-col%2]))
switch {
case col%2 == 0:
return labelStyle.Foreground(color)
Expand Down
6 changes: 3 additions & 3 deletions examples/table/pokemon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ func main() {
Width(80).
Rows(data...).
StyleFunc(func(row, col int) lipgloss.Style {
if row == 0 {
if row == table.HeaderRow {
return headerStyle
}

if data[row-1][1] == "Pikachu" {
if data[row][1] == "Pikachu" {
return selectedStyle
}

Expand All @@ -100,7 +100,7 @@ func main() {
c = dimTypeColors
}

color := c[fmt.Sprint(data[row-1][col])]
color := c[fmt.Sprint(data[row][col])]
return baseStyle.Foreground(color)
}

Expand Down

0 comments on commit 9b809dc

Please sign in to comment.