Skip to content

Commit

Permalink
feat(web/context): allow custom metadata order
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeWasTakenn committed May 8, 2022
1 parent 62d4812 commit a784726
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion web/src/features/menu/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ debugData<ContextMenuProps>([
{
title: "Example button",
description: "Example button description",
metadata: { ["Value 1"]: "Some value", ["Value 2"]: 300 },
metadata: [{ label: "Value 1", value: 300 }],
},
{
title: "Menu button",
Expand Down
9 changes: 7 additions & 2 deletions web/src/features/menu/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,14 @@ const Item: React.FC<{
<PopoverBody>
{Array.isArray(option[1].metadata) ? (
option[1].metadata.map(
(metadata: string, index: number) => (
(
metadata: string | { label: string; value: any },
index: number
) => (
<Text key={`context-metadata-${index}`}>
{metadata}
{typeof metadata === "string"
? `${metadata}`
: `${metadata.label}: ${metadata.value}`}
</Text>
)
)
Expand Down
5 changes: 4 additions & 1 deletion web/src/interfaces/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ export interface Option {
title?: string;
description?: string;
arrow?: boolean;
metadata?: string[] | { [key: string]: any };
metadata?:
| string[]
| { [key: string]: any }
| { label: string; value: any }[];
event?: string;
serverEvent?: string;
args?: any;
Expand Down

0 comments on commit a784726

Please sign in to comment.