From 572bfcee6ce343c6bf9d69262576de4e57c01500 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Tue, 27 Sep 2022 16:57:46 +0200 Subject: Fix Settings UI --- src/components/ErrorBoundary.tsx | 6 +++--- src/components/Flex.tsx | 17 +++++++++++++++++ src/components/Settings.tsx | 35 ++++++++++++++++------------------- 3 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 src/components/Flex.tsx (limited to 'src/components') diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx index e903947..2b754b2 100644 --- a/src/components/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary.tsx @@ -1,5 +1,5 @@ import Logger from "../utils/logger"; -import { Card, React } from "../webpack/common"; +import { React } from "../webpack/common"; interface Props { fallback?: React.ComponentType>; @@ -49,7 +49,7 @@ export default class ErrorBoundary extends React.Component; return ( - {this.state.error} - + ); } } diff --git a/src/components/Flex.tsx b/src/components/Flex.tsx new file mode 100644 index 0000000..c369767 --- /dev/null +++ b/src/components/Flex.tsx @@ -0,0 +1,17 @@ +import { PropsWithChildren } from "react"; +import type { React } from '../webpack/common'; + +export function Flex(props: React.PropsWithChildren<{ + flexDirection?: React.CSSProperties["flexDirection"]; + style?: React.CSSProperties; +}>) { + props.style ??= {}; + props.style.flexDirection ||= props.flexDirection; + props.style.gap ??= "1em"; + props.style.display = "flex"; + return ( +
+ {props.children} +
+ ); +} diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx index d5b655b..1950d7a 100644 --- a/src/components/Settings.tsx +++ b/src/components/Settings.tsx @@ -3,10 +3,11 @@ import Plugins from 'plugins'; import { useSettings } from "../api/settings"; import IpcEvents from "../utils/IpcEvents"; -import { Button, ButtonProps, Flex, Switch, Forms, React } from "../webpack/common"; +import { Button, Switch, Forms, React } from "../webpack/common"; import ErrorBoundary from "./ErrorBoundary"; import { startPlugin } from "../plugins"; import { stopPlugin } from '../plugins/index'; +import { Flex } from './Flex'; export default ErrorBoundary.wrap(function Settings(props) { const [settingsDir, , settingsDirPending] = useAwaiter(() => VencordNative.ipc.invoke(IpcEvents.GET_SETTINGS_DIR), "Loading..."); @@ -32,24 +33,20 @@ export default ErrorBoundary.wrap(function Settings(props) { SettingsDir: {settingsDir} - - - - - - + + Settings