import { Text } from "preact-i18n"; import { useEffect } from "preact/hooks"; import styles from "./Settings.module.scss"; import { Children } from "../../types/Preact"; import Header from '../../components/ui/Header'; import Category from '../../components/ui/Category'; import IconButton from "../../components/ui/IconButton"; import LineDivider from "../../components/ui/LineDivider"; import { ArrowLeft, X, XCircle } from "@styled-icons/feather"; import { Switch, useHistory, useParams } from "react-router-dom"; import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice"; import ButtonItem from "../../components/navigation/items/ButtonItem"; interface Props { pages: { category?: Children, divider?: boolean, id: string, icon: Children title: Children }[] custom?: Children children: Children defaultPage: string showExitButton?: boolean switchPage: (to?: string) => void category: 'pages' | 'channel_pages' | 'server_pages' } export function GenericSettings({ pages, switchPage, category, custom, children, defaultPage, showExitButton }: Props) { const history = useHistory(); const { page } = useParams<{ page: string; }>(); function exitSettings() { if (history.length > 0) { history.goBack(); } else { history.push('/'); } } useEffect(() => { function keyDown(e: KeyboardEvent) { if (e.key === "Escape") { exitSettings(); } } document.body.addEventListener("keydown", keyDown); return () => document.body.removeEventListener("keydown", keyDown); }, []); return (