mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-14 09:25:47 +01:00
🐛 Fix module wrapper hover bug
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
|||||||
import { useHover } from '@mantine/hooks';
|
import { useHover } from '@mantine/hooks';
|
||||||
import { IconAdjustments } from '@tabler/icons';
|
import { IconAdjustments } from '@tabler/icons';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
|
import { useState } from 'react';
|
||||||
import { useConfig } from '../tools/state';
|
import { useConfig } from '../tools/state';
|
||||||
import { IModule } from './ModuleTypes';
|
import { IModule } from './ModuleTypes';
|
||||||
|
|
||||||
@@ -148,7 +149,7 @@ export function ModuleWrapper(props: any) {
|
|||||||
// Remove 'Module' from enabled modules titles
|
// Remove 'Module' from enabled modules titles
|
||||||
const isShown = enabledModules[module.title]?.enabled ?? false;
|
const isShown = enabledModules[module.title]?.enabled ?? false;
|
||||||
//TODO: fix the hover problem
|
//TODO: fix the hover problem
|
||||||
const { hovered, ref } = useHover();
|
const [hovering, setHovering] = useState(false);
|
||||||
|
|
||||||
if (!isShown) {
|
if (!isShown) {
|
||||||
return null;
|
return null;
|
||||||
@@ -158,7 +159,6 @@ export function ModuleWrapper(props: any) {
|
|||||||
<Card
|
<Card
|
||||||
{...props}
|
{...props}
|
||||||
key={module.title}
|
key={module.title}
|
||||||
ref={ref}
|
|
||||||
hidden={!isShown}
|
hidden={!isShown}
|
||||||
withBorder
|
withBorder
|
||||||
radius="lg"
|
radius="lg"
|
||||||
@@ -170,10 +170,17 @@ export function ModuleWrapper(props: any) {
|
|||||||
${(config.settings.appOpacity || 100) / 100}`,
|
${(config.settings.appOpacity || 100) / 100}`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Group position="apart">
|
<motion.div
|
||||||
<ModuleMenu module={module} hovered={hovered} />
|
onHoverStart={() => {
|
||||||
|
setHovering(true);
|
||||||
|
}}
|
||||||
|
onHoverEnd={() => {
|
||||||
|
setHovering(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ModuleMenu module={module} hovered={hovering} />
|
||||||
<module.component />
|
<module.component />
|
||||||
</Group>
|
</motion.div>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -185,6 +192,7 @@ export function ModuleMenu(props: any) {
|
|||||||
<>
|
<>
|
||||||
{module.options && (
|
{module.options && (
|
||||||
<Menu
|
<Menu
|
||||||
|
key={module.title}
|
||||||
withinPortal
|
withinPortal
|
||||||
width="lg"
|
width="lg"
|
||||||
shadow="xl"
|
shadow="xl"
|
||||||
@@ -192,27 +200,23 @@ export function ModuleMenu(props: any) {
|
|||||||
closeOnItemClick={false}
|
closeOnItemClick={false}
|
||||||
radius="md"
|
radius="md"
|
||||||
position="left"
|
position="left"
|
||||||
styles={{
|
|
||||||
dropdown: {
|
|
||||||
// Add shadow and elevation to the body
|
|
||||||
boxShadow: '0 0 14px 14px rgba(0, 0, 0, 0.05)',
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Menu.Target>
|
<Menu.Target>
|
||||||
<Box
|
<motion.div
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: 12,
|
top: 15,
|
||||||
right: 12,
|
right: 15,
|
||||||
|
alignSelf: 'flex-end',
|
||||||
|
}}
|
||||||
|
animate={{
|
||||||
|
opacity: hovered === true ? 1 : 0,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<motion.div initial={{ opacity: 0 }} animate={{ opacity: hovered ? 1 : 0 }}>
|
<ActionIcon>
|
||||||
<ActionIcon>
|
<IconAdjustments />
|
||||||
<IconAdjustments />
|
</ActionIcon>
|
||||||
</ActionIcon>
|
</motion.div>
|
||||||
</motion.div>
|
|
||||||
</Box>
|
|
||||||
</Menu.Target>
|
</Menu.Target>
|
||||||
<Menu.Dropdown>
|
<Menu.Dropdown>
|
||||||
<Menu.Label>Settings</Menu.Label>
|
<Menu.Label>Settings</Menu.Label>
|
||||||
|
|||||||
Reference in New Issue
Block a user