From f346d2ad9964a510379b9910a1621f35f6aaf0f5 Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 25 Mar 2022 23:56:50 +0100 Subject: [PATCH] refactor(nui): Context menu style adjustments --- web/src/components/ContextMenu.tsx | 173 ++++++++++++++++------------- web/src/components/TextUI.tsx | 1 + web/src/index.css | 1 + 3 files changed, 98 insertions(+), 77 deletions(-) diff --git a/web/src/components/ContextMenu.tsx b/web/src/components/ContextMenu.tsx index 6c84346..d62fa3d 100644 --- a/web/src/components/ContextMenu.tsx +++ b/web/src/components/ContextMenu.tsx @@ -2,6 +2,7 @@ import { useNuiEvent } from "../hooks/useNuiEvent"; import { Box, Text, + Flex, Popover, PopoverTrigger, Portal, @@ -41,6 +42,16 @@ debugData([ description: "Even cooler vehicle", metadata: ["Plate: JGM 971", "Status: In garage"], }, + ["Burger"]: { + description: "Make a delicious burger", + metadata: { + ["Bun"]: 3, + ["Lettuce"]: 2, + ["Meat"]: 1, + ["Tomato"]: 1, + ["Cheese"]: 2, + }, + }, }, }, }, @@ -59,89 +70,97 @@ const ContextMenu: React.FC = () => { }); return ( - - - - {contextMenu.title} - - - - {Object.entries(contextMenu.options).map((option, index) => ( - + + - - - {/* TODO: react-markdown (?) */} - - - {option[0]} - - - {option[1].description && ( + {contextMenu.title} + + + + {Object.entries(contextMenu.options).map((option, index) => ( + + + + {/* TODO: react-markdown (?) */} - {option[1].description} + + {option[0]} + - )} - - - - {option[1]?.metadata && - Array.isArray(option[1].metadata) ? ( - option[1].metadata.map((metadata: string, index) => ( - - {metadata} - - )) - ) : ( - <> - {typeof option[1].metadata === "object" && - Object.entries(option[1].metadata).map( - (metadata: { [key: string]: any }, index) => ( - - {metadata[0]}: {metadata[1]} - - ) - )} - - )} - - - - - - - ))} + {option[1].description && ( + + {option[1].description} + + )} + + + + {option[1]?.metadata && + Array.isArray(option[1].metadata) ? ( + option[1].metadata.map((metadata: string, index) => ( + + {metadata} + + )) + ) : ( + <> + {typeof option[1].metadata === "object" && + Object.entries(option[1].metadata).map( + (metadata: { [key: string]: any }, index) => ( + + {metadata[0]}: {metadata[1]} + + ) + )} + + )} + + + + + + + ))} + - + ); }; diff --git a/web/src/components/TextUI.tsx b/web/src/components/TextUI.tsx index 11f711f..0278fe2 100644 --- a/web/src/components/TextUI.tsx +++ b/web/src/components/TextUI.tsx @@ -38,6 +38,7 @@ const TextUI: React.FC = () => { w="100%" h="100%" p={3} + position="absolute" alignItems={data.position === "top-center" ? "baseline" : "center"} justifyContent={ data.position === "right-center" diff --git a/web/src/index.css b/web/src/index.css index f54aa11..b093f6f 100644 --- a/web/src/index.css +++ b/web/src/index.css @@ -12,6 +12,7 @@ body { -moz-osx-font-smoothing: grayscale; height: 100vh; user-select: none; + overflow: hidden !important; } #root {