fix menu-item floating buttons that should only be displayed on hover (#1588)
fix menu-item floating buttons that should only be dis played on hover
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
import type { MouseEvent } from 'react';
|
import { type MouseEvent } from 'react';
|
||||||
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
import { FloatingIconButtonGroup } from '@/ui/button/components/FloatingIconButtonGroup';
|
import { FloatingIconButtonGroup } from '@/ui/button/components/FloatingIconButtonGroup';
|
||||||
import { IconComponent } from '@/ui/icon/types/IconComponent';
|
import { IconComponent } from '@/ui/icon/types/IconComponent';
|
||||||
@ -22,6 +23,17 @@ export type MenuItemProps = {
|
|||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const StyledHoverableMenuItemBase = styled(StyledMenuItemBase)`
|
||||||
|
& .hoverable-buttons {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
&:hover {
|
||||||
|
& .hoverable-buttons {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
export function MenuItem({
|
export function MenuItem({
|
||||||
LeftIcon,
|
LeftIcon,
|
||||||
accent = 'default',
|
accent = 'default',
|
||||||
@ -34,14 +46,18 @@ export function MenuItem({
|
|||||||
const showIconButtons = Array.isArray(iconButtons) && iconButtons.length > 0;
|
const showIconButtons = Array.isArray(iconButtons) && iconButtons.length > 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledMenuItemBase
|
<StyledHoverableMenuItemBase
|
||||||
data-testid={testId ?? undefined}
|
data-testid={testId ?? undefined}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
className={className}
|
className={className}
|
||||||
accent={accent}
|
accent={accent}
|
||||||
>
|
>
|
||||||
<MenuItemLeftContent LeftIcon={LeftIcon ?? undefined} text={text} />
|
<MenuItemLeftContent LeftIcon={LeftIcon ?? undefined} text={text} />
|
||||||
{showIconButtons && <FloatingIconButtonGroup iconButtons={iconButtons} />}
|
<div className="hoverable-buttons">
|
||||||
</StyledMenuItemBase>
|
{showIconButtons && (
|
||||||
|
<FloatingIconButtonGroup iconButtons={iconButtons} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</StyledHoverableMenuItemBase>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user