package components import ( "fmt" "tangled.org/arabica.social/arabica/internal/web/assets" "tangled.org/arabica.social/arabica/internal/web/bff" "tangled.org/pdewey.com/atp" ) // HeaderProps contains all properties for the header component type HeaderProps struct { IsAuthenticated bool UserProfile *bff.UserProfile UserDID string IsModerator bool // Show admin link in dropdown UnreadNotificationCount int // Badge count for bell icon BrandName string // "Arabica"; falls back to "Arabica" when empty AppName string // "arabica" or "oolong" — selects the create-new dropdown contents } // brandName returns the configured brand name with the arabica default // applied so existing call sites that don't thread it stay working. func (p HeaderProps) brandName() string { if p.BrandName != "" { return p.BrandName } return "Arabica" } templ Header(isAuthenticated bool, userProfile *bff.UserProfile, userDID string) { @HeaderWithProps(HeaderProps{ IsAuthenticated: isAuthenticated, UserProfile: userProfile, UserDID: userDID, }) } templ HeaderWithProps(props HeaderProps) { if !props.IsAuthenticated { @LoginModal() } } // LoginModal renders the login dialog for unauthenticated users templ LoginModal() { } // Helper function to get profile identifier (handle or DID) // Prefers handle if available, falls back to DID func getProfileIdentifier(userProfile *bff.UserProfile, userDID string) string { // Prefer handle if available (canonical URL format) if userProfile != nil && userProfile.Handle != "" { return userProfile.Handle } // Fall back to DID if handle not available if userDID != "" { return userDID } // Last resort: empty string (should not happen for authenticated users) return "" } // Helper functions for Avatar component func getHeaderAvatarURL(userProfile *bff.UserProfile) string { if userProfile != nil { return userProfile.Avatar } return "" } func getHeaderDisplayName(userProfile *bff.UserProfile) string { if userProfile != nil { return userProfile.DisplayName } return "" } // formatNotificationCount formats the notification badge count (99+ for large numbers) func formatNotificationCount(count int) string { if count > 99 { return "99+" } return fmt.Sprintf("%d", count) } // arabicaCreateDropdownItems renders the "+" menu entries for the // coffee app: log a brew, add a bean / roaster / grinder / brewer / // recipe. Each Add-* button opens the relevant modal via HTMX. templ arabicaCreateDropdownItems() { @IconCoffee() New Brew } // oolongCreateDropdownItems renders the "+" menu entries for the tea // app: open the steep/tea/vendor/vessel/infuser modals. Cafe, drink, // and recipe entries are deferred for v1. templ oolongCreateDropdownItems() { @IconDroplet() New Steep @IconLeaf() Tea }