package components import ( "fmt" "tangled.org/oolong.social/oolong/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 // "Oolong"; falls back to "Oolong" when empty AppName string // "oolong" — selects the create-new dropdown contents } // brandName returns the configured brand name with the oolong 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 "Oolong" } 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) } // oolongCreateDropdownItems renders the "+" menu entries for the tea // app: open the steep/tea/vendor/vessel/infuser modals. Cafe, drink, // and brew entries are deferred for v1. templ oolongCreateDropdownItems() { @IconDroplet() New Steep @IconLeaf() Tea }