mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
refactor: make components for rules, description, rename stats
This commit is contained in:
@@ -1 +0,0 @@
|
||||
export { default } from './board-stats';
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from './subplebbit-description';
|
||||
@@ -0,0 +1,26 @@
|
||||
import Post from '../post';
|
||||
interface DescriptionPostProps {
|
||||
subplebbitAddress: string | undefined;
|
||||
createdAt: number;
|
||||
description: string;
|
||||
avatarUrl?: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
export const SubplebbitDescription = ({ subplebbitAddress, createdAt, description, avatarUrl, title }: DescriptionPostProps) => {
|
||||
const post = {
|
||||
isDescription: true,
|
||||
subplebbitAddress,
|
||||
timestamp: createdAt,
|
||||
author: { displayName: '## Board Mods' },
|
||||
content: description,
|
||||
link: avatarUrl,
|
||||
title: 'Welcome to ' + title,
|
||||
pinned: true,
|
||||
locked: true,
|
||||
};
|
||||
|
||||
return <Post post={post} />;
|
||||
};
|
||||
|
||||
export default SubplebbitDescription;
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from './subplebbit-rules';
|
||||
@@ -0,0 +1,25 @@
|
||||
import Post from '../post';
|
||||
|
||||
interface RulesPostProps {
|
||||
subplebbitAddress: string | undefined;
|
||||
createdAt: number;
|
||||
rules: string[];
|
||||
}
|
||||
|
||||
export const SubplebbitRules = ({ subplebbitAddress, createdAt, rules }: RulesPostProps) => {
|
||||
const content = rules.map((rule, index) => `${index + 1}. ${rule}`).join('\n');
|
||||
const post = {
|
||||
isRules: true,
|
||||
subplebbitAddress,
|
||||
timestamp: createdAt,
|
||||
author: { displayName: '## Board Mods' },
|
||||
content,
|
||||
title: 'Rules',
|
||||
pinned: true,
|
||||
locked: true,
|
||||
};
|
||||
|
||||
return <Post post={post} />;
|
||||
};
|
||||
|
||||
export default SubplebbitRules;
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from './subplebbit-stats';
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
import { useState } from 'react';
|
||||
import { useLocation, useParams } from 'react-router-dom';
|
||||
import { useComment, useSubplebbit, useSubplebbitStats } from '@plebbit/plebbit-react-hooks';
|
||||
import styles from './board-stats.module.css';
|
||||
import styles from './subplebbit-stats.module.css';
|
||||
import { Trans, useTranslation } from 'react-i18next';
|
||||
import { isDescriptionView, isRulesView } from '../../lib/utils/view-utils';
|
||||
|
||||
const BoardStats = () => {
|
||||
const SubplebbitStats = () => {
|
||||
const { t } = useTranslation();
|
||||
const { commentCid, subplebbitAddress } = useParams<{ subplebbitAddress: string; commentCid: string }>();
|
||||
|
||||
@@ -103,4 +103,4 @@ const BoardStats = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default BoardStats;
|
||||
export default SubplebbitStats;
|
||||
Reference in New Issue
Block a user