61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
package tui
|
|
|
|
import (
|
|
"github.com/charmbracelet/lipgloss"
|
|
)
|
|
|
|
func (m Model) BuildBreadcrumbs() string {
|
|
// Only show breadcrumbs in cart view
|
|
if !m.ViewingCart {
|
|
return ""
|
|
}
|
|
|
|
activeStyle := lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color("#FFFFFF")).
|
|
Bold(true)
|
|
|
|
inactiveStyle := lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color("#666666"))
|
|
|
|
sepStyle := lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color("#666666"))
|
|
|
|
sep := sepStyle.Render(" / ")
|
|
|
|
// Checkout flow steps
|
|
var labels []string
|
|
if m.size < large {
|
|
labels = []string{"cart", "ship", "pay", "confirm"}
|
|
} else {
|
|
labels = []string{"cart", "shipping", "payment", "confirmation"}
|
|
}
|
|
|
|
// Get current checkout step from model
|
|
currentStep := m.CheckoutStep
|
|
|
|
var items []string
|
|
for i, label := range labels {
|
|
if i == currentStep {
|
|
items = append(items, activeStyle.Render(label))
|
|
} else {
|
|
items = append(items, inactiveStyle.Render(label))
|
|
}
|
|
|
|
// Add separator except after last item
|
|
if i < len(labels)-1 {
|
|
items = append(items, sep)
|
|
}
|
|
}
|
|
|
|
breadcrumbsContainer := lipgloss.NewStyle().
|
|
MarginBottom(1).
|
|
PaddingLeft(4)
|
|
|
|
result := ""
|
|
for _, item := range items {
|
|
result += item
|
|
}
|
|
|
|
return breadcrumbsContainer.Render(result)
|
|
}
|