mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-19 07:56:02 +01:00
feat(web/progress): progress bar in context menu's metadata (#217)
* feature: progress bar in context menu's metadata * undefined check `metadata.progress`
This commit is contained in:
@@ -9,6 +9,32 @@ export const debugContext = () => {
|
|||||||
title: 'Vehicle garage',
|
title: 'Vehicle garage',
|
||||||
options: [
|
options: [
|
||||||
{ title: 'Empty button' },
|
{ title: 'Empty button' },
|
||||||
|
{
|
||||||
|
title: 'Karin Kuruma',
|
||||||
|
image: 'https://cdn.discordapp.com/attachments/1063098499027173461/1064276343585505330/screenshot.jpg',
|
||||||
|
arrow: true,
|
||||||
|
colorScheme: 'blue',
|
||||||
|
metadata: [
|
||||||
|
{
|
||||||
|
["label"]: "Body",
|
||||||
|
["value"]: "55%",
|
||||||
|
["progress"]: 55
|
||||||
|
},
|
||||||
|
{
|
||||||
|
["label"]: "Engine",
|
||||||
|
["value"]: "100%",
|
||||||
|
["progress"]: 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
["label"]: "Oil",
|
||||||
|
["progress"]: 11
|
||||||
|
},
|
||||||
|
{
|
||||||
|
["label"]: "Fuel",
|
||||||
|
["progress"]: 87
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'Example button',
|
title: 'Example button',
|
||||||
description: 'Example button description',
|
description: 'Example button description',
|
||||||
|
|||||||
@@ -90,10 +90,16 @@ const ContextButton: React.FC<{
|
|||||||
<HoverCard.Dropdown className={classes.dropdown}>
|
<HoverCard.Dropdown className={classes.dropdown}>
|
||||||
{button.image && <Image src={button.image} />}
|
{button.image && <Image src={button.image} />}
|
||||||
{Array.isArray(button.metadata) ? (
|
{Array.isArray(button.metadata) ? (
|
||||||
button.metadata.map((metadata: string | { label: string; value: any }, index: number) => (
|
button.metadata.map((metadata: string | { label: string; value?: any; progress?: number }, index: number) => (
|
||||||
|
<>
|
||||||
<Text key={`context-metadata-${index}`}>
|
<Text key={`context-metadata-${index}`}>
|
||||||
{typeof metadata === 'string' ? `${metadata}` : `${metadata.label}: ${metadata.value}`}
|
{typeof metadata === 'string' ? `${metadata}` : `${metadata.label}: ${metadata?.value ?? ""}`}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
|
{typeof metadata === 'object' && metadata.progress !== undefined && (
|
||||||
|
<Progress value={metadata.progress} size="sm" color={button.colorScheme || 'dark.3'} />
|
||||||
|
)}
|
||||||
|
</>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export interface Option {
|
|||||||
iconColor?: string;
|
iconColor?: string;
|
||||||
progress?: number;
|
progress?: number;
|
||||||
colorScheme?: string;
|
colorScheme?: string;
|
||||||
metadata?: string[] | { [key: string]: any } | { label: string; value: any }[];
|
metadata?: string[] | { [key: string]: any } | { label: string; value: any; progress: number; }[];
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
event?: string;
|
event?: string;
|
||||||
serverEvent?: string;
|
serverEvent?: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user