-
Notifications
You must be signed in to change notification settings - Fork 227
/
Cell.js
59 lines (53 loc) · 1.57 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
57
58
59
import classnames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
const Cell = (props) => {
const {
align,
children,
className,
columns,
desktopColumns,
order,
phoneColumns,
tabletColumns,
tag: Tag,
...otherProps
} = props;
const classes = classnames('mdc-layout-grid__cell', className, {
[`mdc-layout-grid__cell--align-${align}`]: !!align,
[`mdc-layout-grid__cell--order-${order}`]: !!order,
[`mdc-layout-grid__cell--span-${columns}`]: !!columns,
[`mdc-layout-grid__cell--span-${desktopColumns}-desktop`]: !!desktopColumns,
[`mdc-layout-grid__cell--span-${phoneColumns}-phone`]: !!phoneColumns,
[`mdc-layout-grid__cell--span-${tabletColumns}-tablet`]: !!tabletColumns,
});
return (
<Tag className={classes} {...otherProps}>
{children}
</Tag>
);
};
Cell.propTypes = {
align: PropTypes.oneOf(['bottom', 'middle', 'top']),
children: PropTypes.node,
className: PropTypes.string,
columns: PropTypes.oneOf([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),
desktopColumns: PropTypes.oneOf([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),
order: PropTypes.oneOf([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),
phoneColumns: PropTypes.oneOf([1, 2, 3, 4]),
tabletColumns: PropTypes.oneOf([1, 2, 3, 4, 5, 6, 7, 8]),
tag: PropTypes.string,
};
Cell.defaultProps = {
align: undefined,
children: undefined,
className: '',
columns: undefined,
desktopColumns: undefined,
order: undefined,
phoneColumns: undefined,
tabletColumns: undefined,
tag: 'div',
};
export default Cell;