mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 15:35:55 +01:00
🐛 Layout issues with toggle edit mode button and popover
This commit is contained in:
@@ -1,31 +1,50 @@
|
|||||||
import { Button, Popover, Tooltip, Text } from '@mantine/core';
|
import { ActionIcon, Button, Flex, Popover, Text, Tooltip } from '@mantine/core';
|
||||||
import { IconEditCircle, IconEditCircleOff } from '@tabler/icons';
|
import { IconEditCircle, IconEditCircleOff, IconX } from '@tabler/icons';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { useScreenSmallerThan } from '../../../../../tools/hooks/useScreenSmallerThan';
|
||||||
|
|
||||||
import { useEditModeStore } from '../../../../Dashboard/Views/useEditModeStore';
|
import { useEditModeStore } from '../../../../Dashboard/Views/useEditModeStore';
|
||||||
|
|
||||||
export const ToggleEditModeAction = () => {
|
export const ToggleEditModeAction = () => {
|
||||||
|
const { enabled, toggleEditMode } = useEditModeStore();
|
||||||
|
const [popoverManuallyHidden, setPopoverManuallyHidden] = useState<boolean>();
|
||||||
|
|
||||||
const { t } = useTranslation('layout/header/actions/toggle-edit-mode');
|
const { t } = useTranslation('layout/header/actions/toggle-edit-mode');
|
||||||
|
|
||||||
const { enabled, toggleEditMode } = useEditModeStore();
|
const smallerThanSm = useScreenSmallerThan('sm');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip label={t('tooltip')} withinPortal>
|
<Tooltip label={t('tooltip')} withinPortal>
|
||||||
<Popover opened={enabled} width={250} withArrow>
|
<Popover opened={enabled && !smallerThanSm && !popoverManuallyHidden} width={250} withArrow>
|
||||||
<Popover.Target>
|
<Popover.Target>
|
||||||
|
{smallerThanSm ? (
|
||||||
|
<ActionIcon variant="default" radius="md" size="xl" color="blue">
|
||||||
|
{enabled ? <IconEditCircleOff /> : <IconEditCircle />}
|
||||||
|
</ActionIcon>
|
||||||
|
) : (
|
||||||
<Button
|
<Button
|
||||||
onClick={() => toggleEditMode()}
|
onClick={() => {
|
||||||
|
toggleEditMode();
|
||||||
|
setPopoverManuallyHidden(false);
|
||||||
|
}}
|
||||||
leftIcon={enabled ? <IconEditCircleOff /> : <IconEditCircle />}
|
leftIcon={enabled ? <IconEditCircleOff /> : <IconEditCircle />}
|
||||||
variant="default"
|
variant="default"
|
||||||
radius="md"
|
radius="md"
|
||||||
color="blue"
|
color="blue"
|
||||||
style={{ height: 'auto', alignSelf: 'stretch' }}
|
style={{ height: 44 }}
|
||||||
>
|
>
|
||||||
{enabled ? t('button.enabled') : t('button.disabled')}
|
<Text>{enabled ? t('button.enabled') : t('button.disabled')}</Text>
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
</Popover.Target>
|
</Popover.Target>
|
||||||
<Popover.Dropdown>
|
<Popover.Dropdown p={4} px={6}>
|
||||||
<Text align="center">
|
<div style={{ position: 'absolute', top: 2, right: 2 }}>
|
||||||
|
<ActionIcon onClick={() => setPopoverManuallyHidden(true)}>
|
||||||
|
<IconX size={18} />
|
||||||
|
</ActionIcon>
|
||||||
|
</div>
|
||||||
|
<Text align="center" size="sm">
|
||||||
<Text weight="bold">{t('popover.title')}</Text>
|
<Text weight="bold">{t('popover.title')}</Text>
|
||||||
{t('popover.text')}
|
{t('popover.text')}
|
||||||
</Text>
|
</Text>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export function Header(props: any) {
|
|||||||
<Box className={classes.hide}>
|
<Box className={classes.hide}>
|
||||||
<Logo />
|
<Logo />
|
||||||
</Box>
|
</Box>
|
||||||
<Group position="right" noWrap>
|
<Group position="right" style={{ maxWidth: 'none' }} noWrap>
|
||||||
<Text
|
<Text
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openContextModal({
|
openContextModal({
|
||||||
@@ -35,7 +35,7 @@ export function Header(props: any) {
|
|||||||
}}
|
}}
|
||||||
variant="link"
|
variant="link"
|
||||||
>
|
>
|
||||||
Test: Open Change Pos Modal
|
Test
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Search />
|
<Search />
|
||||||
|
|||||||
Reference in New Issue
Block a user