add subplebbit component

This commit is contained in:
plebeius.eth
2024-03-17 21:47:16 +01:00
parent 1780b9534c
commit 7f8a996eec
6 changed files with 86 additions and 62 deletions
+1
View File
@@ -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;
}
+57
View File
@@ -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;