Skip to content

Commit 8ec7a5e

Browse files
committed
🎨 Change condition pattern to early returns
1 parent 72cc71f commit 8ec7a5e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

cmd/cmd_list.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ func handleLs() {
6262
Border(lipgloss.NormalBorder()).
6363
BorderStyle(lipgloss.NewStyle().Foreground(lipgloss.Color("99"))).
6464
StyleFunc(func(row, col int) lipgloss.Style {
65-
switch {
66-
case row == -1:
65+
// style for table header row
66+
if row == -1 {
6767
return lipgloss.NewStyle().Foreground(lipgloss.Color("99")).Bold(true).Align(lipgloss.Center)
68-
default:
69-
{
70-
if col == 1 {
71-
return lipgloss.NewStyle().Align(lipgloss.Center).PaddingLeft(2).PaddingRight(2).Width(tw)
72-
}
73-
return lipgloss.NewStyle().Align(lipgloss.Center).PaddingLeft(2).PaddingRight(2)
74-
}
7568
}
69+
70+
// force title column to wrap by specifying terminal width
71+
if col == 1 {
72+
return lipgloss.NewStyle().Align(lipgloss.Center).PaddingLeft(2).PaddingRight(2).Width(tw)
73+
}
74+
75+
return lipgloss.NewStyle().Align(lipgloss.Center).PaddingLeft(2).PaddingRight(2)
7676
}).
7777
Headers("ID", "TITLE", "PROGRESS").
7878
Rows(rows...).Width(tw)

0 commit comments

Comments
 (0)