2023-04-29 16:12:56 +02:00
|
|
|
import React, { useEffect, useRef, useState } from 'react';
|
2023-04-21 10:47:39 +02:00
|
|
|
import { Helmet } from 'react-helmet-async';
|
2023-04-29 16:12:56 +02:00
|
|
|
import { useSubplebbit } from '@plebbit/plebbit-react-hooks';
|
2023-04-08 13:27:17 +02:00
|
|
|
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
2023-04-01 15:09:04 +02:00
|
|
|
import { Link, useNavigate } from 'react-router-dom';
|
2023-04-09 08:37:29 +02:00
|
|
|
import { Container, Header, Logo, Page, Search, About, AboutTitle, AboutContent, Boards, BoardsTitle, BoardsContent, Footer } from '../styled/Home.styled';
|
2023-04-24 20:00:11 +00:00
|
|
|
import packageJson from '../../../package.json'
|
|
|
|
|
const {version} = packageJson
|
2023-03-13 14:29:34 +01:00
|
|
|
|
2023-01-31 23:08:57 +01:00
|
|
|
|
2023-04-29 16:12:56 +02:00
|
|
|
const BoardAvatar = ({ address }) => {
|
|
|
|
|
const [avatarUrl, setAvatarUrl] = useState('assets/plebchan.png');
|
|
|
|
|
const subplebbit = useSubplebbit({ subplebbitAddress: address });
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (subplebbit.suggested?.avatarUrl) {
|
|
|
|
|
setAvatarUrl(subplebbit.suggested.avatarUrl);
|
|
|
|
|
}
|
|
|
|
|
console.log(subplebbit);
|
|
|
|
|
}, [subplebbit.suggested?.avatarUrl, subplebbit]);
|
|
|
|
|
|
|
|
|
|
return <img alt="board logo" src={avatarUrl} />;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2023-03-21 11:17:54 +01:00
|
|
|
const Home = () => {
|
|
|
|
|
const {
|
|
|
|
|
setBodyStyle,
|
|
|
|
|
defaultSubplebbits,
|
|
|
|
|
setSelectedAddress,
|
|
|
|
|
setSelectedStyle,
|
|
|
|
|
setSelectedTitle
|
2023-04-08 13:27:17 +02:00
|
|
|
} = useGeneralStore(state => state);
|
2023-02-13 12:05:10 +01:00
|
|
|
|
2023-04-01 15:09:04 +02:00
|
|
|
const inputRef = useRef(null);
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
|
2023-03-21 11:17:54 +01:00
|
|
|
// prevent dark mode
|
2023-02-13 12:05:10 +01:00
|
|
|
useEffect(() => {
|
|
|
|
|
setBodyStyle({
|
2023-04-29 12:47:30 +02:00
|
|
|
background: "#ffe url(assets/fade.png) top repeat-x",
|
2023-02-13 12:05:10 +01:00
|
|
|
color: "maroon",
|
|
|
|
|
fontFamily: "Helvetica, Arial, sans-serif"
|
|
|
|
|
});
|
|
|
|
|
setSelectedStyle("Yotsuba");
|
|
|
|
|
}, [setBodyStyle, setSelectedStyle]);
|
2023-02-09 19:08:15 +01:00
|
|
|
|
2023-02-04 11:35:46 +01:00
|
|
|
|
2023-02-02 21:58:02 +01:00
|
|
|
return (
|
2023-04-21 10:47:39 +02:00
|
|
|
<>
|
|
|
|
|
<Helmet>
|
|
|
|
|
<title>plebchan</title>
|
|
|
|
|
</Helmet>
|
|
|
|
|
<Container>
|
|
|
|
|
<Header>
|
|
|
|
|
<Logo>
|
|
|
|
|
<Link to="/">
|
2023-04-29 12:47:30 +02:00
|
|
|
<img alt="plebchan" src="assets/logo/logo-transparent.png" />
|
2023-04-21 10:47:39 +02:00
|
|
|
</Link>
|
|
|
|
|
</Logo>
|
|
|
|
|
</Header>
|
|
|
|
|
<Page>
|
|
|
|
|
<Search>
|
|
|
|
|
<input type="text" placeholder='"board.eth" or "12D3KooW..."' ref={inputRef} onKeyDown={
|
|
|
|
|
(event) => {
|
|
|
|
|
if (event.key === "Enter") {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
const address = inputRef.current.value;
|
|
|
|
|
if (address) {
|
|
|
|
|
setSelectedAddress(address);
|
|
|
|
|
navigate(`/p/${address}`)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}} />
|
|
|
|
|
<input type="submit" value="Search" onClick={
|
|
|
|
|
() => {
|
2023-04-01 15:09:04 +02:00
|
|
|
const address = inputRef.current.value;
|
|
|
|
|
if (address) {
|
|
|
|
|
setSelectedAddress(address);
|
2023-04-08 22:30:44 +02:00
|
|
|
navigate(`/p/${address}`)
|
2023-04-01 15:09:04 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-04-21 10:47:39 +02:00
|
|
|
} />
|
|
|
|
|
</Search>
|
|
|
|
|
<About>
|
|
|
|
|
<AboutTitle>
|
|
|
|
|
<h2>What is plebchan?</h2>
|
|
|
|
|
</AboutTitle>
|
|
|
|
|
<AboutContent>
|
|
|
|
|
<div id="content">
|
|
|
|
|
<p>Plebchan is a serverless, adminless, decentralized 4chan alternative that uses the <a href="https://plebbit.com" target="_blank" rel="noreferrer">plebbit protocol</a>. Users do not need to register an account before participating in the community; anyone can post comments, share media links, and create a board. Search for any board address above, or feel free to click on a popular board below that interests you and jump right in! </p>
|
|
|
|
|
<br />
|
2023-04-25 15:44:44 +02:00
|
|
|
<p>There are no global rules, each board is completely independent and its owner decides how it should be moderated.</p>
|
2023-04-21 10:47:39 +02:00
|
|
|
</div>
|
|
|
|
|
</AboutContent>
|
|
|
|
|
</About>
|
|
|
|
|
<Boards>
|
|
|
|
|
<BoardsTitle>
|
|
|
|
|
<h2>Popular boards</h2>
|
|
|
|
|
</BoardsTitle>
|
|
|
|
|
<BoardsContent>
|
|
|
|
|
{defaultSubplebbits.map(subplebbit => (
|
|
|
|
|
<div className="board" key={subplebbit.address}>
|
|
|
|
|
<div className="board-title">
|
|
|
|
|
{subplebbit.title ? subplebbit.title : <span style={{userSelect: "none"}}> </span>}
|
|
|
|
|
</div>
|
|
|
|
|
<Link to={`/p/${subplebbit.address}`} onClick={() => {
|
|
|
|
|
setSelectedTitle(subplebbit.title);
|
|
|
|
|
setSelectedAddress(subplebbit.address);
|
|
|
|
|
}} >
|
2023-04-30 14:54:12 +02:00
|
|
|
<div className="board-avatar-container">
|
|
|
|
|
<BoardAvatar address={subplebbit.address} />
|
|
|
|
|
</div>
|
2023-04-21 10:47:39 +02:00
|
|
|
</Link>
|
|
|
|
|
<div className="board-text">
|
|
|
|
|
<b>{subplebbit.address}</b>
|
|
|
|
|
</div>
|
2023-04-01 14:51:07 +02:00
|
|
|
</div>
|
2023-04-21 10:47:39 +02:00
|
|
|
))}
|
|
|
|
|
</BoardsContent>
|
|
|
|
|
</Boards>
|
|
|
|
|
</Page>
|
|
|
|
|
<Footer>
|
|
|
|
|
<ul>
|
|
|
|
|
<li className="fill"></li>
|
|
|
|
|
<li className="first">
|
|
|
|
|
<a href="https://plebbitapp.eth.limo/#/" target="_blank" rel="noopener noreferrer">Plebbit</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="https://gitcoin.co/grants/5515/plebbit-a-serverless-adminless-decentralized-redd" target="_blank" rel="noopener noreferrer">Donate</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="https://plebbit.com/whitepaper" target="_blank" rel="noopener noreferrer">Whitepaper</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="https://snowtrace.io/token/0x625fc9bb971bb305a2ad63252665dcfe9098bee9" target="_blank" rel="noopener noreferrer">Token</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="https://matrix.to/#/#plebbit:plebbitchat.org" target="_blank" rel="noopener noreferrer">Matrix</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="https://t.me/plebbit" target="_blank" rel="noopener noreferrer">Telegram</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="https://twitter.com/getplebbit" target="_blank" rel="noopener noreferrer">Twitter</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="https://discord.gg/E7ejphwzGW" target="_blank" rel="noopener noreferrer">Discord</a>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</Footer>
|
2023-04-22 13:11:42 +02:00
|
|
|
<div style={{
|
|
|
|
|
textAlign: "center",
|
|
|
|
|
fontSize: "11px",
|
2023-04-23 08:43:53 +02:00
|
|
|
marginBottom: "2em",
|
2023-04-22 13:11:42 +02:00
|
|
|
}}>
|
2023-04-24 20:00:11 +00:00
|
|
|
plebchan v{version}. GPL-2.0
|
2023-04-22 13:11:42 +02:00
|
|
|
</div>
|
2023-04-21 10:47:39 +02:00
|
|
|
</Container>
|
|
|
|
|
</>
|
2023-02-02 21:58:02 +01:00
|
|
|
)
|
|
|
|
|
};
|
2023-01-31 23:08:57 +01:00
|
|
|
|
|
|
|
|
export default Home;
|