From bc06d88db030823e4dd1b9a68461e8549ab617d4 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Fri, 2 Jan 2026 22:19:32 +0100 Subject: [PATCH] Use AwaitableComponent for "CreateThemeDialog" --- .../theme/components/CreateThemeButton.tsx | 45 ++- .../theme/components/CreateThemeDialog.tsx | 18 +- .../theme/components/ThemePreview.tsx | 343 +++++++++--------- 3 files changed, 201 insertions(+), 205 deletions(-) diff --git a/src/features/theme/components/CreateThemeButton.tsx b/src/features/theme/components/CreateThemeButton.tsx index 57b65477..38a15d99 100644 --- a/src/features/theme/components/CreateThemeButton.tsx +++ b/src/features/theme/components/CreateThemeButton.tsx @@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next'; import Stack from '@mui/material/Stack'; import Button from '@mui/material/Button'; import AddCircleIcon from '@mui/icons-material/AddCircle'; -import { bindDialog, bindTrigger, usePopupState } from 'material-ui-popup-state/hooks'; +import { AwaitableComponent } from 'awaitable-component'; import { CustomTooltip } from '@/base/components/CustomTooltip.tsx'; import { ThemeCreationDialog } from '@/features/theme/components/CreateThemeDialog.tsx'; import { TypographyMaxLines } from '@/base/components/texts/TypographyMaxLines.tsx'; @@ -18,29 +18,26 @@ import { TypographyMaxLines } from '@/base/components/texts/TypographyMaxLines.t export const CreateThemeButton = () => { const { t } = useTranslation(); - const popupState = usePopupState({ variant: 'popover', popupId: 'theme-creation-dialog' }); - return ( - <> - - - - - {t('settings.appearance.theme.create.title')} - - - - {popupState.isOpen && } - + + + + + {t('settings.appearance.theme.create.title')} + + + ); }; diff --git a/src/features/theme/components/CreateThemeDialog.tsx b/src/features/theme/components/CreateThemeDialog.tsx index 8fad91b2..210121d8 100644 --- a/src/features/theme/components/CreateThemeDialog.tsx +++ b/src/features/theme/components/CreateThemeDialog.tsx @@ -11,7 +11,6 @@ import { useState } from 'react'; import Typography from '@mui/material/Typography'; import Stack from '@mui/material/Stack'; import Button from '@mui/material/Button'; -import { bindDialog } from 'material-ui-popup-state/hooks'; import Dialog from '@mui/material/Dialog'; import DialogTitle from '@mui/material/DialogTitle'; import DialogContent from '@mui/material/DialogContent'; @@ -19,6 +18,7 @@ import DialogActions from '@mui/material/DialogActions'; import TextField from '@mui/material/TextField'; import Link from '@mui/material/Link'; import { jsonrepair } from 'jsonrepair'; +import { AwaitableComponentProps } from 'awaitable-component'; import { getErrorMessage, jsonSaveParse } from '@/lib/HelperFunctions.ts'; import { AppTheme, isThemeNameUnique } from '@/features/theme/services/AppThemes.ts'; import { @@ -91,11 +91,13 @@ const dialogModeToTranslationKey: Record< }; export const ThemeCreationDialog = ({ - bindDialogProps, mode, appTheme = baseCustomTheme, -}: { - bindDialogProps: ReturnType; + isVisible, + onExitComplete, + onSubmit, + onDismiss, +}: AwaitableComponentProps & { mode: DialogMode; appTheme?: AppTheme; }) => { @@ -117,7 +119,7 @@ export const ThemeCreationDialog = ({ const [didThemeChange, setDidThemeChange] = useState(mode === 'create'); return ( - + {t(dialogModeToTranslationKey[mode].title)} {loading && } @@ -212,12 +214,12 @@ export const ThemeCreationDialog = ({ )} -