Skip to content

Commit c0c4a6a

Browse files
codingwolf-atlifeiscontent
authored andcommitted
Refactor BreadcrumbMenuTrigger to use Menu components
- Updated the `MenuTrigger` story in the Breadcrumb component to utilize the new Menu structure, enhancing the integration of menu items within the breadcrumb navigation. - Replaced the previous `BreadcrumbMenuTrigger` with a more modular approach using `MenuTriggerElement`, `MenuPortal`, and related components, improving the overall composition and flexibility of the breadcrumb UI. This change aligns with recent updates to the menu components, promoting a more cohesive design across the UI library.
1 parent 8085ba0 commit c0c4a6a

1 file changed

Lines changed: 41 additions & 21 deletions

File tree

packages/propel/src/ui/breadcrumb/breadcrumb.stories.tsx

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@ import type { Meta, StoryObj } from "@storybook/react-vite";
22
import { ChevronRight, Layers } from "lucide-react";
33
import { expect } from "storybook/test";
44

5-
import { BreadcrumbMenuTrigger } from "../../components/breadcrumb";
6-
import { MenuContent } from "../../components/menu";
7-
import { Menu, MenuItem } from "../menu";
5+
import {
6+
Menu,
7+
MenuItem,
8+
MenuItemContent,
9+
MenuItemTitle,
10+
MenuItemTitleRow,
11+
MenuPopup,
12+
MenuPortal,
13+
MenuPositioner,
14+
MenuTrigger as MenuTriggerElement,
15+
} from "../menu";
816
import {
917
Breadcrumb,
1018
BreadcrumbItem,
@@ -18,10 +26,9 @@ import {
1826
} from "./index";
1927

2028
// UI-tier story: composes the ATOMIC breadcrumb parts (each renders a single element).
21-
// The components-tier `Breadcrumb` story shows the ready-made menu crumbs (which
22-
// compose propel's Menu). Here you assemble the raw crumb chrome: the landmark + list, links,
23-
// the current page, separators, and the bare menu-trigger surface (without an attached menu)
24-
// with its own leading icon and trailing indicator parts.
29+
// The components-tier `Breadcrumb` story shows the ready-made menu crumbs. Here you assemble the
30+
// raw crumb chrome from `ui` atoms: the landmark + list, links, the current page, separators, and
31+
// a menu-trigger crumb wired to a Base UI `Menu` (its own leading icon and trailing indicator).
2532
const meta = {
2633
title: "UI/Breadcrumb",
2734
component: Breadcrumb,
@@ -92,8 +99,9 @@ const inertAnchor = () => <a href="#" onClick={(event) => event.preventDefault()
9299
/**
93100
* A menu-style crumb built from the raw `BreadcrumbTrigger` (`group` adds the open-state marker so
94101
* the indicator can rotate), composing the atomic `BreadcrumbTriggerIcon` and
95-
* `BreadcrumbTriggerIndicator` parts. The UI tier styles just the trigger surface — wiring it to a
96-
* real menu via the `render` prop is a components-tier concern, so no separator follows it.
102+
* `BreadcrumbTriggerIndicator` parts. The trigger is projected onto a Base UI `Menu`'s trigger via
103+
* `render`, with the menu surface assembled from the `ui` menu atoms. The menu crumb owns its own
104+
* chevron, so no separator follows it.
97105
*/
98106
export const MenuTrigger: Story = {
99107
render: () => (
@@ -109,18 +117,30 @@ export const MenuTrigger: Story = {
109117
</BreadcrumbSeparator>
110118
<BreadcrumbItem>
111119
<Menu>
112-
<BreadcrumbMenuTrigger icon={<Layers />}>Plane Design</BreadcrumbMenuTrigger>
113-
<MenuContent>
114-
<MenuItem render={inertAnchor()} layout={"default"}>
115-
Plane Web
116-
</MenuItem>
117-
<MenuItem render={inertAnchor()} layout={"default"}>
118-
Plane Mobile
119-
</MenuItem>
120-
<MenuItem render={inertAnchor()} layout={"default"}>
121-
Plane Server
122-
</MenuItem>
123-
</MenuContent>
120+
<MenuTriggerElement render={<BreadcrumbTrigger group />}>
121+
<BreadcrumbTriggerIcon>
122+
<Layers />
123+
</BreadcrumbTriggerIcon>
124+
Plane Design
125+
<BreadcrumbTriggerIndicator>
126+
<ChevronRight />
127+
</BreadcrumbTriggerIndicator>
128+
</MenuTriggerElement>
129+
<MenuPortal>
130+
<MenuPositioner sideOffset={4}>
131+
<MenuPopup elevation="raised">
132+
{["Plane Web", "Plane Mobile", "Plane Server"].map((label) => (
133+
<MenuItem key={label} render={inertAnchor()} layout="default">
134+
<MenuItemContent>
135+
<MenuItemTitleRow>
136+
<MenuItemTitle>{label}</MenuItemTitle>
137+
</MenuItemTitleRow>
138+
</MenuItemContent>
139+
</MenuItem>
140+
))}
141+
</MenuPopup>
142+
</MenuPositioner>
143+
</MenuPortal>
124144
</Menu>
125145
</BreadcrumbItem>
126146
<BreadcrumbItem>

0 commit comments

Comments
 (0)