Skip to content

Commit

Permalink
feat(ContextMenu): support Avatar in ContextMenu (#1003)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lisa18289 authored Nov 26, 2024
1 parent ad53b40 commit 5f03c84
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
display: flex;
flex-direction: column;
row-gap: var(--menu--item-to-item-spacing);

&:has(:global(.flow--avatar)) {
align-items: center;
padding-top: var(--context-menu--padding);
}
}

.popoverContent.popoverContent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,17 @@ export const ContextMenu = flowComponent("ContextMenu", (props) => {
const propsContext: PropsContext = {
MenuItem: {
selectionVariant,
Avatar: {
size: "l",
},
},

Section: {
MenuItem: {
selectionVariant,
Avatar: {
size: "l",
},
},
renderContextMenuSection: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { Button } from "@/components/Button";
import { Separator } from "@/components/Separator";
import { Heading } from "@/components/Heading";
import { Section } from "@/components/Section";
import { IconServer } from "@/components/Icon/components/icons";
import { IconCamera, IconServer } from "@/components/Icon/components/icons";
import { Text } from "@/components/Text";
import { Avatar } from "@/components/Avatar";
import { Initials } from "@/components/Initials";

const meta: Meta<typeof ContextMenu> = {
title: "Actions/ContextMenu",
Expand Down Expand Up @@ -147,3 +149,34 @@ export const WithIcon: Story = {
};

export const CustomWidth: Story = { args: { width: 400 } };

export const WithAvatar: Story = {
render: (props) => (
<ContextMenuTrigger>
<Button>Trigger</Button>
<ContextMenu selectionMode="navigation" {...props}>
<Section>
<MenuItem>
<Avatar>
<Initials>Max Mustermann</Initials>
</Avatar>
<IconCamera />
</MenuItem>
<Heading>Max Mustermann</Heading>
</Section>
<Separator />
<Section>
<MenuItem>
<Text>Settings</Text>
</MenuItem>
<MenuItem>
<Text>Logout</Text>
</MenuItem>
</Section>
</ContextMenu>
</ContextMenuTrigger>
),
args: {
defaultOpen: true,
},
};

0 comments on commit 5f03c84

Please sign in to comment.