forked from alibaba-fusion/next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
group.jsx
59 lines (51 loc) · 1.4 KB
/
group.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
59
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import Menu from '../menu';
/**
* Nav.Group
* @description 继承自 `Menu.Group` 的能力请查看 `Menu.Group` 文档
*/
class Group extends Component {
static menuChildType = 'group';
static propTypes = {
/**
* 自定义类名
*/
className: PropTypes.string,
/**
* 标签内容
*/
label: PropTypes.node,
/**
* 导航项和子导航
*/
children: PropTypes.node,
};
static contextTypes = {
prefix: PropTypes.string,
iconOnly: PropTypes.bool,
};
render() {
const { prefix, iconOnly } = this.context;
const { className, children, label, ...others } = this.props;
let newLabel = label;
if (iconOnly) {
// TODO: add a group icon ?
newLabel = [
<span key="icon" className={`${prefix}nav-icon-placeholder`} />,
<span key="label">{label}</span>,
];
}
const cls = classNames({
[`${prefix}nav-group-label`]: true,
[className]: !!className,
});
return (
<Menu.Group className={cls} label={newLabel} {...others}>
{children}
</Menu.Group>
);
}
}
export default Group;