From a6fe8ae5afb9b36a6706d2ac256715386d187fe0 Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 18 Mar 2022 16:59:18 +0100 Subject: [PATCH] feat(nui): Text UI --- web/src/components/App.tsx | 2 ++ web/src/components/TextUI.tsx | 59 +++++++++++++++++++++++++++++++++++ web/src/index.css | 3 ++ 3 files changed, 64 insertions(+) create mode 100644 web/src/components/TextUI.tsx diff --git a/web/src/components/App.tsx b/web/src/components/App.tsx index 0c42aeb..132c6b5 100644 --- a/web/src/components/App.tsx +++ b/web/src/components/App.tsx @@ -1,6 +1,7 @@ import Notifications from "./Notifications"; import CircleProgressbar from "./CircleProgressbar"; import Progressbar from "./Progressbar"; +import TextUI from "./TextUI"; const App: React.FC = () => { return ( @@ -8,6 +9,7 @@ const App: React.FC = () => { + ); }; diff --git a/web/src/components/TextUI.tsx b/web/src/components/TextUI.tsx new file mode 100644 index 0000000..a910652 --- /dev/null +++ b/web/src/components/TextUI.tsx @@ -0,0 +1,59 @@ +import React from "react"; +import { useNuiEvent } from "../hooks/useNuiEvent"; +import { Box, Flex, ScaleFade, Text } from "@chakra-ui/react"; +import { debugData } from "../utils/debugData"; + +interface Props { + text: string; + position?: "right-center" | "left-center" | "top-center"; + style?: React.CSSProperties; +} + +debugData([ + { + action: "textUi", + data: { + text: "[E] - Access locker inventory", + position: "right-center", + }, + }, +]); + +const TextUI: React.FC = () => { + const [data, setData] = React.useState({ + text: "", + position: "right-center", + }); + const [visible, setVisible] = React.useState(false); + + useNuiEvent("textUi", (data) => { + setData(data); + setVisible(true); + }); + + useNuiEvent("textUiHide", () => setVisible(false)); + + return ( + + + + {data.text} + + + + ); +}; + +export default TextUI; diff --git a/web/src/index.css b/web/src/index.css index 3d91f76..9a7b933 100644 --- a/web/src/index.css +++ b/web/src/index.css @@ -1,3 +1,5 @@ +@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200;400;700&display=swap"); + body { background: none !important; margin: 0; @@ -7,6 +9,7 @@ body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; height: 100vh; + user-select: none; } #root {