mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
35 lines
1015 B
TypeScript
35 lines
1015 B
TypeScript
import { useState } from 'react';
|
|
import { useParams } from 'react-router-dom';
|
|
import { useSubplebbit } from '@plebbit/plebbit-react-hooks';
|
|
import styles from './board-banner.module.css';
|
|
|
|
const totalBanners = 24;
|
|
|
|
const ImageBanner = () => {
|
|
const [imagePath] = useState(() => {
|
|
const randomBannerIndex = Math.floor(Math.random() * totalBanners) + 1;
|
|
return `assets/banners/banner-${randomBannerIndex}.jpg`;
|
|
});
|
|
|
|
return <img src={imagePath} alt='banner' />;
|
|
};
|
|
|
|
const BoardBanner = () => {
|
|
const { subplebbitAddress } = useParams();
|
|
const subplebbit = useSubplebbit({ subplebbitAddress });
|
|
const { address, title } = subplebbit || {};
|
|
|
|
return (
|
|
<div className={styles.content}>
|
|
<div className={styles.bannerCnt}>
|
|
<ImageBanner key={subplebbitAddress} />
|
|
</div>
|
|
<div className={styles.boardTitle}>{title || `p/${address}`}</div>
|
|
{title && <div className={styles.boardAddress}>p/{address}</div>}
|
|
<hr />
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default BoardBanner;
|