From e6092ad3ddf137aa83f054f34e5f1af78b31c25a Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 2 May 2022 17:46:16 +0800 Subject: ... --- FrontEnd/src/views/settings/index.tsx | 104 ++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 44 deletions(-) (limited to 'FrontEnd/src/views/settings/index.tsx') diff --git a/FrontEnd/src/views/settings/index.tsx b/FrontEnd/src/views/settings/index.tsx index 8110002b..633bb209 100644 --- a/FrontEnd/src/views/settings/index.tsx +++ b/FrontEnd/src/views/settings/index.tsx @@ -16,6 +16,7 @@ import ChangeAvatarDialog from "./ChangeAvatarDialog"; import ChangeNicknameDialog from "./ChangeNicknameDialog"; import "./index.css"; +import classNames from "classnames"; interface SettingSectionProps { title: I18nText; @@ -35,91 +36,106 @@ const SettingSection: React.FC = ({ title, children }) => { ); }; -interface ButtonSettingItemProps { +interface SettingItemContainerWithoutChildrenProps { title: I18nText; subtext?: I18nText; - onClick: () => void; first?: boolean; danger?: boolean; + style?: React.CSSProperties; + className?: string; + onClick?: () => void; } -const ButtonSettingItem: React.FC = ({ +interface SettingItemContainerProps + extends SettingItemContainerWithoutChildrenProps { + children?: React.ReactNode; +} + +function SettingItemContainer({ title, subtext, - onClick, first, danger, -}) => { + children, + style, + className, + onClick, +}: SettingItemContainerProps): JSX.Element { const { t } = useTranslation(); return (
- {convertI18nText(title, t)} - {subtext && ( +
+
+ {convertI18nText(title, t)} +
{convertI18nText(subtext, t)} - )} +
+
{children}
); +} + +type ButtonSettingItemProps = SettingItemContainerWithoutChildrenProps; + +const ButtonSettingItem: React.FC = ({ + className, + ...props +}) => { + return ( + + ); }; -interface SelectSettingItemProps { - title: I18nText; - subtext?: I18nText; +interface SelectSettingItemProps + extends SettingItemContainerWithoutChildrenProps { options: { value: string; label: I18nText; }[]; value?: string; onSelect: (value: string) => void; - first?: boolean; } const SelectSettingsItem: React.FC = ({ - title, - subtext, options, value, onSelect, - first, + ...props }) => { const { t } = useTranslation(); return ( -
-
-
{convertI18nText(title, t)}
- - {convertI18nText(subtext, t)} - -
-
- {value == null ? ( - - ) : ( - - )} -
-
+ + {value == null ? ( + + ) : ( + + )} + ); }; -- cgit v1.2.3