From 00c2012ccf74cc7464612abd94c27c6f872ed3e1 Mon Sep 17 00:00:00 2001 From: Sinclair Chen Date: Thu, 23 Jun 2022 12:55:41 -0500 Subject: [PATCH] Refactor empty avatar component --- web/components/avatar.tsx | 16 +++++++++++++++- web/components/feed/feed-bets.tsx | 6 ++---- web/pages/notifications.tsx | 6 ++---- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/web/components/avatar.tsx b/web/components/avatar.tsx index 5604e5aa..e6506c03 100644 --- a/web/components/avatar.tsx +++ b/web/components/avatar.tsx @@ -1,7 +1,7 @@ import Router from 'next/router' import clsx from 'clsx' import { MouseEvent } from 'react' -import { UserCircleIcon } from '@heroicons/react/solid' +import { UserCircleIcon, UserIcon, UsersIcon } from '@heroicons/react/solid' export function Avatar(props: { username?: string @@ -45,3 +45,17 @@ export function Avatar(props: { /> ) } + +export function EmptyAvatar(props: { size?: number; multi?: boolean }) { + const { size = 8, multi } = props + const insize = size - 3 + const Icon = multi ? UsersIcon : UserIcon + + return ( +
+ +
+ ) +} diff --git a/web/components/feed/feed-bets.tsx b/web/components/feed/feed-bets.tsx index cae9bef6..06460a91 100644 --- a/web/components/feed/feed-bets.tsx +++ b/web/components/feed/feed-bets.tsx @@ -4,7 +4,7 @@ import { Bet } from 'common/bet' import { User } from 'common/user' import { useUser, useUserById } from 'web/hooks/use-user' import { Row } from 'web/components/layout/row' -import { Avatar } from 'web/components/avatar' +import { Avatar, EmptyAvatar } from 'web/components/avatar' import clsx from 'clsx' import { UserIcon, UsersIcon } from '@heroicons/react/solid' import { formatMoney } from 'common/util/format' @@ -50,9 +50,7 @@ export function FeedBet(props: { /> ) : (
-
-
+
)}
diff --git a/web/pages/notifications.tsx b/web/pages/notifications.tsx index 0b04c7b0..070caa3e 100644 --- a/web/pages/notifications.tsx +++ b/web/pages/notifications.tsx @@ -7,7 +7,7 @@ import { notification_source_types, notification_source_update_types, } from 'common/notification' -import { Avatar } from 'web/components/avatar' +import { Avatar, EmptyAvatar } from 'web/components/avatar' import { Row } from 'web/components/layout/row' import { Page } from 'web/components/page' import { Title } from 'web/components/title' @@ -235,9 +235,7 @@ function NotificationGroupItem(props: { /> )} -
-
+
setExpanded(!expanded)}