This repository has been archived by the owner on Mar 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
/
menu.js
83 lines (74 loc) · 2.04 KB
/
menu.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import React from 'react';
import PropTypes from 'prop-types';
import { MenuAlignments } from '../enums';
import { GeneralPropTypes, FlexboxPropTypes, createClassName, generalClassNames, removeProps, objectKeys, objectValues } from '../utils';
/**
* Menu component.
* http://foundation.zurb.com/sites/docs/menu.html
*
* @param {Object} props
* @returns {Object}
*/
export const Menu = (props) => {
const className = createClassName(
props.noDefaultClassName ? null : 'menu',
props.className,
{
'align-right': props.alignment === MenuAlignments.RIGHT,
'align-center': props.alignment === MenuAlignments.CENTER,
'icon-top': props.iconsOnTop,
'expanded': props.isExpanded,
'vertical': props.isVertical,
'simple': props.isSimple,
'nested': props.isNested,
'dropdown': props.isDropdown,
'medium-horizontal': props.horizontalOnMedium
},
generalClassNames(props)
);
const passProps = removeProps(props, objectKeys(Menu.propTypes));
return <ul {...passProps} className={className}/>;
};
Menu.propTypes = {
...GeneralPropTypes,
...FlexboxPropTypes,
alignment: PropTypes.oneOf(objectValues(MenuAlignments)),
iconsOnTop: PropTypes.bool,
isExpanded: PropTypes.bool,
isVertical: PropTypes.bool,
isDropdown: PropTypes.bool,
isSimple: PropTypes.bool,
isNested: PropTypes.bool,
horizontalOnMedium: PropTypes.bool
};
/**
* Menu item component.
*
* @param {Object} props
* @returns {Object}
*/
export const MenuItem = (props) => {
const className = createClassName(
props.className,
{
'active': props.isActive
},
generalClassNames(props)
);
const passProps = removeProps(props, objectKeys(MenuItem.propTypes));
return <li {...passProps} className={className}/>;
};
MenuItem.propTypes = {
...GeneralPropTypes,
...FlexboxPropTypes,
isActive: PropTypes.bool
};
/**
* Menu text wrapper-component.
*
* @param {Object} props
* @returns {XML}
*/
export const MenuText = (props) => (
<MenuItem {...props} className={props.className || 'menu-text'}/>
);