import './settings.css'; import { useRef } from 'preact/hooks'; import { useSnapshot } from 'valtio'; import logo from '../assets/logo.svg'; import RelativeTime from '../components/relative-time'; import targetLanguages from '../data/lingva-target-languages'; import getTranslateTargetLanguage from '../utils/get-translate-target-language'; import localeCode2Text from '../utils/localeCode2Text'; import states from '../utils/states'; import store from '../utils/store'; function Settings({ onClose }) { const snapStates = useSnapshot(states); const currentTheme = store.local.get('theme') || 'auto'; const themeFormRef = useRef(); const targetLanguage = snapStates.settings.contentTranslationTargetLanguage || null; const systemTargetLanguage = getTranslateTargetLanguage(); const systemTargetLanguageText = localeCode2Text(systemTargetLanguage); return (

Settings

  • { console.log(e); e.preventDefault(); const formData = new FormData(themeFormRef.current); const theme = formData.get('theme'); const html = document.documentElement; if (theme === 'auto') { html.classList.remove('is-light', 'is-dark'); } else { html.classList.toggle('is-light', theme === 'light'); html.classList.toggle('is-dark', theme === 'dark'); } document .querySelector('meta[name="color-scheme"]') .setAttribute( 'content', theme === 'auto' ? 'dark light' : theme, ); if (theme === 'auto') { store.local.del('theme'); } else { store.local.set('theme', theme); } }} >

Experiments

  • {snapStates.settings.contentTranslation && (

    Note: This feature uses an external API to translate, powered by{' '} Lingva Translate .

    )}

About

{' '} { e.preventDefault(); states.showAccount = 'phanpy@hachyderm.io'; }} > @phanpy .

Built {' '} by{' '} { e.preventDefault(); states.showAccount = 'cheeaun@mastodon.social'; }} > @cheeaun .{' '} Privacy Policy .

{__BUILD_TIME__ && (

Last build: {' '} {__COMMIT_HASH__ && ( <> ( {__COMMIT_HASH__} ) )}

)}
); } export default Settings;