Skip to content

Commit

Permalink
fix(ui): overflow message for modals
Browse files Browse the repository at this point in the history
  • Loading branch information
PhearZero committed Dec 2, 2024
1 parent ee1c17f commit 0ed05bc
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion ui/style/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,28 @@ func WithOverlay(overlay string, view string) string {
row -= lipgloss.Height(overlay) / 2
col := lipgloss.Width(view) / 2
col -= lipgloss.Width(overlay) / 2

// Display the terminal resize
if col < 0 || row < 0 {
return view
overlayText := "Resize terminal to see overlay"
overlay = WithNavigation("( esc )", WithTitle("Screen Size",
ApplyBorder(
lipgloss.Width(overlayText)+4,
lipgloss.Height(overlayText)+2,
"1",
).Padding(1).Render(overlayText),
),
)
overlayLines = strings.Split(overlay, "\n")
row = lipgloss.Height(view) / 2
row -= lipgloss.Height(overlay) / 2
col = lipgloss.Width(view) / 2
col -= lipgloss.Width(overlay) / 2

// If it is still too small, just return the text
if col < 0 || row < 0 {
return overlayText
}

Check warning on line 128 in ui/style/style.go

View check run for this annotation

Codecov / codecov/patch

ui/style/style.go#L110-L128

Added lines #L110 - L128 were not covered by tests
}

for i, overlayLine := range overlayLines {
Expand Down

0 comments on commit 0ed05bc

Please sign in to comment.