aboutsummaryrefslogtreecommitdiff
path: root/src/components/VencordSettings/shared.tsx
diff options
context:
space:
mode:
authorV <vendicated@riseup.net>2023-05-12 01:40:43 +0200
committerGitHub <noreply@github.com>2023-05-12 01:40:43 +0200
commit5c5b009c4180b73603a9c3a6c6663f889a2e2062 (patch)
tree9f586ff1e4491bbd8d7ac046d60bbae081d1d6f8 /src/components/VencordSettings/shared.tsx
parent0c54b1fa1d8f9d858baf912bb4b1efd9d3c0ec93 (diff)
downloadVencord-5c5b009c4180b73603a9c3a6c6663f889a2e2062.tar.gz
Vencord-5c5b009c4180b73603a9c3a6c6663f889a2e2062.tar.bz2
Vencord-5c5b009c4180b73603a9c3a6c6663f889a2e2062.zip
Settings: Fix resetting scroll/search when getting a ping (#1106)
Diffstat (limited to 'src/components/VencordSettings/shared.tsx')
-rw-r--r--src/components/VencordSettings/shared.tsx51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/components/VencordSettings/shared.tsx b/src/components/VencordSettings/shared.tsx
new file mode 100644
index 0000000..0d3910d
--- /dev/null
+++ b/src/components/VencordSettings/shared.tsx
@@ -0,0 +1,51 @@
+/*
+ * Vencord, a modification for Discord's desktop app
+ * Copyright (c) 2023 Vendicated and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+
+import "./settingsStyles.css";
+
+import ErrorBoundary from "@components/ErrorBoundary";
+import { handleComponentFailed } from "@components/handleComponentFailed";
+import { Margins } from "@utils/margins";
+import { onlyOnce } from "@utils/onlyOnce";
+import { Forms, Text } from "@webpack/common";
+import type { ComponentType, PropsWithChildren } from "react";
+
+export function SettingsTab({ title, children }: PropsWithChildren<{ title: string; }>) {
+ return (
+ <Forms.FormSection>
+ <Text
+ variant="heading-lg/semibold"
+ tag="h2"
+ className={Margins.bottom16}
+ >
+ {title}
+ </Text>
+
+ {children}
+ </Forms.FormSection>
+ );
+}
+
+const onError = onlyOnce(handleComponentFailed);
+
+export function wrapTab(component: ComponentType, tab: string) {
+ return ErrorBoundary.wrap(component, {
+ message: `Failed to render the ${tab} tab. If this issue persists, try using the installer to reinstall!`,
+ onError,
+ });
+}