-
Notifications
You must be signed in to change notification settings - Fork 418
/
nav-dropdown.jsx
58 lines (53 loc) · 1.79 KB
/
nav-dropdown.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React from 'react';
import Button from '../button';
import Icon from '../icon';
import Dropdown from '../menu-dropdown';
import DropdownTrigger from '../menu-dropdown/button-trigger';
import MenuDropdown from '../menu-dropdown/menu-dropdown';
import { BUILDER_HEADER_NAV_DROPDOWN } from '../../utilities/constants';
// This component accepts the same props as MenuDropdown.
// eslint-disable-next-line react/forbid-foreign-prop-types
const { propTypes } = MenuDropdown;
/**
* A dropdown within the navigation section of the header.
*/
const BuilderHeaderNavDropdown = (props) => {
// Separate props we care about in order to pass others along passively to the dropdown component
const { iconCategory, iconName, label, assistiveText, ...rest } = props;
return (
<Dropdown {...rest}>
<DropdownTrigger>
<Button
className="slds-builder-header__item-action slds-media slds-media_center"
variant="base"
>
<span className="slds-media__figure">
<Icon
assistiveText={{
label: assistiveText && assistiveText.icon,
}}
category={iconCategory}
containerClassName="slds-icon_container slds-icon-utility-page slds-current-color"
name={iconName}
size="x-small"
/>
</span>
<span className="slds-media__body">
<span className="slds-truncate" title={label}>
{label}
</span>
<Icon
category="utility"
containerClassName="slds-icon_container slds-icon-utility-chevrondown slds-current-color slds-m-left_small"
name="chevrondown"
size="x-small"
/>
</span>
</Button>
</DropdownTrigger>
</Dropdown>
);
};
BuilderHeaderNavDropdown.displayName = BUILDER_HEADER_NAV_DROPDOWN;
BuilderHeaderNavDropdown.propTypes = propTypes;
export default BuilderHeaderNavDropdown;