Profile Cover Photo
deso-ui/profile-cover-photoFreeBlock
A component for displaying a user's cover photo.
Install it
npx shadcn@latest add https://ui.deso.com/r/profile-cover-photo.jsonSource
1'use client';23import React from 'react';4import { Skeleton } from '@/components/ui/skeleton';5import { useProfile } from '@/hooks/useProfile';6import { cn } from '@/lib/utils/deso';7import { AspectRatio } from '@/components/ui/aspect-ratio';89type AspectRatioString = '16:9' | '3:1' | '2:1' | '4:3';10type GradientColor = 'blue' | 'purple' | 'pink' | 'green' | 'orange' | 'random';1112interface ProfileCoverPhotoProps {13 publicKey: string;14 aspectRatio?: AspectRatioString;15 fallbackGradient?: GradientColor;16 showOverlay?: boolean;17 overlayOpacity?: number;18 enableParallax?: boolean;19 className?: string;20 children?: React.ReactNode;21}2223// Aspect ratio configurations24const aspectRatioConfig = {25 '16:9': 'aspect-video',26 '3:1': 'aspect-[3/1]',27 '2:1': 'aspect-[2/1]',28 '4:3': 'aspect-[4/3]',29} as const;3031// Gradient configurations32const gradientConfig = {33 blue: 'bg-gradient-to-br from-blue-400 to-blue-600',34 purple: 'bg-gradient-to-br from-purple-400 to-purple-600',35 pink: 'bg-gradient-to-br from-pink-400 to-pink-600',36 green: 'bg-gradient-to-br from-green-400 to-green-600',37 orange: 'bg-gradient-to-br from-orange-400 to-orange-600',38 random: 'bg-gradient-to-br from-indigo-400 via-purple-400 to-pink-400',39} as const;4041const getAspectRatioValue = (ratio: AspectRatioString): number => {42 const [w, h] = ratio.split(':').map(Number);43 return w / h;44};4546export function ProfileCoverPhoto({47 publicKey,48 aspectRatio = '16:9',49 fallbackGradient = 'blue',50 showOverlay = false,51 overlayOpacity = 0.3,52 enableParallax = false,53 className,54 children,55}: ProfileCoverPhotoProps) {56 // Fetch profile data using Apollo Client57 const { profile, loading, error } = useProfile(publicKey);5859 // Use FeaturedImageURL from extraData for the cover photo60 const featuredImage = profile?.extraData?.FeaturedImageURL;61 const aspectClass = aspectRatioConfig[aspectRatio];62 const gradientClass = gradientConfig[fallbackGradient];6364 const aspectRatioValue = getAspectRatioValue(aspectRatio);6566 if (loading) {67 return (68 <AspectRatio ratio={aspectRatioValue}>69 <Skeleton className="w-full h-full" />70 </AspectRatio>71 );72 }7374 if (error || !featuredImage) {75 return (76 <AspectRatio ratio={aspectRatioValue}>77 <div className="w-full h-full bg-slate-200" />78 </AspectRatio>79 );80 }8182 return (83 <AspectRatio84 ratio={aspectRatioValue}85 className={cn(86 'relative w-full h-full overflow-hidden rounded-lg',87// … truncated
Files it writes
More from deso-ui
All 47 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Action Menuaction-menu | deso-ui | Blocks | Free | no deps | |
| Confirmation Dialogconfirmation-dialog | deso-ui | Blocks | Free | no deps | |
| Copy Buttoncopy-button | deso-ui | Blocks | Free | no deps | |
| Editoreditor | deso-ui | Blocks | Free | no deps | |
| Editor Emoji Pickereditor-emoji-picker | deso-ui | Blocks | Free | no deps | |
| Editor Markdowneditor-markdown | deso-ui | Blocks | Free | no deps | |
| Editor Uploadeditor-upload | deso-ui | Blocks | Free | no deps | |
| Feed Listfeed-list | deso-ui | Blocks | Free | no deps |
