update app layout, add 'thread closed' banner

This commit is contained in:
plebeius.eth
2024-04-08 17:13:02 +02:00
parent 254f9ed887
commit f13b496652
7 changed files with 83 additions and 59 deletions
@@ -10,6 +10,15 @@
padding-bottom: 0.5em;
}
.closed {
font-size: x-large;
text-align: center;
color: red;
font-weight: 700;
padding-top: 100px;
padding-bottom: 100px;
}
@media (max-width: 640px) {
.postFormButtonDesktop {
display: none;
+25 -12
View File
@@ -1,26 +1,39 @@
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import styles from './post-form.module.css';
import { isPostPageView } from '../../lib/utils/view-utils';
import { useLocation, useParams } from 'react-router-dom';
import { useComment } from '@plebbit/plebbit-react-hooks';
import { isPostPageView } from '../../lib/utils/view-utils';
import styles from './post-form.module.css';
export interface PostFormProps {
address: string | undefined;
}
const PostForm = ({ address }: PostFormProps) => {
const PostForm = () => {
const { t } = useTranslation();
const { subplebbitAddress, commentCid } = useParams<{ subplebbitAddress: string; commentCid: string }>();
const comment = useComment({ commentCid });
const { deleted, locked, removed } = comment || {};
const isThreadClosed = deleted || locked || removed;
const [showForm, setShowForm] = useState(false);
const isInPostPage = isPostPageView(useLocation().pathname, useParams());
return (
<>
<div className={styles.postFormButtonDesktop}>
[
<button className='button' onClick={() => setShowForm(true)}>
{isInPostPage ? t('post_a_reply') : t('start_new_thread')}
</button>
]
{isThreadClosed ? (
<div className={styles.closed}>
Thread closed.
<br />
You may not reply at this time.
</div>
) : (
<div>
[
<button className='button' onClick={() => setShowForm(true)}>
{isInPostPage ? t('post_a_reply') : t('start_new_thread')}
</button>
]
</div>
)}
</div>
<div className={styles.postFormButtonMobile}>
<button className='button' onClick={() => setShowForm(!showForm)}>