mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(post): add avatars
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import { Trans, useTranslation } from 'react-i18next';
|
import { Trans, useTranslation } from 'react-i18next';
|
||||||
import { Link, useLocation, useParams } from 'react-router-dom';
|
import { Link, useLocation, useParams } from 'react-router-dom';
|
||||||
import { Comment, useAccount, useComment, useEditedComment } from '@plebbit/plebbit-react-hooks';
|
import { Comment, useAccount, useAuthorAvatar, useComment, useEditedComment } from '@plebbit/plebbit-react-hooks';
|
||||||
import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js';
|
import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js';
|
||||||
import styles from '../../views/post/post.module.css';
|
import styles from '../../views/post/post.module.css';
|
||||||
import { getCommentMediaInfo, getDisplayMediaInfoType, getHasThumbnail } from '../../lib/utils/media-utils';
|
import { getCommentMediaInfo, getDisplayMediaInfoType, getHasThumbnail } from '../../lib/utils/media-utils';
|
||||||
@@ -54,6 +54,7 @@ const PostInfo = ({ openReplyModal, post, postReplyCount = 0, roles, isHidden }:
|
|||||||
const stateString = useStateString(post);
|
const stateString = useStateString(post);
|
||||||
const isReply = parentCid;
|
const isReply = parentCid;
|
||||||
const { showOmittedReplies } = useShowOmittedReplies();
|
const { showOmittedReplies } = useShowOmittedReplies();
|
||||||
|
const { imageUrl: avatarImageUrl } = useAuthorAvatar({ author });
|
||||||
|
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@@ -99,6 +100,13 @@ const PostInfo = ({ openReplyModal, post, postReplyCount = 0, roles, isHidden }:
|
|||||||
</span>
|
</span>
|
||||||
{!(isDescription || isRules) && (
|
{!(isDescription || isRules) && (
|
||||||
<>
|
<>
|
||||||
|
{isReply && author?.avatar && (
|
||||||
|
<Tooltip
|
||||||
|
children={<span className={styles.authorAvatar} style={{ backgroundImage: `url(${avatarImageUrl})` }} />}
|
||||||
|
content={avatarImageUrl?.toString() || ''}
|
||||||
|
showTooltip={!!avatarImageUrl}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
(u/
|
(u/
|
||||||
<Tooltip
|
<Tooltip
|
||||||
children={
|
children={
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import { Trans, useTranslation } from 'react-i18next';
|
import { Trans, useTranslation } from 'react-i18next';
|
||||||
import { Link, useLocation, useParams } from 'react-router-dom';
|
import { Link, useLocation, useParams } from 'react-router-dom';
|
||||||
import { Comment, useAccount, useComment, useEditedComment } from '@plebbit/plebbit-react-hooks';
|
import { Comment, useAccount, useAuthorAvatar, useComment, useEditedComment } from '@plebbit/plebbit-react-hooks';
|
||||||
import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js';
|
import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js';
|
||||||
import styles from '../../views/post/post.module.css';
|
import styles from '../../views/post/post.module.css';
|
||||||
import { getCommentMediaInfo, getHasThumbnail } from '../../lib/utils/media-utils';
|
import { getCommentMediaInfo, getHasThumbnail } from '../../lib/utils/media-utils';
|
||||||
@@ -29,6 +29,7 @@ const PostInfoAndMedia = ({ openReplyModal, post, postReplyCount = 0, roles }: P
|
|||||||
const { address, shortAddress } = author || {};
|
const { address, shortAddress } = author || {};
|
||||||
const displayName = author?.displayName?.trim();
|
const displayName = author?.displayName?.trim();
|
||||||
const authorRole = roles?.[address]?.role;
|
const authorRole = roles?.[address]?.role;
|
||||||
|
const { imageUrl: avatarImageUrl } = useAuthorAvatar({ author });
|
||||||
|
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@@ -73,6 +74,13 @@ const PostInfoAndMedia = ({ openReplyModal, post, postReplyCount = 0, roles }: P
|
|||||||
</span>
|
</span>
|
||||||
{!(isDescription || isRules) && (
|
{!(isDescription || isRules) && (
|
||||||
<>
|
<>
|
||||||
|
{isReply && author?.avatar && (
|
||||||
|
<Tooltip
|
||||||
|
children={<span className={styles.authorAvatar} style={{ backgroundImage: `url(${avatarImageUrl})` }} />}
|
||||||
|
content={avatarImageUrl?.toString() || ''}
|
||||||
|
showTooltip={!!avatarImageUrl}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
(u/
|
(u/
|
||||||
<Tooltip
|
<Tooltip
|
||||||
children={
|
children={
|
||||||
|
|||||||
@@ -504,6 +504,17 @@
|
|||||||
text-decoration: var(--post-content-link-text-decoration-hover);
|
text-decoration: var(--post-content-link-text-decoration-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.authorAvatar {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
background-size: 100%;
|
||||||
|
background-position: center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 640px) {
|
@media (max-width: 640px) {
|
||||||
.replyQuotePreview {
|
.replyQuotePreview {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
|
|||||||
Reference in New Issue
Block a user