feat(web): ability to not be able to close the context menu

This commit is contained in:
Luke
2022-09-08 10:05:44 +02:00
parent 105756ef4e
commit adf0994b3f
3 changed files with 12 additions and 3 deletions

View File

@@ -18,6 +18,7 @@ const ContextMenu: React.FC = () => {
});
const closeContext = () => {
if (contextMenu.canClose === false) return;
setVisible(false);
fetchNui('closeContext');
};
@@ -76,7 +77,8 @@ const ContextMenu: React.FC = () => {
</Box>
<Flex
borderRadius="md"
bg="gray.800"
as="button"
bg={contextMenu.canClose === false ? 'gray.600' : 'gray.800'}
flex="1 15%"
alignSelf="stretch"
textAlign="center"
@@ -84,11 +86,16 @@ const ContextMenu: React.FC = () => {
alignItems="center"
marginLeft={2}
p={2}
_hover={{ bg: 'gray.700' }}
cursor={contextMenu.canClose === false ? 'not-allowed' : undefined}
_hover={{ bg: contextMenu.canClose === false ? undefined : 'gray.700' }}
transition="300ms"
onClick={() => closeContext()}
>
<FontAwesomeIcon icon="xmark" fontSize={20} />
<FontAwesomeIcon
icon="xmark"
fontSize={20}
color={contextMenu.canClose === false ? '#718096' : undefined}
/>
</Flex>
</Flex>
<Box maxH={560} overflowY="scroll">

View File

@@ -21,5 +21,6 @@ export interface Options {
export interface ContextMenuProps {
title: string;
menu?: string;
canClose?: boolean;
options: Options | Option[];
}