Skip to content

Commit a69621c

Browse files
Isha KasliwalAyesha Mazumdar
authored andcommitted
feat(breadcrumbs): Added overflow menu breadcrumb variant
1 parent adb39a6 commit a69621c

File tree

4 files changed

+78
-8
lines changed

4 files changed

+78
-8
lines changed

ui/components/breadcrumbs/_doc.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
* utility. When you add the `.slds-breadcrumb` class, the separators are
88
* automatically generated.
99
*
10+
* **Overflow Menu Variant**
11+
* The overflow menu breadcrumbs variant is a composition of the overflow menu with actions example of the menus component and breadcrumbs component. To implement this, include the overflow menu as the first `<li>` in the breadcrumb component. In order to vertically align all of the breadcrumb items to the center, add the `.slds-grid_vertical-align-center` class to the `<ol>`.
12+
*
1013
* #### Accessibility
1114
*
1215
* Place the breadcrumb in a `nav` element with `role="navigation"`.

ui/components/breadcrumbs/base/_index.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@
4848
}
4949
}
5050
}
51+
52+
.slds-dropdown-trigger {
53+
margin-right: $spacing-x-small;
54+
}
5155
}

ui/components/breadcrumbs/base/example.jsx

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,67 @@
44
import React from 'react';
55
import BreadCrumbs from '../index.react';
66
const { Crumb } = BreadCrumbs;
7+
import { ButtonIcon } from '../../button-icons/base/example';
8+
import { Trigger } from '../../menus/dropdown/example';
9+
import { Menu } from '../../menus/dropdown/example';
10+
import { MenuList } from '../../menus/dropdown/example';
11+
import { MenuItem } from '../../menus/dropdown/example';
712

8-
export default (
9-
<BreadCrumbs>
10-
<Crumb href="javascript:void(0);">Parent Entity</Crumb>
11-
<Crumb href="javascript:void(0);">Parent Record Name</Crumb>
12-
</BreadCrumbs>
13+
const moreIcon = (
14+
<ButtonIcon
15+
className="slds-button_icon-border-filled slds-button_icon-x-small"
16+
sprite="utility"
17+
symbol="threedots"
18+
assistiveText="Show More"
19+
aria-haspopup="true"
20+
title="Show More"
21+
/>
1322
);
23+
24+
let BreadcrumbMenu = props => (
25+
<Trigger className="slds-is-open" triggerIcon={moreIcon}>
26+
<Menu className="slds-dropdown_left slds-dropdown_actions">
27+
<MenuList>
28+
<MenuItem tabIndex="0">Menu Item One</MenuItem>
29+
<MenuItem>Menu Item Two</MenuItem>
30+
<MenuItem>Menu Item Three</MenuItem>
31+
</MenuList>
32+
</Menu>
33+
</Trigger>
34+
);
35+
36+
export let examples = [
37+
{
38+
id: 'base',
39+
label: 'Base',
40+
element: (
41+
<BreadCrumbs>
42+
<Crumb className="slds-text-title_caps" href="javascript:void(0);">
43+
Parent Entity
44+
</Crumb>
45+
<Crumb className="slds-text-title_caps" href="javascript:void(0);">
46+
Parent Record Name
47+
</Crumb>
48+
</BreadCrumbs>
49+
)
50+
},
51+
{
52+
id: 'overflow-breadcrumbs',
53+
label: 'Breadcrumbs with Overflow Menu',
54+
element: (
55+
<div style={{ height: '250px' }}>
56+
<BreadCrumbs listClassNames="slds-grid_vertical-align-center">
57+
<Crumb hasMenu>
58+
<BreadcrumbMenu />
59+
</Crumb>
60+
<Crumb className="slds-text-title_caps" href="javascript:void(0);">
61+
Parent Entity
62+
</Crumb>
63+
<Crumb className="slds-text-title_caps" href="javascript:void(0);">
64+
Parent Record Name
65+
</Crumb>
66+
</BreadCrumbs>
67+
</div>
68+
)
69+
}
70+
];

ui/components/breadcrumbs/index.react.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22
// Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license
33

44
import React from 'react';
5+
import classNames from 'classnames';
56

67
const Crumb = props => (
7-
<li className="slds-breadcrumb__item slds-text-title_caps">
8-
<a href={props.href}>{props.children}</a>
8+
<li className={classNames('slds-breadcrumb__item', props.className)}>
9+
{props.hasMenu ? props.children : <a href={props.href}>{props.children}</a>}
910
</li>
1011
);
1112

1213
Crumb.propTypes = { href: React.PropTypes.string };
1314

1415
const BreadCrumbs = props => (
1516
<nav {...props} role="navigation" aria-label="Breadcrumbs">
16-
<ol className="slds-breadcrumb slds-list_horizontal slds-wrap">
17+
<ol
18+
className={classNames(
19+
'slds-breadcrumb slds-list_horizontal slds-wrap',
20+
props.listClassNames
21+
)}
22+
>
1723
{props.children}
1824
</ol>
1925
</nav>

0 commit comments

Comments
 (0)