mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 23:46:03 +01:00
feat(nui): Text UI
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import Notifications from "./Notifications";
|
import Notifications from "./Notifications";
|
||||||
import CircleProgressbar from "./CircleProgressbar";
|
import CircleProgressbar from "./CircleProgressbar";
|
||||||
import Progressbar from "./Progressbar";
|
import Progressbar from "./Progressbar";
|
||||||
|
import TextUI from "./TextUI";
|
||||||
|
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
return (
|
return (
|
||||||
@@ -8,6 +9,7 @@ const App: React.FC = () => {
|
|||||||
<Progressbar />
|
<Progressbar />
|
||||||
<CircleProgressbar />
|
<CircleProgressbar />
|
||||||
<Notifications />
|
<Notifications />
|
||||||
|
<TextUI />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
59
web/src/components/TextUI.tsx
Normal file
59
web/src/components/TextUI.tsx
Normal file
@@ -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<Props>({
|
||||||
|
text: "",
|
||||||
|
position: "right-center",
|
||||||
|
});
|
||||||
|
const [visible, setVisible] = React.useState(false);
|
||||||
|
|
||||||
|
useNuiEvent<Props>("textUi", (data) => {
|
||||||
|
setData(data);
|
||||||
|
setVisible(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
useNuiEvent("textUiHide", () => setVisible(false));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Flex
|
||||||
|
w="100%"
|
||||||
|
h="100%"
|
||||||
|
p={3}
|
||||||
|
alignItems={data.position === "top-center" ? "baseline" : "center"}
|
||||||
|
justifyContent={
|
||||||
|
data.position === "right-center"
|
||||||
|
? "flex-end"
|
||||||
|
: data.position === "left-center"
|
||||||
|
? "flex-start"
|
||||||
|
: "center"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<ScaleFade in={visible} unmountOnExit>
|
||||||
|
<Box bg="blue.400" p={3} fontFamily="Poppins" style={data.style}>
|
||||||
|
<Text>{data.text}</Text>
|
||||||
|
</Box>
|
||||||
|
</ScaleFade>
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TextUI;
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200;400;700&display=swap");
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background: none !important;
|
background: none !important;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -7,6 +9,7 @@ body {
|
|||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#root {
|
#root {
|
||||||
|
|||||||
Reference in New Issue
Block a user