mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-03-30 23:23:35 +08:00
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
import React, { Component, PropTypes } from 'react';
|
|
|
|
class DeepTree extends Component {
|
|
static propTypes = {
|
|
breadth: PropTypes.number.isRequired,
|
|
components: PropTypes.object,
|
|
depth: PropTypes.number.isRequired,
|
|
id: PropTypes.number.isRequired,
|
|
wrap: PropTypes.number.isRequired
|
|
};
|
|
|
|
render() {
|
|
const { breadth, components, depth, id, wrap } = this.props;
|
|
const { Box } = components;
|
|
|
|
let result = (
|
|
<Box color={id % 3} components={components} layout={depth % 2 === 0 ? 'column' : 'row'} outer>
|
|
{depth === 0 && <Box color={id % 3 + 3} components={components} fixed />}
|
|
{depth !== 0 &&
|
|
Array.from({ length: breadth })
|
|
.map((el, i) => (
|
|
<DeepTree
|
|
breadth={breadth}
|
|
components={components}
|
|
depth={depth - 1}
|
|
id={i}
|
|
key={i}
|
|
wrap={wrap}
|
|
/>
|
|
))}
|
|
</Box>
|
|
);
|
|
for (let i = 0; i < wrap; i++) {
|
|
result = <Box components={components}>{result}</Box>;
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
module.exports = DeepTree;
|