mirror of
https://github.com/plebbit/seedit.git
synced 2026-05-19 06:04:56 -04:00
feat(post tools label): add spoiler label next to post tools buttons
This commit is contained in:
@@ -33,5 +33,6 @@
|
||||
"time_1_month_ago": "1 month ago",
|
||||
"time_x_months_ago": "{{count}} months ago",
|
||||
"time_1_year_ago": "1 year ago",
|
||||
"time_x_years_ago": "{{count}} years ago"
|
||||
"time_x_years_ago": "{{count}} years ago",
|
||||
"post_label_spoiler": "spoiler"
|
||||
}
|
||||
@@ -33,5 +33,6 @@
|
||||
"time_1_month_ago": "1 mese fa",
|
||||
"time_x_months_ago": "{{count}} mesi fa",
|
||||
"time_1_year_ago": "1 anno fa",
|
||||
"time_x_years_ago": "{{count}} anni fa"
|
||||
"time_x_years_ago": "{{count}} anni fa",
|
||||
"post_label_spoiler": "spoiler"
|
||||
}
|
||||
1
src/components/post-tools/post-tools-label/index.ts
Normal file
1
src/components/post-tools/post-tools-label/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export {default} from './post-tools-label';
|
||||
@@ -0,0 +1,10 @@
|
||||
.stamp {
|
||||
color: var(--text);
|
||||
border-color: currentColor;
|
||||
border-radius: 3px;
|
||||
border: 1px solid;
|
||||
display: inline-block;
|
||||
font-size: 10px;
|
||||
line-height: 14px;
|
||||
padding: 0 4px;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { FC } from 'react';
|
||||
import styles from './post-tools-label.module.css';
|
||||
import { useComment } from '@plebbit/plebbit-react-hooks';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
interface PostToolsLabelProps {
|
||||
commentCid: string;
|
||||
}
|
||||
|
||||
const PostToolsLabel: FC<PostToolsLabelProps> = ({ commentCid }) => {
|
||||
const comment = useComment({ commentCid });
|
||||
const { spoiler } = comment;
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<li>
|
||||
<span className={styles.stamp}>
|
||||
<span className={styles.content}>{spoiler && t('post_label_spoiler').toUpperCase()}</span>
|
||||
</span>
|
||||
</li>
|
||||
);
|
||||
};
|
||||
|
||||
export default PostToolsLabel;
|
||||
@@ -3,6 +3,7 @@ import styles from './post-tools.module.css';
|
||||
import { useComment } from '@plebbit/plebbit-react-hooks';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import PostToolsLabel from './post-tools-label';
|
||||
|
||||
interface PostToolsProps {
|
||||
commentCid: string;
|
||||
@@ -11,11 +12,12 @@ interface PostToolsProps {
|
||||
const PostTools: FC<PostToolsProps> = ({ commentCid }) => {
|
||||
const comment = useComment({ commentCid });
|
||||
const subplebbitAddress = comment.subplebbitAddress;
|
||||
const { cid, replyCount } = comment;
|
||||
const { cid, replyCount, spoiler } = comment;
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<ul className={styles.buttons}>
|
||||
{spoiler && <PostToolsLabel commentCid={cid} />}
|
||||
<li className={styles.first}>
|
||||
<Link to={`p/${subplebbitAddress}/c/${cid}`} onClick={(e) => e.preventDefault()}>
|
||||
{replyCount === 0 ? t('feed_post_no_comments') : `${replyCount} ${replyCount === 1 ? t('feed_post_comment') : t('feed_post_comments')}`}
|
||||
|
||||
Reference in New Issue
Block a user