mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 23:46:03 +01:00
feat(web): ability to not be able to close the context menu
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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">
|
||||||
|
|||||||
@@ -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[];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user