package components import ( "fmt" "arabica/internal/web/bff" ) // 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 } templ Header(isAuthenticated bool, userProfile *bff.UserProfile, userDID string) { @HeaderWithProps(HeaderProps{ IsAuthenticated: isAuthenticated, UserProfile: userProfile, UserDID: userDID, }) } templ HeaderWithProps(props HeaderProps) { } // 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) }