Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Optimize PageHeader className naming #17321

Merged
merged 2 commits into from Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 14 additions & 14 deletions components/page-header/__tests__/__snapshots__/demo.test.js.snap
Expand Up @@ -39,20 +39,20 @@ exports[`renders ./components/page-header/demo/actions.md correctly 1`] = `
/>
</div>
<div
class="ant-page-header-title-view"
class="ant-page-header-heading"
>
<span
class="ant-page-header-title-view-title"
class="ant-page-header-heading-title"
>
Title
</span>
<span
class="ant-page-header-title-view-sub-title"
class="ant-page-header-heading-sub-title"
>
This is a subtitle
</span>
<span
class="ant-page-header-title-view-tags"
class="ant-page-header-heading-tags"
>
<div
class="ant-tag ant-tag-red"
Expand All @@ -61,7 +61,7 @@ exports[`renders ./components/page-header/demo/actions.md correctly 1`] = `
</div>
</span>
<span
class="ant-page-header-title-view-extra"
class="ant-page-header-heading-extra"
>
<button
class="ant-btn"
Expand Down Expand Up @@ -90,7 +90,7 @@ exports[`renders ./components/page-header/demo/actions.md correctly 1`] = `
</span>
</div>
<div
class="ant-page-header-content-view"
class="ant-page-header-content"
>
<div
class="wrap"
Expand Down Expand Up @@ -448,15 +448,15 @@ exports[`renders ./components/page-header/demo/basic.md correctly 1`] = `
/>
</div>
<div
class="ant-page-header-title-view"
class="ant-page-header-heading"
>
<span
class="ant-page-header-title-view-title"
class="ant-page-header-heading-title"
>
Title
</span>
<span
class="ant-page-header-title-view-sub-title"
class="ant-page-header-heading-sub-title"
>
This is a subtitle
</span>
Expand Down Expand Up @@ -519,10 +519,10 @@ exports[`renders ./components/page-header/demo/breadcrumb.md correctly 1`] = `
</span>
</div>
<div
class="ant-page-header-title-view"
class="ant-page-header-heading"
>
<span
class="ant-page-header-title-view-title"
class="ant-page-header-heading-title"
>
Title
</span>
Expand Down Expand Up @@ -585,16 +585,16 @@ exports[`renders ./components/page-header/demo/content.md correctly 1`] = `
</span>
</div>
<div
class="ant-page-header-title-view"
class="ant-page-header-heading"
>
<span
class="ant-page-header-title-view-title"
class="ant-page-header-heading-title"
>
Title
</span>
</div>
<div
class="ant-page-header-content-view"
class="ant-page-header-content"
>
<div
class="wrap"
Expand Down
Expand Up @@ -11,10 +11,10 @@ exports[`PageHeader pageHeader should support className 1`] = `
class="ant-page-header not-works"
>
<div
class="ant-page-header-title-view"
class="ant-page-header-heading"
>
<span
class="ant-page-header-title-view-title"
class="ant-page-header-heading-title"
>
Page Title
</span>
Expand Down
14 changes: 7 additions & 7 deletions components/page-header/index.tsx
Expand Up @@ -67,14 +67,14 @@ const renderHeader = (prefixCls: string, props: PageHeaderProps) => {

const renderTitle = (prefixCls: string, props: PageHeaderProps) => {
const { title, subTitle, tags, extra } = props;
const titlePrefixCls = `${prefixCls}-title-view`;
const headingPrefixCls = `${prefixCls}-heading`;
if (title || subTitle || tags || extra) {
return (
<div className={titlePrefixCls}>
{title && <span className={`${titlePrefixCls}-title`}>{title}</span>}
{subTitle && <span className={`${titlePrefixCls}-sub-title`}>{subTitle}</span>}
{tags && <span className={`${titlePrefixCls}-tags`}>{tags}</span>}
{extra && <span className={`${titlePrefixCls}-extra`}>{extra}</span>}
<div className={headingPrefixCls}>
{title && <span className={`${headingPrefixCls}-title`}>{title}</span>}
{subTitle && <span className={`${headingPrefixCls}-sub-title`}>{subTitle}</span>}
{tags && <span className={`${headingPrefixCls}-tags`}>{tags}</span>}
{extra && <span className={`${headingPrefixCls}-extra`}>{extra}</span>}
</div>
);
}
Expand Down Expand Up @@ -112,7 +112,7 @@ const PageHeader: React.SFC<PageHeaderProps> = props => (
<div className={className} style={style}>
{renderHeader(prefixCls, props)}
{renderTitle(prefixCls, props)}
{children && <div className={`${prefixCls}-content-view`}>{children}</div>}
{children && <div className={`${prefixCls}-content`}>{children}</div>}
{renderFooter(prefixCls, footer)}
</div>
);
Expand Down
8 changes: 4 additions & 4 deletions components/page-header/style/index.less
Expand Up @@ -31,11 +31,11 @@
margin: 0 12px;
}

.@{ant-prefix}-breadcrumb {
margin-bottom: 12px;
.@{ant-prefix}-breadcrumb + &-heading {
margin-top: 12px;
}

&-title-view {
&-heading {
display: inline-block;
&-title {
display: inline-block;
Expand Down Expand Up @@ -72,7 +72,7 @@
}
}

&-content-view {
&-content {
padding-top: 12px;
}

Expand Down