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

🔥feat: new pageheader style #18128

Merged
merged 22 commits into from Aug 25, 2019
Merged
Show file tree
Hide file tree
Changes from 20 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
1,218 changes: 827 additions & 391 deletions components/page-header/__tests__/__snapshots__/demo.test.js.snap

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions components/page-header/__tests__/index.test.js
Expand Up @@ -63,4 +63,26 @@ describe('PageHeader', () => {
const wrapper = render(<PageHeader title={false} />);
expect(wrapper).toMatchSnapshot();
});

it('breadcrumbs and back icon can only have one', () => {
const routes = [
{
path: 'index',
breadcrumbName: 'First-level Menu',
},
{
path: 'first',
breadcrumbName: 'Second-level Menu',
},
{
path: 'second',
breadcrumbName: 'Third-level Menu',
},
];
const wrapper = mount(<PageHeader title="Title" onBack={() => true} breadcrumb={{ routes }} />);
expect(wrapper.find('.ant-breadcrumb')).toHaveLength(0);

wrapper.setProps({ onBack: undefined });
expect(wrapper.find('.ant-breadcrumb')).toHaveLength(1);
});
});
161 changes: 63 additions & 98 deletions components/page-header/demo/actions.md
@@ -1,8 +1,8 @@
---
order: 5
order: 4
title:
zh-CN: 复杂的例子
en-US: Complex example
zh-CN: 组合起来的例子
chenshuai2144 marked this conversation as resolved.
Show resolved Hide resolved
en-US: Compose example
---

## zh-CN
Expand All @@ -14,107 +14,72 @@ title:
Use the operating area and customize the sub-nodes, suitable for use in the need to display some complex information to help users quickly understand the information and operations of this page.

```jsx
import { PageHeader, Tag, Tabs, Button, Statistic, Row, Col } from 'antd';

const { TabPane } = Tabs;

const Description = ({ term, children, span = 12 }) => (
<Col span={span}>
<div className="description">
<div className="term">{term}</div>
<div className="detail">{children}</div>
</div>
</Col>
);

const content = (
<Row>
<Description term="Created">Lili Qu</Description>
<Description term="Association">
<a>421421</a>
</Description>
<Description term="Creation Time">2017-01-10</Description>
<Description term="Effective Time">2017-10-10</Description>
<Description term="Remarks" span={24}>
Gonghu Road, Xihu District, Hangzhou, Zhejiang, China
</Description>
</Row>
);

const extraContent = (
<Row>
<Col span={12}>
<Statistic title="Status" value="Pending" />
</Col>
<Col span={12}>
<Statistic title="Price" prefix="$" value={568.08} />
</Col>
</Row>
);
import { PageHeader, Tag, Button, Statistic, Descriptions } from 'antd';

ReactDOM.render(
<PageHeader
onBack={() => window.history.back()}
title="Title"
subTitle="This is a subtitle"
tags={<Tag color="red">Warning</Tag>}
extra={[
<Button key="3">Operation</Button>,
<Button key="2">Operation</Button>,
<Button key="1" type="primary">
Primary
</Button>,
]}
footer={
<Tabs defaultActiveKey="1">
<TabPane tab="Details" key="1" />
<TabPane tab="Rule" key="2" />
</Tabs>
}
>
<div className="wrap">
<div className="content padding">{content}</div>
<div className="extraContent">{extraContent}</div>
</div>
</PageHeader>,
<div>
<PageHeader
onBack={() => window.history.back()}
title="Title"
subTitle="This is a subtitle"
extra={[
<Button key="3">Operation</Button>,
<Button key="2">Operation</Button>,
<Button key="1" type="primary">
Primary
</Button>,
]}
>
<Descriptions size="small" column={3}>
<Descriptions.item label="Created">Lili Qu</Descriptions.item>
<Descriptions.item label="Association">
<a>421421</a>
</Descriptions.item>
<Descriptions.item label="Creation Time">2017-01-10</Descriptions.item>
<Descriptions.item label="Effective Time">2017-10-10</Descriptions.item>
<Descriptions.item label="Remarks">
Gonghu Road, Xihu District, Hangzhou, Zhejiang, China
</Descriptions.item>
</Descriptions>
</PageHeader>
<br />
<PageHeader
onBack={() => window.history.back()}
title="Title"
tags={<Tag color="blue">Running</Tag>}
subTitle="This is a subtitle"
extra={[
<Button key="3">Operation</Button>,
<Button key="2">Operation</Button>,
<Button key="1" type="primary">
Primary
</Button>,
]}
>
<div
style={{
display: 'flex',
}}
>
<Statistic title="Status" value="Pending" />
<Statistic
title="Price"
prefix="$"
value={568.08}
style={{
margin: '0 32px',
}}
/>
<Statistic title="Balance" prefix="$" value={3345.08} />
</div>
</PageHeader>
</div>,
mountNode,
);
```

<style>
#components-page-header-demo-actions .wrap {
display: flex;
}
#components-page-header-demo-actions .content {
flex: 1;
}
#components-page-header-demo-actions .extraContent {
min-width: 240px;
text-align: right;
}
#components-page-header-demo-actions .content.padding {
padding-left: 40px;
}
#components-page-header-demo-actions .content .description {
display: table;
}
#components-page-header-demo-actions .description .term {
display: table-cell;
margin-right: 8px;
padding-bottom: 8px;
white-space: nowrap;
line-height: 20px;
}
#components-page-header-demo-actions .description .term:after {
position: relative;
top: -0.5px;
margin: 0 8px 0 2px;
content: ":";
}
#components-page-header-demo-actions .description .detail {
display: table-cell;
padding-bottom: 8px;
width: 100%;
line-height: 20px;
tr:last-child td {
padding-bottom: 0;
}
</style>
5 changes: 4 additions & 1 deletion components/page-header/demo/breadcrumb.md
Expand Up @@ -31,5 +31,8 @@ const routes = [
},
];

ReactDOM.render(<PageHeader title="Title" breadcrumb={{ routes }} />, mountNode);
ReactDOM.render(
<PageHeader title="Title" breadcrumb={{ routes }} subTitle="This is a subtitle" />,
mountNode,
);
chenshuai2144 marked this conversation as resolved.
Show resolved Hide resolved
```