Skip to content

Commit

Permalink
feat(web): ability to not be able to close the context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeWasTakenn committed Sep 8, 2022
1 parent 105756e commit adf0994
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions resource/interface/client/context.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function lib.showContext(id)
action = 'showContext',
data = {
title = data.title,
canClose = data.canClose,
menu = data.menu,
options = data.options
}
Expand Down
13 changes: 10 additions & 3 deletions web/src/features/menu/context/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const ContextMenu: React.FC = () => {
});

const closeContext = () => {
if (contextMenu.canClose === false) return;
setVisible(false);
fetchNui('closeContext');
};
Expand Down Expand Up @@ -76,19 +77,25 @@ 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"
justifyContent="center"
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">
Expand Down
1 change: 1 addition & 0 deletions web/src/interfaces/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ export interface Options {
export interface ContextMenuProps {
title: string;
menu?: string;
canClose?: boolean;
options: Options | Option[];
}

0 comments on commit adf0994

Please sign in to comment.