diff --git a/src/components/layout/header/Actions/ToggleEditMode/ToggleEditMode.tsx b/src/components/layout/header/Actions/ToggleEditMode/ToggleEditMode.tsx index aed97282c..09956261d 100644 --- a/src/components/layout/header/Actions/ToggleEditMode/ToggleEditMode.tsx +++ b/src/components/layout/header/Actions/ToggleEditMode/ToggleEditMode.tsx @@ -1,19 +1,20 @@ import axios from 'axios'; import Consola from 'consola'; -import { ActionIcon, Button, Group, Popover, Text } from '@mantine/core'; -import { IconEditCircle, IconEditCircleOff, IconX } from '@tabler/icons'; +import { ActionIcon, Button, Group, Title, Tooltip } from '@mantine/core'; +import { IconEditCircle, IconEditCircleOff } from '@tabler/icons'; import { getCookie } from 'cookies-next'; import { Trans, useTranslation } from 'next-i18next'; -import { useEffect, useState } from 'react'; +import { useEffect } from 'react'; +import { cleanNotifications, showNotification } from '@mantine/notifications'; import { useConfigContext } from '../../../../../config/provider'; import { useScreenSmallerThan } from '../../../../../hooks/useScreenSmallerThan'; import { useEditModeStore } from '../../../../Dashboard/Views/useEditModeStore'; import { AddElementAction } from '../AddElementAction/AddElementAction'; +import { useColorTheme } from '../../../../../tools/color'; export const ToggleEditModeAction = () => { const { enabled, toggleEditMode } = useEditModeStore(); - const [popoverManuallyHidden, setPopoverManuallyHidden] = useState(); const { t } = useTranslation('layout/header/actions/toggle-edit-mode'); @@ -29,21 +30,45 @@ export const ToggleEditModeAction = () => { const toggleButtonClicked = () => { toggleEditMode(); + if (!enabled) { + showNotification({ + styles: (theme) => ({ + root: { + backgroundColor: theme.colors.orange[7], + borderColor: theme.colors.orange[7], - setPopoverManuallyHidden(false); + '&::before': { backgroundColor: theme.white }, + }, + title: { color: theme.white }, + description: { color: theme.white }, + closeButton: { + color: theme.white, + '&:hover': { backgroundColor: theme.colors.orange[7] }, + }, + }), + radius: 'md', + autoClose: false, + title: {t('popover.title')}, + message: , + }); + } else { + cleanNotifications(); + } }; + const { primaryColor, secondaryColor } = useColorTheme(); const ToggleButtonDesktop = () => ( - + + + ); const ToggleActionIconMobile = () => ( @@ -59,45 +84,24 @@ export const ToggleEditModeAction = () => { ); return ( - - - {smallerThanSm ? ( - enabled ? ( - - - - - ) : ( + <> + {smallerThanSm ? ( + enabled ? ( + + - ) - ) : enabled ? ( - - - {enabled && } - + ) : ( + + ) + ) : enabled ? ( + - )} - - - -
- setPopoverManuallyHidden(true)}> - - -
- - {t('popover.title')} - - - - -
-
+ {enabled && } + + ) : ( + + )} + ); };