2016-12-30 21:41:28 +08:00
|
|
|
import React from 'react';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
|
|
|
|
export interface BasicProps {
|
|
|
|
style?: React.CSSProperties;
|
|
|
|
prefixCls?: string;
|
|
|
|
className?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
function generator(props) {
|
|
|
|
return (Basic) : any => {
|
|
|
|
return class Adapter extends React.Component<BasicProps, any> {
|
|
|
|
static Header: any;
|
|
|
|
static Footer: any;
|
|
|
|
static Content: any;
|
|
|
|
static Sider: any;
|
|
|
|
render() {
|
|
|
|
const { prefixCls } = props;
|
2017-02-24 16:06:15 +08:00
|
|
|
return <Basic prefixCls={prefixCls} {...this.props}/>;
|
2016-12-30 21:41:28 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
class Basic extends React.Component<BasicProps, any> {
|
|
|
|
render() {
|
2017-02-24 16:06:15 +08:00
|
|
|
const { prefixCls, className, children, ...others } = this.props;
|
2017-01-08 17:03:47 +08:00
|
|
|
let hasSider;
|
2017-02-24 16:06:15 +08:00
|
|
|
React.Children.forEach(children, (element: any) => {
|
|
|
|
if (element && element.type && element.type.__ANT_LAYOUT_SIDER) {
|
|
|
|
hasSider = true;
|
|
|
|
}
|
|
|
|
});
|
2017-01-08 17:03:47 +08:00
|
|
|
const divCls = classNames(className, prefixCls, {
|
|
|
|
[`${prefixCls}-has-sider`]: hasSider,
|
|
|
|
});
|
2016-12-30 21:41:28 +08:00
|
|
|
return (
|
2017-01-08 17:03:47 +08:00
|
|
|
<div className={divCls} {...others}>{children}</div>
|
2016-12-30 21:41:28 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const Layout = generator({
|
|
|
|
prefixCls: 'ant-layout',
|
|
|
|
})(Basic);
|
|
|
|
|
|
|
|
const Header = generator({
|
|
|
|
prefixCls: 'ant-layout-header',
|
|
|
|
})(Basic);
|
|
|
|
|
|
|
|
const Footer = generator({
|
|
|
|
prefixCls: 'ant-layout-footer',
|
|
|
|
})(Basic);
|
|
|
|
|
|
|
|
const Content = generator({
|
|
|
|
prefixCls: 'ant-layout-content',
|
|
|
|
})(Basic);
|
|
|
|
|
|
|
|
Layout.Header = Header;
|
|
|
|
Layout.Footer = Footer;
|
|
|
|
Layout.Content = Content;
|
|
|
|
|
|
|
|
export default Layout;
|