From 9b809dc7e52aef06501a0a28fc876ad005916deb Mon Sep 17 00:00:00 2001 From: bashbunni <15822994+bashbunni@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:02:40 -0700 Subject: [PATCH] fix(examples): fix out of range error (#395) --- examples/table/languages/main.go | 4 ++-- examples/table/mindy/main.go | 2 +- examples/table/pokemon/main.go | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/table/languages/main.go b/examples/table/languages/main.go index b0e94d82..aa8a10cf 100644 --- a/examples/table/languages/main.go +++ b/examples/table/languages/main.go @@ -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 @@ -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) } diff --git a/examples/table/mindy/main.go b/examples/table/mindy/main.go index f58fff38..9f97c9af 100644 --- a/examples/table/mindy/main.go +++ b/examples/table/mindy/main.go @@ -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) diff --git a/examples/table/pokemon/main.go b/examples/table/pokemon/main.go index 5c25eee9..ff3d7bad 100644 --- a/examples/table/pokemon/main.go +++ b/examples/table/pokemon/main.go @@ -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 } @@ -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) }