mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-19 07:56:02 +01:00
feat(web/context): allow displaying icons in context menu items
This commit is contained in:
@@ -17,11 +17,13 @@ debugData<ContextMenuProps>([
|
|||||||
{
|
{
|
||||||
title: "Example button",
|
title: "Example button",
|
||||||
description: "Example button description",
|
description: "Example button description",
|
||||||
|
icon: "inbox",
|
||||||
image: "https://i.imgur.com/YAe7k17.jpeg",
|
image: "https://i.imgur.com/YAe7k17.jpeg",
|
||||||
metadata: [{ label: "Value 1", value: 300 }],
|
metadata: [{ label: "Value 1", value: 300 }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Menu button",
|
title: "Menu button",
|
||||||
|
icon: "bars",
|
||||||
menu: "other_example_menu",
|
menu: "other_example_menu",
|
||||||
description: "Takes you to another menu",
|
description: "Takes you to another menu",
|
||||||
metadata: ["It also has metadata support"],
|
metadata: ["It also has metadata support"],
|
||||||
@@ -29,6 +31,7 @@ debugData<ContextMenuProps>([
|
|||||||
{
|
{
|
||||||
title: "Event button",
|
title: "Event button",
|
||||||
description: "Open a menu and send event data",
|
description: "Open a menu and send event data",
|
||||||
|
icon: "check",
|
||||||
arrow: true,
|
arrow: true,
|
||||||
event: "some_event",
|
event: "some_event",
|
||||||
args: { value1: 300, value2: "Other value" },
|
args: { value1: 300, value2: "Other value" },
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
Flex,
|
Flex,
|
||||||
Spacer,
|
Spacer,
|
||||||
Image,
|
Image,
|
||||||
|
HStack,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { Option, ContextMenuProps } from "../../interfaces/context";
|
import { Option, ContextMenuProps } from "../../interfaces/context";
|
||||||
@@ -55,6 +56,18 @@ const Item: React.FC<{
|
|||||||
: clickContext(option[0])
|
: clickContext(option[0])
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
{option[1]?.icon && (
|
||||||
|
<FontAwesomeIcon
|
||||||
|
fixedWidth
|
||||||
|
icon={option[1].icon}
|
||||||
|
fontSize={20}
|
||||||
|
style={{
|
||||||
|
marginRight: 10,
|
||||||
|
justifySelf: "center",
|
||||||
|
color: option[1].iconColor,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Box>
|
<Box>
|
||||||
<Box paddingBottom={option[1].description ? 1 : 0}>
|
<Box paddingBottom={option[1].description ? 1 : 0}>
|
||||||
<Text w="100%" fontWeight="medium">
|
<Text w="100%" fontWeight="medium">
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
|
import { IconProp } from "@fortawesome/fontawesome-svg-core";
|
||||||
|
|
||||||
export interface Option {
|
export interface Option {
|
||||||
menu?: string;
|
menu?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
arrow?: boolean;
|
arrow?: boolean;
|
||||||
image?: string;
|
image?: string;
|
||||||
|
icon?: IconProp;
|
||||||
|
iconColor?: string;
|
||||||
metadata?:
|
metadata?:
|
||||||
| string[]
|
| string[]
|
||||||
| { [key: string]: any }
|
| { [key: string]: any }
|
||||||
|
|||||||
Reference in New Issue
Block a user