mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Allow menu to open when icon is disabled
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
2024dd9412
commit
f5674dc76f
@ -44,8 +44,9 @@
|
|||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.disabled,&.inactive {
|
&.disabled {
|
||||||
opacity: 0.4;
|
opacity: 0.4;
|
||||||
|
cursor: default;
|
||||||
filter: grayscale(0.7);
|
filter: grayscale(0.7);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
@ -55,14 +56,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.disabled {
|
|
||||||
cursor: default;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.inactive {
|
|
||||||
cursor: context-menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.isDragging {
|
&.isDragging {
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,6 @@ export interface HotbarIconProps extends DOMAttributes<HTMLElement> {
|
|||||||
active?: boolean;
|
active?: boolean;
|
||||||
menuItems?: CatalogEntityContextMenu[];
|
menuItems?: CatalogEntityContextMenu[];
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
inactive?: boolean;
|
|
||||||
size?: number;
|
size?: number;
|
||||||
background?: string;
|
background?: string;
|
||||||
}
|
}
|
||||||
@ -66,7 +65,7 @@ function onMenuItemClick(menuItem: CatalogEntityContextMenu) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const HotbarIcon = observer(({menuItems = [], size = 40, ...props}: HotbarIconProps) => {
|
export const HotbarIcon = observer(({menuItems = [], size = 40, ...props}: HotbarIconProps) => {
|
||||||
const { uid, title, src, material, active, className, source, disabled, onMenuOpen, onClick, inactive, children, ...rest } = props;
|
const { uid, title, src, material, active, className, source, disabled, onMenuOpen, onClick, children, ...rest } = props;
|
||||||
const id = `hotbarIcon-${uid}`;
|
const id = `hotbarIcon-${uid}`;
|
||||||
const [menuOpen, setMenuOpen] = useState(false);
|
const [menuOpen, setMenuOpen] = useState(false);
|
||||||
|
|
||||||
@ -96,7 +95,7 @@ export const HotbarIcon = observer(({menuItems = [], size = 40, ...props}: Hotba
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cssNames("HotbarIcon flex", className, { disabled, inactive })}>
|
<div className={cssNames("HotbarIcon flex", className, { disabled })}>
|
||||||
<MaterialTooltip title={`${title || "unknown"} (${source || "unknown"})`} placement="right">
|
<MaterialTooltip title={`${title || "unknown"} (${source || "unknown"})`} placement="right">
|
||||||
<div id={id}>
|
<div id={id}>
|
||||||
{renderIcon()}
|
{renderIcon()}
|
||||||
@ -111,10 +110,8 @@ export const HotbarIcon = observer(({menuItems = [], size = 40, ...props}: Hotba
|
|||||||
toggleEvent="contextmenu"
|
toggleEvent="contextmenu"
|
||||||
position={{right: true, bottom: true }} // FIXME: position does not work
|
position={{right: true, bottom: true }} // FIXME: position does not work
|
||||||
open={() => {
|
open={() => {
|
||||||
if (!disabled) {
|
onMenuOpen?.();
|
||||||
onMenuOpen?.();
|
toggleMenu();
|
||||||
toggleMenu();
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
close={() => toggleMenu()}>
|
close={() => toggleMenu()}>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -163,7 +163,7 @@ export class HotbarMenu extends React.Component<Props> {
|
|||||||
onClick: () => this.removeItem(item.entity.uid)
|
onClick: () => this.removeItem(item.entity.uid)
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
inactive
|
disabled
|
||||||
size={40}
|
size={40}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user