Commit 776c67ad authored by XieZhiXiong's avatar XieZhiXiong

feat: 添加分列容器

parent 21563b87
......@@ -139,3 +139,34 @@ registerVirtualBox('MellowCardBox', (_props) => {
</MellowCard>
)
})
// 分列 容器
registerVirtualBox('ColumnLayout', (_props) => {
const { children, props } = _props;
const xComponentProps = props['x-component-props'] || {};
const {
column = 3,
} = xComponentProps;
const span = 24 / column;
const childNodes: React.ReactElement[] = React.Children.map(children, (child) => child);
const cols = Array.apply(null, Array(column)).map(() => []);
childNodes.forEach((item, index) => {
cols[index % column].push(item);
});
return (
<Row
gutter={32}
>
{cols.map((item, index) => (
<Col key={index} span={span}>
{item}
</Col>
))}
</Row>
)
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment