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 @@ function lib.showContext(id)
action = 'showContext', action = 'showContext',
data = { data = {
title = data.title, title = data.title,
canClose = data.canClose,
menu = data.menu, menu = data.menu,
options = data.options options = data.options
} }

View File

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

View File

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