diff --git a/packages/frontend/src/components/Dialog/Dialog.tsx b/packages/frontend/src/components/Dialog/Dialog.tsx index 804db65a01..df4db2a367 100644 --- a/packages/frontend/src/components/Dialog/Dialog.tsx +++ b/packages/frontend/src/components/Dialog/Dialog.tsx @@ -60,7 +60,6 @@ const Dialog = React.memo( const onClose = (value: any) => { props.onClose && props.onClose(value) - dialog.current!.style.display = 'none' } const onCancel = (ev: React.BaseSyntheticEvent) => { @@ -72,7 +71,6 @@ const Dialog = React.memo( useEffect(() => { // calling showModal is "only" the way to have ::backdrop dialog.current?.showModal() - dialog.current!.style.display = 'flex' }) let style diff --git a/packages/frontend/src/components/Dialog/styles.module.scss b/packages/frontend/src/components/Dialog/styles.module.scss index 1debebf310..c3c231311a 100644 --- a/packages/frontend/src/components/Dialog/styles.module.scss +++ b/packages/frontend/src/components/Dialog/styles.module.scss @@ -3,8 +3,13 @@ $paddingHorizontal: 30px; $paddingVertical: 20px; .dialog { + opacity: 0; padding: 0; + &:last-of-type { + opacity: 1; + } + &.unstyled { background: none; width: 100vw; diff --git a/packages/frontend/src/components/Settings/Settings.tsx b/packages/frontend/src/components/Settings/Settings.tsx index 2a6991feb9..a397864595 100644 --- a/packages/frontend/src/components/Settings/Settings.tsx +++ b/packages/frontend/src/components/Settings/Settings.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react' +import React, { useEffect } from 'react' import { useSettingsStore } from '../../stores/settings' import { SendBackupDialog } from '../dialogs/SetupMultiDevice' @@ -20,19 +20,11 @@ import useTranslationFunction from '../../hooks/useTranslationFunction' import type { DialogProps } from '../../contexts/DialogContext' -type SettingsView = - | 'main' - | 'chats_and_media' - | 'notifications' - | 'appearance' - | 'advanced' - export default function Settings({ onClose }: DialogProps) { const { openDialog } = useDialog() // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const settingsStore = useSettingsStore()[0]! const tx = useTranslationFunction() - const [settingsMode, setSettingsMode] = useState('main') useEffect(() => { if (window.__settingsOpened) { @@ -48,137 +40,157 @@ export default function Settings({ onClose }: DialogProps) { return ( - {settingsMode === 'main' && ( - <> - - - - { - openDialog(EditProfileDialog, { - settingsStore, - }) - }} - > - {tx('pref_edit_profile')} - - - setSettingsMode('chats_and_media')} - > - {tx('pref_chats_and_media')} - - setSettingsMode('notifications')} - > - {tx('pref_notifications')} - - setSettingsMode('appearance')} - > - {tx('pref_appearance')} - - { - openDialog(SendBackupDialog) - onClose() - }} - > - {tx('multidevice_title')} - - - setSettingsMode('advanced')} - > - {tx('menu_advanced')} - - - {!runtime.getRuntimeInfo().isMac && ( - runtime.openLink(donationUrl)} - isLink - > - {tx('donate')} - - )} - runtime.openHelpWindow()} - > - {tx('menu_help')} - - openDialog(About)}> - {tx('global_menu_help_about_desktop')} - - - - )} - {settingsMode === 'chats_and_media' && ( - <> - setSettingsMode('main')} - onClose={onClose} - /> - - - - - )} - {settingsMode === 'notifications' && ( - <> - setSettingsMode('main')} - onClose={onClose} - /> - - - - - )} - {settingsMode === 'appearance' && ( - <> - setSettingsMode('main')} - onClose={onClose} - /> - - - - - )} - {settingsMode === 'advanced' && ( - <> - setSettingsMode('main')} - onClose={onClose} - /> - - - - - )} + + + + { + openDialog(EditProfileDialog, { + settingsStore, + }) + }} + > + {tx('pref_edit_profile')} + + + openDialog(SettingsDialogChatsAndMedia)} + > + {tx('pref_chats_and_media')} + + openDialog(SettingsDialogNotifications)} + > + {tx('pref_notifications')} + + openDialog(SettingsDialogAppearance)} + > + {tx('pref_appearance')} + + { + openDialog(SendBackupDialog) + }} + > + {tx('multidevice_title')} + + + openDialog(SettingsDialogAdvanced)} + > + {tx('menu_advanced')} + + + {!runtime.getRuntimeInfo().isMac && ( + runtime.openLink(donationUrl)} + isLink + > + {tx('donate')} + + )} + runtime.openHelpWindow()} + > + {tx('menu_help')} + + openDialog(About)}> + {tx('global_menu_help_about_desktop')} + + + + ) +} + +function SettingsDialogChatsAndMedia({ onClose }: DialogProps) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const settingsStore = useSettingsStore()[0]! + const tx = useTranslationFunction() + return ( + + + + + + + ) +} + +function SettingsDialogNotifications({ onClose }: DialogProps) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const settingsStore = useSettingsStore()[0]! + const tx = useTranslationFunction() + return ( + + + + + + + ) +} + +function SettingsDialogAppearance({ onClose }: DialogProps) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const settingsStore = useSettingsStore()[0]! + const tx = useTranslationFunction() + + return ( + + + + + + + ) +} + +function SettingsDialogAdvanced({ onClose }: DialogProps) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const settingsStore = useSettingsStore()[0]! + const tx = useTranslationFunction() + return ( + + + + + ) }