2023-01-01 19:57:27 +00:00
|
|
|
import "./ProfilePreview.css";
|
2023-01-19 00:03:24 +00:00
|
|
|
import { ReactNode } from "react";
|
|
|
|
|
2023-01-20 11:11:50 +00:00
|
|
|
import ProfileImage from "Element/ProfileImage";
|
|
|
|
import FollowButton from "Element/FollowButton";
|
|
|
|
import useProfile from "Feed/ProfileFeed";
|
|
|
|
import { HexKey } from "Nostr";
|
2023-01-19 15:21:13 +00:00
|
|
|
import { useInView } from "react-intersection-observer";
|
2023-01-01 19:57:27 +00:00
|
|
|
|
2023-01-16 17:48:25 +00:00
|
|
|
export interface ProfilePreviewProps {
|
|
|
|
pubkey: HexKey,
|
|
|
|
options?: {
|
|
|
|
about?: boolean
|
2023-01-19 00:03:24 +00:00
|
|
|
},
|
|
|
|
actions?: ReactNode
|
2023-01-16 17:48:25 +00:00
|
|
|
}
|
|
|
|
export default function ProfilePreview(props: ProfilePreviewProps) {
|
2023-01-01 19:57:27 +00:00
|
|
|
const pubkey = props.pubkey;
|
2023-01-16 17:48:25 +00:00
|
|
|
const user = useProfile(pubkey)?.get(pubkey);
|
2023-01-19 15:21:13 +00:00
|
|
|
const { ref, inView } = useInView({ triggerOnce: true });
|
2023-01-10 10:30:33 +00:00
|
|
|
const options = {
|
|
|
|
about: true,
|
|
|
|
...props.options
|
|
|
|
};
|
2023-01-01 19:57:27 +00:00
|
|
|
|
|
|
|
return (
|
2023-01-19 15:21:13 +00:00
|
|
|
<div className="profile-preview" ref={ref}>
|
|
|
|
{inView && <>
|
|
|
|
<ProfileImage pubkey={pubkey} subHeader=
|
|
|
|
{options.about ? <div className="f-ellipsis about">
|
|
|
|
{user?.about}
|
|
|
|
</div> : undefined} />
|
|
|
|
{props.actions ?? <FollowButton pubkey={pubkey} className="ml5" />}
|
|
|
|
</>}
|
2023-01-01 19:57:27 +00:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|