mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 07:25:48 +01:00
✨ Add edit mode button
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"tooltip": "The edit mode enables you to configure your dashboard",
|
||||||
|
"button": {
|
||||||
|
"disabled": "Enter Edit Mode",
|
||||||
|
"enabled": "Exit Edit Mode"
|
||||||
|
},
|
||||||
|
"popover": {
|
||||||
|
"title": "Edit mode is enabled",
|
||||||
|
"text": "You can adjust and configure your apps now"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { Button, Popover, Tooltip, Text } from '@mantine/core';
|
||||||
|
import { IconEditCircle, IconEditCircleOff } from '@tabler/icons';
|
||||||
|
import { useTranslation } from 'next-i18next';
|
||||||
|
|
||||||
|
import { useEditModeStore } from '../../../../Dashboard/Views/useEditModeStore';
|
||||||
|
|
||||||
|
export const ToggleEditModeAction = () => {
|
||||||
|
const { t } = useTranslation('layout/header/actions/toggle-edit-mode');
|
||||||
|
|
||||||
|
const { enabled, toggleEditMode } = useEditModeStore();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip label={t('tooltip')} withinPortal>
|
||||||
|
<Popover opened={enabled} width={250} withArrow>
|
||||||
|
<Popover.Target>
|
||||||
|
<Button
|
||||||
|
onClick={() => toggleEditMode()}
|
||||||
|
leftIcon={enabled ? <IconEditCircleOff /> : <IconEditCircle />}
|
||||||
|
variant="default"
|
||||||
|
radius="md"
|
||||||
|
color="blue"
|
||||||
|
style={{ height: 'auto', alignSelf: 'stretch' }}
|
||||||
|
>
|
||||||
|
{enabled ? t('button.enabled') : t('button.disabled')}
|
||||||
|
</Button>
|
||||||
|
</Popover.Target>
|
||||||
|
<Popover.Dropdown>
|
||||||
|
<Text align="center">
|
||||||
|
<Text weight="bold">{t('popover.title')}</Text>
|
||||||
|
{t('popover.text')}
|
||||||
|
</Text>
|
||||||
|
</Popover.Dropdown>
|
||||||
|
</Popover>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import { ActionIcon, Box, createStyles, Group, Header as MantineHeader } from '@mantine/core';
|
import { Box, createStyles, Group, Header as MantineHeader, Text } from '@mantine/core';
|
||||||
import { openContextModal } from '@mantine/modals';
|
import { openContextModal } from '@mantine/modals';
|
||||||
import { IconCode } from '@tabler/icons';
|
|
||||||
import { useConfigContext } from '../../../config/provider';
|
import { useConfigContext } from '../../../config/provider';
|
||||||
import { Logo } from '../Logo';
|
import { Logo } from '../Logo';
|
||||||
import { useCardStyles } from '../useCardStyles';
|
import { useCardStyles } from '../useCardStyles';
|
||||||
import { AddElementAction } from './Actions/AddElementAction/AddElementAction';
|
import { AddElementAction } from './Actions/AddElementAction/AddElementAction';
|
||||||
|
import { ToggleEditModeAction } from './Actions/ToggleEditMode/ToggleEditMode';
|
||||||
import { Search } from './Search';
|
import { Search } from './Search';
|
||||||
import { SettingsMenu } from './SettingsMenu';
|
import { SettingsMenu } from './SettingsMenu';
|
||||||
|
|
||||||
@@ -23,10 +23,7 @@ export function Header(props: any) {
|
|||||||
<Logo />
|
<Logo />
|
||||||
</Box>
|
</Box>
|
||||||
<Group position="right" noWrap>
|
<Group position="right" noWrap>
|
||||||
<Search />
|
<Text
|
||||||
<AddElementAction />
|
|
||||||
|
|
||||||
<ActionIcon
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openContextModal({
|
openContextModal({
|
||||||
modal: 'changeTilePosition',
|
modal: 'changeTilePosition',
|
||||||
@@ -36,14 +33,14 @@ export function Header(props: any) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
variant="default"
|
variant="link"
|
||||||
radius="md"
|
|
||||||
size="xl"
|
|
||||||
color="blue"
|
|
||||||
>
|
>
|
||||||
<IconCode />
|
Test: Open Change Pos Modal
|
||||||
</ActionIcon>
|
</Text>
|
||||||
|
|
||||||
|
<Search />
|
||||||
|
<AddElementAction />
|
||||||
|
<ToggleEditModeAction />
|
||||||
<SettingsMenu />
|
<SettingsMenu />
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export const dashboardNamespaces = [
|
|||||||
'layout/app-shelf-menu',
|
'layout/app-shelf-menu',
|
||||||
'layout/tools',
|
'layout/tools',
|
||||||
'layout/element-selector/selector',
|
'layout/element-selector/selector',
|
||||||
|
'layout/header/actions/toggle-edit-mode',
|
||||||
'settings/common',
|
'settings/common',
|
||||||
'settings/general/theme-selector',
|
'settings/general/theme-selector',
|
||||||
'settings/general/config-changer',
|
'settings/general/config-changer',
|
||||||
|
|||||||
Reference in New Issue
Block a user