mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-19 07:56:02 +01:00
feat(nui): Metadata popover
This commit is contained in:
@@ -1,5 +1,13 @@
|
|||||||
import { useNuiEvent } from "../hooks/useNuiEvent";
|
import { useNuiEvent } from "../hooks/useNuiEvent";
|
||||||
import { Box, Text } from "@chakra-ui/react";
|
import {
|
||||||
|
Box,
|
||||||
|
Text,
|
||||||
|
Popover,
|
||||||
|
PopoverTrigger,
|
||||||
|
Portal,
|
||||||
|
PopoverContent,
|
||||||
|
PopoverBody,
|
||||||
|
} from "@chakra-ui/react";
|
||||||
import { debugData } from "../utils/debugData";
|
import { debugData } from "../utils/debugData";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
@@ -51,8 +59,14 @@ const ContextMenu: React.FC = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<Box
|
||||||
<Box position="absolute" w="xs" h="fit-content" top="20%" right="25%">
|
position="absolute"
|
||||||
|
w="xs"
|
||||||
|
h="fit-content"
|
||||||
|
maxH="20rem"
|
||||||
|
top="20%"
|
||||||
|
right="25%"
|
||||||
|
>
|
||||||
<Box borderRadius="md" bg="gray.700" mb={3}>
|
<Box borderRadius="md" bg="gray.700" mb={3}>
|
||||||
<Text
|
<Text
|
||||||
fontFamily="Poppins"
|
fontFamily="Poppins"
|
||||||
@@ -64,7 +78,15 @@ const ContextMenu: React.FC = () => {
|
|||||||
{contextMenu.title}
|
{contextMenu.title}
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
|
<Box maxH="33rem" overflowY="scroll">
|
||||||
{Object.entries(contextMenu.options).map((option, index) => (
|
{Object.entries(contextMenu.options).map((option, index) => (
|
||||||
|
<Popover
|
||||||
|
placement="right-start"
|
||||||
|
trigger="hover"
|
||||||
|
eventListeners={{ scroll: true }}
|
||||||
|
isLazy
|
||||||
|
>
|
||||||
|
<PopoverTrigger>
|
||||||
<Box
|
<Box
|
||||||
bg="gray.700"
|
bg="gray.700"
|
||||||
borderRadius="md"
|
borderRadius="md"
|
||||||
@@ -89,9 +111,15 @@ const ContextMenu: React.FC = () => {
|
|||||||
<Text>{option[1].description}</Text>
|
<Text>{option[1].description}</Text>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
{option[1]?.metadata && Array.isArray(option[1].metadata) ? (
|
<Portal>
|
||||||
|
<PopoverContent fontFamily="Poppins" bg="gray.800">
|
||||||
|
<PopoverBody>
|
||||||
|
{option[1]?.metadata &&
|
||||||
|
Array.isArray(option[1].metadata) ? (
|
||||||
option[1].metadata.map((metadata: string, index) => (
|
option[1].metadata.map((metadata: string, index) => (
|
||||||
<Text key={`context-metadata-${index}`}>{metadata}</Text>
|
<Text key={`context-metadata-${index}`}>
|
||||||
|
{metadata}
|
||||||
|
</Text>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
@@ -105,10 +133,15 @@ const ContextMenu: React.FC = () => {
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
</PopoverBody>
|
||||||
|
</PopoverContent>
|
||||||
|
</Portal>
|
||||||
</Box>
|
</Box>
|
||||||
|
</PopoverTrigger>
|
||||||
|
</Popover>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -40,3 +40,11 @@ code {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
background-color: transparent;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user