-
Notifications
You must be signed in to change notification settings - Fork 494
/
cell.js
56 lines (50 loc) · 1.21 KB
/
cell.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
import React from 'react';
import PropTypes from 'prop-types';
import classNames from '../../utils/classnames';
/**
* Cell consist of `CellBody`, `CellHeader` and `CellFooter` for flexible reason
*
*/
const Cell = (props) => {
const { className, children, access, href, link, component, htmlFor, ...others } = props;
const DefaultComponent = href ? 'a' : htmlFor ? 'label' : 'div';
var CellComponent = component ? component : DefaultComponent;
const cls = classNames({
'weui-cell': true,
'weui-cell_access': access,
'weui-cell_link': link,
[className]: className
});
return (
<CellComponent
className={cls}
href={href}
htmlFor={htmlFor}
{ ...others }
>
{ children }
</CellComponent>
);
};
Cell.propTypes = {
/**
* if cell should have arrow or link
*
*/
access: PropTypes.bool,
/**
* if this cell body is link
*
*/
link: PropTypes.bool,
/**
* pass in an component to replace Cell but apply same style
*
*/
component: PropTypes.func
};
Cell.defaultProps = {
access: false,
link: false,
};
export default Cell;