mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
feat(web/context): context menu exit button
This commit is contained in:
@@ -52,15 +52,17 @@ const ContextMenu: React.FC = () => {
|
|||||||
options: { "": { description: "", metadata: [] } },
|
options: { "": { description: "", metadata: [] } },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const closeContext = () => {
|
||||||
|
setVisible(false);
|
||||||
|
fetchNui("closeContext");
|
||||||
|
};
|
||||||
|
|
||||||
// Hides the context menu on ESC
|
// Hides the context menu on ESC
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!visible) return;
|
if (!visible) return;
|
||||||
|
|
||||||
const keyHandler = (e: KeyboardEvent) => {
|
const keyHandler = (e: KeyboardEvent) => {
|
||||||
if (["Escape"].includes(e.code)) {
|
if (["Escape"].includes(e.code)) closeContext();
|
||||||
setVisible(false);
|
|
||||||
fetchNui("closeContext");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("keydown", keyHandler);
|
window.addEventListener("keydown", keyHandler);
|
||||||
@@ -119,6 +121,22 @@ const ContextMenu: React.FC = () => {
|
|||||||
{contextMenu.title}
|
{contextMenu.title}
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
|
<Flex
|
||||||
|
borderRadius="md"
|
||||||
|
bg="gray.800"
|
||||||
|
flex="1 15%"
|
||||||
|
alignSelf="stretch"
|
||||||
|
textAlign="center"
|
||||||
|
justifyContent="center"
|
||||||
|
alignItems="center"
|
||||||
|
marginLeft={2}
|
||||||
|
p={2}
|
||||||
|
_hover={{ bg: "gray.700" }}
|
||||||
|
transition="300ms"
|
||||||
|
onClick={() => closeContext()}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon="xmark" fontSize={20} />
|
||||||
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Box maxH={560} overflowY="scroll">
|
<Box maxH={560} overflowY="scroll">
|
||||||
{Object.entries(contextMenu.options).map((option, index) => (
|
{Object.entries(contextMenu.options).map((option, index) => (
|
||||||
|
|||||||
Reference in New Issue
Block a user