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(module:descriptions): add component #3327

Merged
merged 8 commits into from Jun 5, 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
1 change: 1 addition & 0 deletions components/components.less
Expand Up @@ -13,6 +13,7 @@
@import "./collapse/style/entry.less";
@import "./comment/style/entry.less";
@import "./date-picker/style/entry.less";
@import "./descriptions/style/entry.less";
@import "./divider/style/entry.less";
@import "./drawer/style/entry.less";
@import "./dropdown/style/entry.less";
Expand Down
1 change: 1 addition & 0 deletions components/core/public-api.ts
Expand Up @@ -21,3 +21,4 @@ export * from './util/public-api';
export * from './wave/public-api';
export * from './dropdown/public-api';
export * from './logger/public-api';
export * from './responsive/public-api';
27 changes: 27 additions & 0 deletions components/core/responsive/break-point.ts
@@ -0,0 +1,27 @@
/**
* @license
* Copyright Alibaba.com All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

export enum Breakpoint {
xxl = 'xxl',
xl = 'xl',
lg = 'lg',
md = 'md',
sm = 'sm',
xs = 'xs'
}

export type BreakpointMap = { [key in Breakpoint]: string };

export const responsiveMap: BreakpointMap = {
xs: '(max-width: 575px)',
sm: '(min-width: 576px)',
md: '(min-width: 768px)',
lg: '(min-width: 992px)',
xl: '(min-width: 1200px)',
xxl: '(min-width: 1600px)'
};
wzhudev marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions components/core/responsive/index.ts
@@ -0,0 +1 @@
export * from './public-api';
1 change: 1 addition & 0 deletions components/core/responsive/public-api.ts
@@ -0,0 +1 @@
export * from './break-point';
14 changes: 14 additions & 0 deletions components/descriptions/demo/basic.md
@@ -0,0 +1,14 @@
---
order: 0
title:
zh-CN: 基本
en-US: Basic
---

## zh-CN

简单的展示。

## en-US

Basic usage.
20 changes: 20 additions & 0 deletions components/descriptions/demo/basic.ts
@@ -0,0 +1,20 @@
import { Component } from '@angular/core';

@Component({
selector: 'nz-demo-descriptions-basic',
template: `
<nz-descriptions nzTitle="User Info">
<nz-descriptions-item nzTitle="UserName">Zhou Maomao</nz-descriptions-item>
<nz-descriptions-item nzTitle="Telephone">18100000000</nz-descriptions-item>
<nz-descriptions-item nzTitle="Live">Hangzhou, Zhejiang</nz-descriptions-item>
<nz-descriptions-item nzTitle="Remark">Empty</nz-descriptions-item>
<nz-descriptions-item nzTitle="Address">
No. 18, Wantang Road, Xihu District, Hangzhou, Zhejiang, China
</nz-descriptions-item>
</nz-descriptions>
`
})

export class NzDemoDescriptionsBasicComponent {

}
14 changes: 14 additions & 0 deletions components/descriptions/demo/border.md
@@ -0,0 +1,14 @@
---
order: 1
title:
zh-CN: 带边框的
en-US: Border
---

## zh-CN

带边框和背景颜色列表。

## en-US

Descriptions with border and background color.
38 changes: 38 additions & 0 deletions components/descriptions/demo/border.ts
@@ -0,0 +1,38 @@
import { Component } from '@angular/core';

@Component({
selector: 'nz-demo-descriptions-border',
template: `
<nz-descriptions nzTitle="User Info" nzBordered>
<nz-descriptions-item nzTitle="Product">Cloud Database</nz-descriptions-item>
<nz-descriptions-item nzTitle="Billing Mode">Prepaid</nz-descriptions-item>
<nz-descriptions-item nzTitle="Automatic Renewal">YES</nz-descriptions-item>
<nz-descriptions-item nzTitle="Order Time">
2018-04-24 18:00:00
</nz-descriptions-item>
<nz-descriptions-item nzTitle="Usage Time" [nzSpan]="3">
2018-04-24 18:00:00 To 2019-04-24 18:00:00
</nz-descriptions-item>
<nz-descriptions-item nzTitle="Status" [nzSpan]="3">
<nz-badge nzStatus="processing" nzText="Running"></nz-badge>
</nz-descriptions-item>
<nz-descriptions-item nzTitle="Negotiated Amount">$80.00</nz-descriptions-item>
<nz-descriptions-item nzTitle="Discount">$20.00</nz-descriptions-item>
<nz-descriptions-item nzTitle="Official Receipts">$60.00</nz-descriptions-item>
<nz-descriptions-item nzTitle="Config Info">
Data disk type: MongoDB
<br />
Database version: 3.4
<br />
Package: dds.mongo.mid
<br />
Storage space: 10 GB
<br />
Replication_factor:3
<br />
Region: East China 1<br />
</nz-descriptions-item>
</nz-descriptions>
`
})
export class NzDemoDescriptionsBorderComponent {}
14 changes: 14 additions & 0 deletions components/descriptions/demo/custom-size.md
@@ -0,0 +1,14 @@
---
order: 2
title:
zh-CN: 自定义尺寸
en-US: Custom size
---

## zh-CN

自定义尺寸,适应在各种容器中展示。

## en-US

Custom sizes to fit in a variety of containers.
41 changes: 41 additions & 0 deletions components/descriptions/demo/custom-size.ts
@@ -0,0 +1,41 @@
import { Component } from '@angular/core';

@Component({
selector: 'nz-demo-descriptions-custom-size',
template: `
<nz-radio-group [(ngModel)]="size">
<label nz-radio nzValue="default">default</label>
<label nz-radio nzValue="middle">middle</label>
<label nz-radio nzValue="small">small</label>
</nz-radio-group>
<br />
<br />
<nz-descriptions nzTitle="Custom Size" nzBordered [nzSize]="size">
<nz-descriptions-item nzTitle="Product">
Cloud Database
</nz-descriptions-item>
<nz-descriptions-item nzTitle="Billing">Prepaid</nz-descriptions-item>
<nz-descriptions-item nzTitle="time">18:00:00</nz-descriptions-item>
<nz-descriptions-item nzTitle="Amount">$80.00</nz-descriptions-item>
<nz-descriptions-item nzTitle="Discount">$20.00</nz-descriptions-item>
<nz-descriptions-item nzTitle="Official">$60.00</nz-descriptions-item>
<nz-descriptions-item nzTitle="Config Info">
Data disk type: MongoDB
<br />
Database version: 3.4
<br />
Package: dds.mongo.mid
<br />
Storage space: 10 GB
<br />
Replication_factor:3
<br />
Region: East China 1
<br />
</nz-descriptions-item>
</nz-descriptions>
`
})
export class NzDemoDescriptionsCustomSizeComponent {
size = 'default';
}
14 changes: 14 additions & 0 deletions components/descriptions/demo/responsive.md
@@ -0,0 +1,14 @@
---
order: 3
title:
zh-CN: 响应式
en-US: Responsive
---

## zh-CN

通过响应式的配置可以实现在小屏幕设备上的完美呈现。

## en-US

Responsive configuration enables perfect presentation on small screen devices.
32 changes: 32 additions & 0 deletions components/descriptions/demo/responsive.ts
@@ -0,0 +1,32 @@
import { Component } from '@angular/core';

@Component({
selector: 'nz-demo-descriptions-responsive',
template: `
<nz-descriptions nzTitle="Responsive Descriptions" [nzColumn]="{ xxl: 4, xl: 3, lg: 3, md: 3, sm: 2, xs: 1 }">
<nz-descriptions-item nzTitle="Product">
Cloud Database
</nz-descriptions-item>
<nz-descriptions-item nzTitle="Billing">Prepaid</nz-descriptions-item>
<nz-descriptions-item nzTitle="time">18:00:00</nz-descriptions-item>
<nz-descriptions-item nzTitle="Amount">$80.00</nz-descriptions-item>
<nz-descriptions-item nzTitle="Discount">$20.00</nz-descriptions-item>
<nz-descriptions-item nzTitle="Official">$60.00</nz-descriptions-item>
<nz-descriptions-item nzTitle="Config Info">
Data disk type: MongoDB
<br />
Database version: 3.4
<br />
Package: dds.mongo.mid
<br />
Storage space: 10 GB
<br />
Replication_factor:3
<br />
Region: East China 1
<br />
</nz-descriptions-item>
</nz-descriptions>
`
})
export class NzDemoDescriptionsResponsiveComponent {}
38 changes: 38 additions & 0 deletions components/descriptions/doc/index.en-US.md
@@ -0,0 +1,38 @@
---
category: Components
type: Data Display
title: Descriptions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title: Descriptions
title: Description List

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个应该是他们那边搞错了,中英文不一致

cols: 1
---

Display multiple read-only fields in groups.

## When To Use

Commonly displayed on the details page.

## API

### nz-descriptions

| Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
| `[nzTitle]` | Describe the title of the list, displayed at the top | `string\|TemplateRef<void>` | `false` |
| `[nzBordered]` | Whether to display the border | `boolean` | `false` |
| `[nzColumn]` | The number of `nz-descriptions-item` in a row. It could be a number or a object like `{ xs: 8, sm: 16, md: 24}` | `number\|object` | `{ xxl: 3, xl: 3, lg: 3, md: 3, sm: 2, xs: 1 }` |
| `[nzSize]` | Set the size of the list. Only works when `nzBordered` is set | `'default'|'middle'|'small'` | `'default'` |

### Import this Component Individually

You can get more detail [here](/docs/getting-started/en#import-a-component-individually).

```ts
import { NzDescriptionsModule } from 'ng-zorro-antd';
```

### nz-descriptions-item

| Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
| `[nzTitle]` | Description of the content | `boolean` | `string\|TemplateRef<void>` |
| `[nzSpan]` | The number of columns included | `number` | `1` |
39 changes: 39 additions & 0 deletions components/descriptions/doc/index.zh-CN.md
@@ -0,0 +1,39 @@
---
category: Components
type: 数据展示
title: Descriptions
subtitle: 描述列表
cols: 1
---

成组显示多个只读字段。

## 何时使用

常见于详情页的信息展示。

## API

wzhudev marked this conversation as resolved.
Show resolved Hide resolved
### nz-descriptions

| 参数 | 说明 | 类型 | 默认值 |
| -------- | ----------- | ---- | ------- |
| `[nzTitle]` | 描述列表的标题,显示在最顶部 | `string\|TemplateRef<void>` | `false` |
| `[nzBorder]` | 是否展示边框 | `boolean` | `false` |
| `[nzColumn]` | 一行的 `nz-descriptions-item` 的数量,可以写成像素值或支持响应式的对象写法 `{ xs: 8, sm: 16, md: 24}` | `number\|object` | `{ xxl: 3, xl: 3, lg: 3, md: 3, sm: 2, xs: 1 }` |
| `[nzSize]` | 设置列表的大小(只有设置 `nzBordered` 时生效) | `'default'|'middle'|'small'` | `'default'` |

### 单独引入此组件

想要了解更多关于单独引入组件的内容,可以在[快速上手](/docs/getting-started/zh#单独引入某个组件)页面进行查看。

```ts
import { NzDescriptionsModule } from 'ng-zorro-antd';
```

### nz-descriptions-item

| 参数 | 说明 | 类型 | 默认值 |
| -------- | ----------- | ---- | ------- |
| `[nzTitle]` | 内容的描述 | `string\|TemplateRef<void>` | - |
| `[nzSpan]` | 包含列的数量 | `number` | `1` |
9 changes: 9 additions & 0 deletions components/descriptions/index.ts
@@ -0,0 +1,9 @@
/**
* @license
* Copyright Alibaba.com All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

export * from './public-api';
17 changes: 17 additions & 0 deletions components/descriptions/nz-descriptions-definitions.ts
@@ -0,0 +1,17 @@
/**
* @license
* Copyright Alibaba.com All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

import { TemplateRef } from '@angular/core';

export type NzDescriptionsSize = 'default' | 'middle' | 'small';

export interface NzDescriptionsItemRenderProps {
title: string | TemplateRef<void>;
span: number;
content: TemplateRef<void>;
}
4 changes: 4 additions & 0 deletions components/descriptions/nz-descriptions-item.component.html
@@ -0,0 +1,4 @@
<!-- Use a template to wrap contents so contents wouldn't be displayed. -->
<ng-template>
<ng-content></ng-content>
</ng-template>
26 changes: 26 additions & 0 deletions components/descriptions/nz-descriptions-item.component.ts
@@ -0,0 +1,26 @@
/**
* @license
* Copyright Alibaba.com All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

import { ChangeDetectionStrategy, Component, Input, TemplateRef, ViewChild, ViewEncapsulation } from '@angular/core';

import { InputNumber } from 'ng-zorro-antd/core';

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-descriptions-item',
wzhudev marked this conversation as resolved.
Show resolved Hide resolved
templateUrl: './nz-descriptions-item.component.html',
exportAs: 'nzDescriptionsItem',
preserveWhitespaces: false
})
export class NzDescriptionsItemComponent {
@ViewChild(TemplateRef) content: TemplateRef<void>;

@Input() @InputNumber() nzSpan = 1;
@Input() nzTitle: string = '';
}