package components import ( "fmt" "tangled.org/arabica.social/arabica/internal/entities/arabica" "tangled.org/arabica.social/arabica/internal/web/assets" "tangled.org/arabica.social/arabica/internal/web/bff" "tangled.org/pdewey.com/atp" ) // BeanSummaryProps defines props for displaying bean metadata inline. // Used in both bean feed cards and brew feed cards. type BeanSummaryProps struct { Bean *arabica.Bean CoffeeAmount int // if > 0, shows scale icon + "Xg" (brew context) } // BeanSummary renders the bean name, roaster, and attribute tags. templ BeanSummary(props BeanSummaryProps) { if props.Bean != nil {
if props.Bean.Name != "" { { props.Bean.Name } } else { { props.Bean.Origin } }
if props.Bean.Roaster != nil && props.Bean.Roaster.Name != "" {
@IconStore() { props.Bean.Roaster.Name }
}
if props.Bean.Origin != "" { @IconMapPin() { props.Bean.Origin } } if props.Bean.RoastLevel != "" { @IconFlame() { props.Bean.RoastLevel } } if props.Bean.Variety != "" { @IconLeaf() { props.Bean.Variety } } if props.Bean.Process != "" { @IconSprout() { props.Bean.Process } } if props.Bean.Rating != nil { @IconStar() { bff.FormatBeanRating(props.Bean.Rating) } } if props.CoffeeAmount > 0 { @IconScale() { fmt.Sprintf("%dg", props.CoffeeAmount) } }
} } // TypeBadge renders a colored pill with an icon and type label for record type identification. templ TypeBadge(recordType string) { switch recordType { case "brew": @IconCoffee() Brew case "bean": @IconBean() Bean case "recipe": @IconFileText() Recipe case "roaster": @IconStore() Roaster case "grinder": @IconGear() Grinder case "brewer": @IconBrewer() Brewer } } // RecordViewHeaderProps defines properties for the shared record view header. type RecordViewHeaderProps struct { RecordType string // "brew", "bean", "roaster", "grinder", "brewer", "recipe" Title string Timestamp string // formatted date string TimestampISO string // ISO 8601 for