import { ArrowBack, X } from "@styled-icons/boxicons-regular"; import { Helmet } from "react-helmet"; import { Switch, useHistory, useParams } from "react-router-dom"; import styles from "./Settings.module.scss"; import classNames from "classnames"; import { Text } from "preact-i18n"; import { useContext, useEffect, useState } from "preact/hooks"; import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice"; import { ThemeContext } from "../../context/Theme"; import Category from "../../components/ui/Category"; import Header from "../../components/ui/Header"; import IconButton from "../../components/ui/IconButton"; import LineDivider from "../../components/ui/LineDivider"; import ButtonItem from "../../components/navigation/items/ButtonItem"; import { Children } from "../../types/Preact"; interface Props { pages: { category?: Children; divider?: boolean; id: string; icon: Children; title: Children; hideTitle?: boolean; }[]; 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 theme = useContext(ThemeContext); const { page } = useParams<{ page: string }>(); const [closing, setClosing] = useState(false); function exitSettings() { setClosing(true); setTimeout(() => { if (history.length > 0) { history.goBack(); } else { history.push("/"); } }, 100); } useEffect(() => { function keyDown(e: KeyboardEvent) { if (e.key === "Escape") { exitSettings(); } } document.body.addEventListener("keydown", keyDown); return () => document.body.removeEventListener("keydown", keyDown); }, []); return (