mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
add subplebbit component
This commit is contained in:
+17
@@ -16,6 +16,23 @@ const App = () => {
|
|||||||
document.body.classList.add(theme);
|
document.body.classList.add(theme);
|
||||||
}, [theme]);
|
}, [theme]);
|
||||||
|
|
||||||
|
// const globalLayout = (
|
||||||
|
// <>
|
||||||
|
// <ChallengeModal />
|
||||||
|
// <Outlet />
|
||||||
|
// </>
|
||||||
|
// );
|
||||||
|
|
||||||
|
// const boardLayout = (
|
||||||
|
// <>
|
||||||
|
// <TopNav />
|
||||||
|
// <ImageBanner />
|
||||||
|
// <PostForm />
|
||||||
|
// <Stats />
|
||||||
|
// <Outlet />
|
||||||
|
// </>
|
||||||
|
// );
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`${styles.app} ${isInHomeView ? 'yotsuba' : theme}`}>
|
<div className={`${styles.app} ${isInHomeView ? 'yotsuba' : theme}`}>
|
||||||
<Routes>
|
<Routes>
|
||||||
|
|||||||
@@ -7,17 +7,6 @@
|
|||||||
min-width: 750px;
|
min-width: 750px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.debug {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
padding: 0.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.debug select {
|
|
||||||
margin: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo img {
|
.logo img {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
height: 120px;
|
height: 120px;
|
||||||
|
|||||||
+1
-51
@@ -1,50 +1,10 @@
|
|||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import styles from './home.module.css';
|
import styles from './home.module.css';
|
||||||
import useTheme from '../../hooks/use-theme';
|
|
||||||
import { Link, useNavigate } from 'react-router-dom';
|
import { Link, useNavigate } from 'react-router-dom';
|
||||||
import { Trans, useTranslation } from 'react-i18next';
|
import { Trans, useTranslation } from 'react-i18next';
|
||||||
import { useDefaultSubplebbitAddresses } from '../../hooks/use-default-subplebbits';
|
import { useDefaultSubplebbitAddresses } from '../../hooks/use-default-subplebbits';
|
||||||
import { useEffect } from 'react';
|
|
||||||
import packageJson from '../../../package.json';
|
import packageJson from '../../../package.json';
|
||||||
|
|
||||||
// TODO: remove theme and languages selectors for debugging
|
|
||||||
const ThemeSettings = () => {
|
|
||||||
const [theme, setTheme] = useTheme();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<select value={theme} onChange={(e) => setTheme(e.target.value)}>
|
|
||||||
<option value='yotsuba'>yotsuba</option>
|
|
||||||
<option value='yotsuba-b'>yotsuba-b</option>
|
|
||||||
<option value='tomorrow'>tomorrow</option>
|
|
||||||
</select>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
const availableLanguages = ['ar', 'bn', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa', 'fi', 'fil', 'fr', 'he', 'hi', 'hu', 'id', 'it', 'ja', 'ko', 'mr', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sq', 'sv', 'te', 'th', 'tr', 'uk', 'ur', 'vi', 'zh'];
|
|
||||||
|
|
||||||
const LanguageSettings = () => {
|
|
||||||
const { i18n } = useTranslation();
|
|
||||||
const { changeLanguage, language } = i18n;
|
|
||||||
|
|
||||||
const onSelectLanguage = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
||||||
changeLanguage(e.target.value);
|
|
||||||
window.location.reload();
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={styles.languageSettings}>
|
|
||||||
<select value={language} onChange={onSelectLanguage}>
|
|
||||||
{availableLanguages.map((lang) => (
|
|
||||||
<option key={lang} value={lang}>
|
|
||||||
{lang}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const isValidAddress = (address: string): boolean => {
|
const isValidAddress = (address: string): boolean => {
|
||||||
if (address.includes('/') || address.includes('\\') || address.includes(' ')) {
|
if (address.includes('/') || address.includes('\\') || address.includes(' ')) {
|
||||||
return false;
|
return false;
|
||||||
@@ -121,7 +81,7 @@ const Boards = () => {
|
|||||||
<div className={styles.list}>
|
<div className={styles.list}>
|
||||||
{defaultSubplebbitAddresses.map((address) => (
|
{defaultSubplebbitAddresses.map((address) => (
|
||||||
<div className={styles.subplebbit} key={address}>
|
<div className={styles.subplebbit} key={address}>
|
||||||
<Link to={`/b/${address}`}>{address}</Link>
|
<Link to={`/p/${address}`}>{address}</Link>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -234,18 +194,8 @@ const Footer = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
const [, setTheme] = useTheme();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setTheme('yotsuba');
|
|
||||||
}, [setTheme]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
<div className={styles.debug}>
|
|
||||||
<LanguageSettings />
|
|
||||||
<ThemeSettings />
|
|
||||||
</div>
|
|
||||||
<Link to='/'>
|
<Link to='/'>
|
||||||
<div className={styles.logo}>
|
<div className={styles.logo}>
|
||||||
<img alt='plebchan' src='/assets/logo/logo-transparent.png' />
|
<img alt='plebchan' src='/assets/logo/logo-transparent.png' />
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './subplebbit';
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
.debug {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug select {
|
||||||
|
margin: 2px;
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import useTheme from '../../hooks/use-theme';
|
||||||
|
import styles from './subplebbit.module.css';
|
||||||
|
|
||||||
|
// TODO: remove theme and languages selectors for debugging
|
||||||
|
const ThemeSettings = () => {
|
||||||
|
const [theme, setTheme] = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<select value={theme} onChange={(e) => setTheme(e.target.value)}>
|
||||||
|
<option value='yotsuba'>Yotsuba</option>
|
||||||
|
<option value='yotsuba-b'>Yotsuba B</option>
|
||||||
|
<option value='futaba'>Futaba</option>
|
||||||
|
<option value='burichan'>Burichan</option>
|
||||||
|
<option value='tomorrow'>Tomorrow</option>
|
||||||
|
<option value='photon'>Photon</option>
|
||||||
|
</select>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// prettier-ignore
|
||||||
|
const availableLanguages = ['ar', 'bn', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa', 'fi', 'fil', 'fr', 'he', 'hi', 'hu', 'id', 'it', 'ja', 'ko', 'mr', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sq', 'sv', 'te', 'th', 'tr', 'uk', 'ur', 'vi', 'zh'];
|
||||||
|
|
||||||
|
const LanguageSettings = () => {
|
||||||
|
const { i18n } = useTranslation();
|
||||||
|
const { changeLanguage, language } = i18n;
|
||||||
|
|
||||||
|
const onSelectLanguage = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
||||||
|
changeLanguage(e.target.value);
|
||||||
|
window.location.reload();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.languageSettings}>
|
||||||
|
<select value={language} onChange={onSelectLanguage}>
|
||||||
|
{availableLanguages.map((lang) => (
|
||||||
|
<option key={lang} value={lang}>
|
||||||
|
{lang}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const Subplebbit = () => {
|
||||||
|
return (
|
||||||
|
<div className={styles.content}>
|
||||||
|
<div className={styles.debug}>
|
||||||
|
<LanguageSettings />
|
||||||
|
<ThemeSettings />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Subplebbit;
|
||||||
Reference in New Issue
Block a user