diff --git a/apps/web/src/app/[locale]/auth/login/login-page.tsx b/apps/web/src/app/[locale]/auth/login/login-page.tsx index db33f7161..76ea8da29 100644 --- a/apps/web/src/app/[locale]/auth/login/login-page.tsx +++ b/apps/web/src/app/[locale]/auth/login/login-page.tsx @@ -5,9 +5,9 @@ import { useRouter } from "next/navigation"; import { useSession } from "next-auth/react"; import { Logo } from "@/components/logo"; +import { OptimizedAvatarImage } from "@/components/optimized-avatar-image"; import { Skeleton } from "@/components/skeleton"; import { Trans } from "@/components/trans"; -import { UserAvatar } from "@/components/user"; import { usePostHog } from "@/utils/posthog"; import { trpc } from "@/utils/trpc/client"; @@ -53,9 +53,13 @@ export const LoginPage = ({ magicLink, email }: PageProps) => {
-
- -
+
+ +
{data?.name ?? }
@@ -71,9 +75,8 @@ export const LoginPage = ({ magicLink, email }: PageProps) => { onClick={async () => { await magicLinkFetch.mutateAsync(); }} - size="lg" variant="primary" - className="mt-4 w-full" + className="mt-6 w-full" > diff --git a/apps/web/src/components/current-user-avatar.tsx b/apps/web/src/components/current-user-avatar.tsx index 53adcedeb..6d6884dc7 100644 --- a/apps/web/src/components/current-user-avatar.tsx +++ b/apps/web/src/components/current-user-avatar.tsx @@ -1,18 +1,8 @@ "use client"; -import { Avatar, AvatarFallback, AvatarImage } from "@rallly/ui/avatar"; -import Image from "next/image"; +import { OptimizedAvatarImage } from "@/components/optimized-avatar-image"; import { useUser } from "@/components/user-provider"; -function getAvatarUrl(imageKey: string) { - // Some users have avatars that come from external providers (e.g. Google). - if (imageKey.startsWith("https://")) { - return imageKey; - } - - return `/api/storage/${imageKey}`; -} - export const CurrentUserAvatar = ({ size, className, @@ -22,23 +12,11 @@ export const CurrentUserAvatar = ({ }) => { const { user } = useUser(); return ( - - {user.image ? ( - user.image.startsWith("http") ? ( - - ) : ( - {user.name} - ) - ) : ( - {user.name[0]} - )} - + ); }; diff --git a/apps/web/src/components/optimized-avatar-image.tsx b/apps/web/src/components/optimized-avatar-image.tsx new file mode 100644 index 000000000..b4dba9437 --- /dev/null +++ b/apps/web/src/components/optimized-avatar-image.tsx @@ -0,0 +1,45 @@ +"use client"; +import { Avatar, AvatarFallback, AvatarImage } from "@rallly/ui/avatar"; +import Image from "next/image"; + +function getAvatarUrl(imageKey: string) { + // Some users have avatars that come from external providers (e.g. Google). + if (imageKey.startsWith("https://")) { + return imageKey; + } + + return `/api/storage/${imageKey}`; +} + +export const OptimizedAvatarImage = ({ + size, + className, + src, + name, +}: { + size: number; + src?: string; + name: string; + className?: string; +}) => { + return ( + + {src ? ( + src.startsWith("http") ? ( + + ) : ( + {name} + ) + ) : ( + {name[0]} + )} + + ); +}; diff --git a/apps/web/src/trpc/routers/user.ts b/apps/web/src/trpc/routers/user.ts index 0b9900641..9d541867b 100644 --- a/apps/web/src/trpc/routers/user.ts +++ b/apps/web/src/trpc/routers/user.ts @@ -43,6 +43,7 @@ export const user = router({ select: { name: true, email: true, + image: true, }, }); }), diff --git a/packages/ui/src/avatar.tsx b/packages/ui/src/avatar.tsx index ef3d2e781..aaa9c8844 100644 --- a/packages/ui/src/avatar.tsx +++ b/packages/ui/src/avatar.tsx @@ -7,14 +7,17 @@ import { cn } from "@rallly/ui"; const Avatar = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( + React.ComponentPropsWithoutRef & { + size?: number; + } +>(({ className, size = 48, ...props }, ref) => ( ));