Skip to content

Commit

Permalink
update display names for layout components
Browse files Browse the repository at this point in the history
(cherry picked from commit 286e0e9)
  • Loading branch information
morenyang committed Jan 28, 2020
1 parent 6de8522 commit d77de6d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/layout/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
export interface GeneratorProps {
suffixCls: string;
tagName: 'header' | 'footer' | 'main' | 'section';
displayName: string;
}
export interface BasicProps extends React.HTMLAttributes<HTMLDivElement> {
prefixCls?: string;
Expand All @@ -30,9 +31,11 @@ interface BasicPropsWithTagName extends BasicProps {
tagName: 'header' | 'footer' | 'main' | 'section';
}

function generator({ suffixCls, tagName }: GeneratorProps) {
function generator({ suffixCls, tagName, displayName }: GeneratorProps) {
return (BasicComponent: any) => {
return class Adapter extends React.Component<BasicProps, any> {
static displayName: string = displayName;

static Header: any;

static Footer: any;
Expand Down Expand Up @@ -108,21 +111,25 @@ const Layout: React.ComponentClass<BasicProps> & {
} = generator({
suffixCls: 'layout',
tagName: 'section',
displayName: 'Layout',
})(BasicLayout);

const Header = generator({
suffixCls: 'layout-header',
tagName: 'header',
displayName: 'Header',
})(Basic);

const Footer = generator({
suffixCls: 'layout-footer',
tagName: 'footer',
displayName: 'Footer',
})(Basic);

const Content = generator({
suffixCls: 'layout-content',
tagName: 'main',
displayName: 'Content',
})(Basic);

Layout.Header = Header;
Expand Down

0 comments on commit d77de6d

Please sign in to comment.