-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:skeleton): add skeleton component
- Loading branch information
Showing
24 changed files
with
735 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
order: 1 | ||
title: | ||
zh-CN: 动画效果 | ||
en-US: Active Animation | ||
--- | ||
## zh-CN | ||
|
||
显示动画效果。 | ||
|
||
## en-US | ||
|
||
Display active animation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-skeleton-active', | ||
template: ` | ||
<nz-skeleton [nzActive]="true"></nz-skeleton> | ||
` | ||
}) | ||
export class NzDemoSkeletonActiveComponent { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 0 | ||
title: | ||
zh-CN: 基本 | ||
en-US: Basic | ||
--- | ||
|
||
## zh-CN | ||
|
||
最简单的用法。 | ||
|
||
## en-US | ||
|
||
Basic usage. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-skeleton-basic', | ||
template: ` | ||
<nz-skeleton></nz-skeleton> | ||
` | ||
}) | ||
export class NzDemoSkeletonBasicComponent { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 2 | ||
title: | ||
zh-CN: 包含子组件 | ||
en-US: Contains sub component | ||
--- | ||
|
||
## zh-CN | ||
|
||
加载占位图包含子组件。 | ||
|
||
## en-US | ||
|
||
Skeleton contains sub component. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-skeleton-children', | ||
template: ` | ||
<div class="article"> | ||
<nz-skeleton [nzLoading]="loading"> | ||
<h4>Ant Design, a design language</h4> | ||
<p>We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.</p> | ||
</nz-skeleton> | ||
<button nz-button (click)="showSkeleton()" [disabled]="loading"> | ||
Show Skeleton | ||
</button> | ||
</div> | ||
`, | ||
styles : [ | ||
` | ||
.article h4 { | ||
margin-bottom: 16px; | ||
} | ||
.article button { | ||
margin-top: 16px; | ||
} | ||
` | ||
] | ||
}) | ||
export class NzDemoSkeletonChildrenComponent { | ||
loading = false; | ||
|
||
showSkeleton(): void { | ||
this.loading = true; | ||
setTimeout(() => { | ||
this.loading = false; | ||
}, 3000); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 2 | ||
title: | ||
zh-CN: 列表样例 | ||
en-US: List Sample | ||
--- | ||
|
||
## zh-CN | ||
|
||
在列表组件中使用加载占位符。 | ||
|
||
## en-US | ||
|
||
Use skeleton in list component. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-skeleton-list', | ||
template: ` | ||
<nz-switch [(ngModel)]="loading"></nz-switch> | ||
<nz-list [nzDataSource]="listData" [nzRenderItem]="item" [nzItemLayout]="'vertical'"> | ||
<ng-template #item let-item> | ||
<nz-list-item [nzContent]="loading?' ':item.content" [nzActions]="loading?[]:[starAction,likeAction,msgAction]" [nzExtra]="loading?'':extra"> | ||
<nz-skeleton [nzLoading]="loading" [nzActive]="true"> | ||
<ng-template #starAction><i class="anticon anticon-star-o" style="margin-right: 8px;"></i> 156</ng-template> | ||
<ng-template #likeAction><i class="anticon anticon-like-o" style="margin-right: 8px;"></i> 156</ng-template> | ||
<ng-template #msgAction><i class="anticon anticon-message" style="margin-right: 8px;"></i> 2</ng-template> | ||
<nz-list-item-meta | ||
[nzAvatar]="item.avatar" | ||
[nzTitle]="nzTitle" | ||
[nzDescription]="item.description"> | ||
<ng-template #nzTitle><a href="{{item.href}}">{{item.title}}</a></ng-template> | ||
</nz-list-item-meta> | ||
<ng-template #extra> | ||
<img width="272" alt="logo" src="https://gw.alipayobjects.com/zos/rmsportal/mqaQswcyDLcXyDKnZfES.png"> | ||
</ng-template> | ||
</nz-skeleton> | ||
</nz-list-item> | ||
</ng-template> | ||
</nz-list> | ||
` | ||
}) | ||
export class NzDemoSkeletonListComponent { | ||
loading = true; | ||
listData = new Array(3).fill({}).map((i, index) => { | ||
return { | ||
href: 'http://ng.ant.design', | ||
title: `ant design part ${index}`, | ||
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png', | ||
description: 'Ant Design, a design language for background applications, is refined by Ant UED Team.', | ||
content: 'We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.' | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
category: Components | ||
type: Data Entry | ||
title: Skeleton | ||
cols: 1 | ||
--- | ||
|
||
Provide a placeholder at the place which need waiting for loading. | ||
|
||
## When To Use | ||
|
||
- When resource need long time loading, like low network speed. | ||
- The component contains much information, such as List or Card. | ||
|
||
## API | ||
|
||
### nz-skeleton | ||
|
||
| Property | Description | Type | Default | | ||
| --- | --- | --- | --- | | ||
| `[nzActive]` | Show animation effect | boolean | false | | ||
| `[nzAvatar]` | Show avatar placeholder | boolean | NzSkeletonAvatar | false | | ||
| `[nzLoading]` | Display the skeleton when `true` | boolean | - | | ||
| `[nzParagraph]` | Show paragraph placeholder | boolean | NzSkeletonParagraph | true | | ||
| `[nzTitle]` | Show title placeholder | boolean | NzSkeletonTitle | true | | ||
|
||
|
||
### NzSkeletonAvatar | ||
|
||
| Property | Description | Type | Default | | ||
| --- | --- | --- | --- | | ||
| `size` | Set the size of avatar | Enum{ 'large', 'small', 'default' } | - | | ||
| `shape` | Set the shape of avatar | Enum{ 'circle', 'square' } | - | | ||
|
||
### NzSkeletonTitle | ||
|
||
| Property | Description | Type | Default | | ||
| --- | --- | --- | --- | | ||
| `width` | Set the width of title | number | string | - | | ||
|
||
### NzSkeletonParagraph | ||
|
||
| Property | Description | Type | Default | | ||
| --- | --- | --- | --- | | ||
| `rows` | Set the row count of paragraph | number | - | | ||
| `width` | Set the width of paragraph. When width is an Array, it can set the width of each row. Otherwise only set the last row width | number | string | Array<number | string> | - | |
Oops, something went wrong.