mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 23:46:03 +01:00
refactor(nui): Custom notification layout
This commit is contained in:
@@ -1,4 +1,10 @@
|
|||||||
import { useToast, type ToastPositionWithLogical, Box } from "@chakra-ui/react";
|
import {
|
||||||
|
useToast,
|
||||||
|
type ToastPositionWithLogical,
|
||||||
|
Box,
|
||||||
|
HStack,
|
||||||
|
Text,
|
||||||
|
} from "@chakra-ui/react";
|
||||||
import { useNuiEvent } from "../hooks/useNuiEvent";
|
import { useNuiEvent } from "../hooks/useNuiEvent";
|
||||||
import { debugData } from "../utils/debugData";
|
import { debugData } from "../utils/debugData";
|
||||||
import { IconProp } from "@fortawesome/fontawesome-svg-core";
|
import { IconProp } from "@fortawesome/fontawesome-svg-core";
|
||||||
@@ -10,16 +16,16 @@ interface Props {
|
|||||||
duration?: number;
|
duration?: number;
|
||||||
position?: ToastPositionWithLogical;
|
position?: ToastPositionWithLogical;
|
||||||
status?: "info" | "warning" | "success" | "error";
|
status?: "info" | "warning" | "success" | "error";
|
||||||
color?: string;
|
|
||||||
icon?: string;
|
|
||||||
id?: number;
|
id?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CustomProps {
|
interface CustomProps {
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
text: string;
|
description: string;
|
||||||
|
title?: string;
|
||||||
duration?: number;
|
duration?: number;
|
||||||
icon?: IconProp;
|
icon?: IconProp;
|
||||||
|
iconColor?: string;
|
||||||
position?: ToastPositionWithLogical;
|
position?: ToastPositionWithLogical;
|
||||||
id?: number;
|
id?: number;
|
||||||
}
|
}
|
||||||
@@ -29,7 +35,7 @@ debugData<Props>([
|
|||||||
action: "notify",
|
action: "notify",
|
||||||
data: {
|
data: {
|
||||||
description: "Dunak is nerd",
|
description: "Dunak is nerd",
|
||||||
color: "red",
|
title: "Dunak",
|
||||||
id: 1,
|
id: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -39,8 +45,9 @@ debugData<CustomProps>([
|
|||||||
{
|
{
|
||||||
action: "customNotify",
|
action: "customNotify",
|
||||||
data: {
|
data: {
|
||||||
text: "Dunak is nerd",
|
description: "Dunak is nerd",
|
||||||
icon: "clipboard-check",
|
title: "Dunak",
|
||||||
|
icon: "basket-shopping",
|
||||||
style: {
|
style: {
|
||||||
backgroundColor: "#2D3748",
|
backgroundColor: "#2D3748",
|
||||||
color: "white",
|
color: "white",
|
||||||
@@ -59,9 +66,21 @@ const Notifications: React.FC = () => {
|
|||||||
duration: data.duration || 4000,
|
duration: data.duration || 4000,
|
||||||
position: data.position || "top-right",
|
position: data.position || "top-right",
|
||||||
render: () => (
|
render: () => (
|
||||||
<Box style={data.style} p={3}>
|
<Box style={data.style} p={3} borderRadius="md" boxShadow="lg">
|
||||||
{data.icon && <FontAwesomeIcon icon={data.icon} />}
|
<HStack spacing={0}>
|
||||||
{data.text}
|
{data.icon && (
|
||||||
|
<FontAwesomeIcon
|
||||||
|
icon={data.icon}
|
||||||
|
fontSize="1.4rem"
|
||||||
|
style={{ paddingRight: 11 }}
|
||||||
|
color={data.iconColor}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Box w="100%">
|
||||||
|
{data.title && <Text as="b">{data.title}</Text>}
|
||||||
|
{data.description && <Text>{data.description}</Text>}
|
||||||
|
</Box>
|
||||||
|
</HStack>
|
||||||
</Box>
|
</Box>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,9 +10,19 @@ import { fas } from "@fortawesome/free-solid-svg-icons";
|
|||||||
import { far } from "@fortawesome/free-regular-svg-icons";
|
import { far } from "@fortawesome/free-regular-svg-icons";
|
||||||
import { fab } from "@fortawesome/free-brands-svg-icons";
|
import { fab } from "@fortawesome/free-brands-svg-icons";
|
||||||
import { library } from "@fortawesome/fontawesome-svg-core";
|
import { library } from "@fortawesome/fontawesome-svg-core";
|
||||||
|
import { isEnvBrowser } from "./utils/misc";
|
||||||
|
|
||||||
library.add(fas, far, fab);
|
library.add(fas, far, fab);
|
||||||
|
|
||||||
|
if (isEnvBrowser()) {
|
||||||
|
const root = document.getElementById("root");
|
||||||
|
|
||||||
|
root!.style.backgroundImage = 'url("https://i.imgur.com/3pzRj9n.png")';
|
||||||
|
root!.style.backgroundSize = "cover";
|
||||||
|
root!.style.backgroundRepeat = "no-repeat";
|
||||||
|
root!.style.backgroundPosition = "center";
|
||||||
|
}
|
||||||
|
|
||||||
debugData([
|
debugData([
|
||||||
{
|
{
|
||||||
action: "setVisible",
|
action: "setVisible",
|
||||||
|
|||||||
Reference in New Issue
Block a user