-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display feed certification in discover result
- Loading branch information
Showing
5 changed files
with
177 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { useWhoami } from "@renderer/atoms/user" | ||
import { Avatar, AvatarFallback, AvatarImage } from "@renderer/components/ui/avatar" | ||
import { | ||
Tooltip, | ||
TooltipContent, | ||
TooltipPortal, | ||
TooltipTrigger, | ||
} from "@renderer/components/ui/tooltip" | ||
import { cn } from "@renderer/lib/utils" | ||
import type { FeedModel } from "@renderer/models" | ||
import { usePresentUserProfileModal } from "@renderer/modules/profile/hooks" | ||
import { useTranslation } from "react-i18next" | ||
|
||
export const FeedCertification = ({ feed, className }: { feed: FeedModel; className?: string }) => { | ||
const me = useWhoami() | ||
const presentUserProfile = usePresentUserProfileModal("drawer") | ||
const { t } = useTranslation() | ||
|
||
return ( | ||
feed.ownerUserId && | ||
(feed.ownerUserId === me?.id ? ( | ||
<Tooltip delayDuration={300}> | ||
<TooltipTrigger asChild> | ||
<i className={cn("i-mgc-certificate-cute-fi ml-1.5 shrink-0 text-accent", className)} /> | ||
</TooltipTrigger> | ||
|
||
<TooltipPortal> | ||
<TooltipContent className="px-4 py-2"> | ||
<div className="flex items-center text-base font-semibold"> | ||
<i className="i-mgc-certificate-cute-fi mr-2 shrink-0 text-accent" /> | ||
{t("feed_item.claimed_feed")} | ||
</div> | ||
<div>{t("feed_item.claimed_by_you")}</div> | ||
</TooltipContent> | ||
</TooltipPortal> | ||
</Tooltip> | ||
) : ( | ||
<Tooltip delayDuration={300}> | ||
<TooltipTrigger asChild> | ||
<i | ||
className={cn("i-mgc-certificate-cute-fi ml-1.5 shrink-0 text-amber-500", className)} | ||
/> | ||
</TooltipTrigger> | ||
|
||
<TooltipPortal> | ||
<TooltipContent className="px-4 py-2"> | ||
<div className="flex items-center text-base font-semibold"> | ||
<i className="i-mgc-certificate-cute-fi mr-2 shrink-0 text-amber-500" /> | ||
{t("feed_item.claimed_feed")} | ||
</div> | ||
<div className="mt-1 flex items-center gap-1.5"> | ||
<span>{t("feed_item.claimed_by_owner")}</span> | ||
{feed.owner ? ( | ||
<Avatar | ||
className="inline-flex aspect-square size-5 rounded-full" | ||
onClick={(e) => { | ||
e.stopPropagation() | ||
presentUserProfile(feed.owner!.id) | ||
}} | ||
> | ||
<AvatarImage src={feed.owner.image || undefined} /> | ||
<AvatarFallback>{feed.owner.name?.slice(0, 2)}</AvatarFallback> | ||
</Avatar> | ||
) : ( | ||
<span>{t("feed_item.claimed_by_unknown")}</span> | ||
)} | ||
</div> | ||
</TooltipContent> | ||
</TooltipPortal> | ||
</Tooltip> | ||
)) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters