-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18115 from GordonSmith/HPCC-30964-METRIC_BREADCUM…
…P_OVERLAP HPCC-30964 Add overflow support to metrics breadcrumbs
- Loading branch information
Showing
9 changed files
with
140 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
esp/src/src-react/components/controls/OverflowBreadcrumb.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import * as React from "react"; | ||
import { Overflow, Breadcrumb, OverflowItem, BreadcrumbItem, BreadcrumbButton, BreadcrumbButtonProps, BreadcrumbDivider, OverflowDivider } from "@fluentui/react-components"; | ||
import { bundleIcon, Folder20Filled, Folder20Regular, FolderOpen20Filled, FolderOpen20Regular, } from "@fluentui/react-icons"; | ||
import { OverflowMenu } from "./OverflowMenu"; | ||
|
||
const LineageIcon = bundleIcon(Folder20Filled, Folder20Regular); | ||
const SelectedLineageIcon = bundleIcon(FolderOpen20Filled, FolderOpen20Regular); | ||
|
||
export interface BreadcrumbInfo { | ||
id: string; | ||
label: string; | ||
props?: BreadcrumbButtonProps | ||
} | ||
|
||
interface OverflowGroupDividerProps { | ||
groupId: string; | ||
} | ||
|
||
const OverflowGroupDivider: React.FunctionComponent<OverflowGroupDividerProps> = ({ | ||
groupId, | ||
}) => { | ||
return <OverflowDivider groupId={groupId}> | ||
<BreadcrumbDivider data-group={groupId} /> | ||
</OverflowDivider>; | ||
}; | ||
|
||
function icon(breadcrumb: BreadcrumbInfo, selected: string) { | ||
return breadcrumb.id === selected ? <SelectedLineageIcon /> : <LineageIcon />; | ||
} | ||
|
||
export interface OverflowBreadcrumbProps { | ||
breadcrumbs: BreadcrumbInfo[]; | ||
selected: string; | ||
onSelect: (tab: BreadcrumbInfo) => void; | ||
} | ||
|
||
export const OverflowBreadcrumb: React.FunctionComponent<OverflowBreadcrumbProps> = ({ | ||
breadcrumbs, | ||
selected, | ||
onSelect | ||
}) => { | ||
|
||
const overflowItems = React.useMemo(() => { | ||
return breadcrumbs.map((breadcrumb, idx) => <> | ||
<OverflowItem id={breadcrumb.id} groupId={breadcrumb.id} key={`button-items-${breadcrumb.id}`}> | ||
<BreadcrumbItem> | ||
<BreadcrumbButton {...breadcrumb.props} current={breadcrumb.id === selected} icon={icon(breadcrumb, selected)} onClick={() => onSelect(breadcrumb)}> | ||
{breadcrumb.label} | ||
</BreadcrumbButton> | ||
</BreadcrumbItem> | ||
</OverflowItem> | ||
{idx < breadcrumbs.length - 1 && <OverflowGroupDivider groupId={breadcrumb.id} />} | ||
</>); | ||
}, [breadcrumbs, onSelect, selected]); | ||
|
||
return <Overflow> | ||
<Breadcrumb> | ||
{...overflowItems} | ||
<OverflowMenu menuItems={breadcrumbs.map(breadcrumb => ({ ...breadcrumb, icon: icon(breadcrumb, selected) }))} onMenuSelect={onSelect} /> | ||
</Breadcrumb> | ||
</Overflow>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters