-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(table): replace loading with skeleton and make skeleton stronger…
… #INFR-9201 (#2799)
- Loading branch information
1 parent
89f5cd0
commit 89d5cd5
Showing
15 changed files
with
504 additions
and
167 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum ThyTableColumnSkeletonType { | ||
title = 'title', | ||
member = 'member', | ||
default = 'default' | ||
} |
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 @@ | ||
export * from './column-skeleton-type'; |
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 |
---|---|---|
@@ -1 +1,17 @@ | ||
<thy-table-skeleton [thyRowCount]="5"> </thy-table-skeleton> | ||
<span>默认:</span> | ||
<div class="mt-2"> | ||
<thy-radio-group [(ngModel)]="theme"> | ||
<label thyRadio thyLabelText="Default" thyInline thyValue="default"></label> | ||
<label thyRadio thyLabelText="Bordered" thyInline thyValue="bordered"></label> | ||
<label thyRadio thyLabelText="Boxed" thyInline thyValue="boxed"></label> | ||
</thy-radio-group> | ||
</div> | ||
<thy-button-group thySize="sm" thyType="outline-default" class="mb-2"> | ||
<button thyButton *ngFor="let item of sizes" (click)="size = item.value" [ngClass]="{ active: item.value === size }"> | ||
{{ item.value }}({{ item.height }}) | ||
</button> | ||
</thy-button-group> | ||
<thy-table-skeleton [thyRowCount]="5" [thyTheme]="theme" [thySize]="size"> </thy-table-skeleton> | ||
|
||
<span class="d-inline-block mt-8">支持配置骨架列的宽度和类型:</span> | ||
<thy-table-skeleton [thyRowCount]="5" [thyColumns]="columns"> </thy-table-skeleton> |
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 |
---|---|---|
@@ -1,16 +1,49 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Component } from '@angular/core'; | ||
import { ThyTableColumnSkeletonType, ThyTableSize, ThyTableSkeletonColumn, ThyTableTheme } from 'ngx-tethys/table'; | ||
|
||
@Component({ | ||
selector: 'thy-table-skeleton-example', | ||
templateUrl: './skeleton.component.html' | ||
}) | ||
export class ThyTableSkeletonExampleComponent implements OnInit { | ||
export class ThyTableSkeletonExampleComponent { | ||
data = [ | ||
{ id: 1, name: 'Peter', age: 25, job: 'Engineer', address: 'Beijing Dong Sheng Technology' }, | ||
{ id: 2, name: 'James', age: 26, job: 'Designer', address: 'Xian Economic Development Zone' }, | ||
{ id: 3, name: 'Tom', age: 30, job: 'Engineer', address: 'New Industrial Park, Shushan, Hefei, Anhui' } | ||
]; | ||
constructor() {} | ||
|
||
ngOnInit() {} | ||
theme: ThyTableTheme = 'default'; | ||
|
||
sizes: { value: ThyTableSize; height: number }[] = [ | ||
{ | ||
value: 'xs', | ||
height: 44 | ||
}, | ||
{ | ||
value: 'sm', | ||
height: 48 | ||
}, | ||
{ | ||
value: 'md', | ||
height: 52 | ||
}, | ||
{ | ||
value: 'lg', | ||
height: 56 | ||
}, | ||
{ | ||
value: 'xlg', | ||
height: 60 | ||
} | ||
]; | ||
|
||
size: ThyTableSize = 'md'; | ||
|
||
columns: ThyTableSkeletonColumn[] = [ | ||
{ width: '40%', type: ThyTableColumnSkeletonType.title }, | ||
{ width: 'auto', type: ThyTableColumnSkeletonType.default }, | ||
{ width: 'auto', type: ThyTableColumnSkeletonType.default }, | ||
{ width: 'auto', type: ThyTableColumnSkeletonType.default }, | ||
{ width: '17%', type: ThyTableColumnSkeletonType.member } | ||
]; | ||
} |
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 |
---|---|---|
@@ -1,79 +1,87 @@ | ||
<table> | ||
<thead> | ||
<tr> | ||
<th [width]="i === 0 ? '40%' : i === 1 ? '20%' : 'auto'" *ngFor="let key of columnCount; index as i"> | ||
<thy-skeleton-rectangle | ||
[thyRowWidth]="titleWidth" | ||
[thyRowHeight]="titleHeight" | ||
[thyBorderRadius]="thyBorderRadius" | ||
[thyAnimated]="thyAnimated" | ||
[thyAnimatedInterval]="thyAnimatedInterval" | ||
[thyPrimaryColor]="thyPrimaryColor" | ||
[thySecondaryColor]="thySecondaryColor" | ||
></thy-skeleton-rectangle> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<ng-template ngFor let-item [ngForOf]="rowCount" let-i="index + 1"> | ||
<table [ngClass]="tableClassMap" [style.min-width]="thyMinWidth"> | ||
<colgroup> | ||
<col *ngFor="let column of columns; trackBy: trackByFn" [width]="column.width" /> | ||
</colgroup> | ||
<ng-container *ngIf="!thyHeadless"> | ||
<thead> | ||
<tr> | ||
<td> | ||
<div class="d-flex" style="align-items:center"> | ||
<thy-skeleton-rectangle | ||
class="mr-2" | ||
[thyRowWidth]="checkBoxWidth" | ||
[thyRowHeight]="thyRowHeight" | ||
[thyBorderRadius]="thyBorderRadius" | ||
[thyAnimated]="thyAnimated" | ||
[thyAnimatedInterval]="thyAnimatedInterval" | ||
[thyPrimaryColor]="thyPrimaryColor" | ||
[thySecondaryColor]="thySecondaryColor" | ||
></thy-skeleton-rectangle> | ||
<thy-skeleton-rectangle | ||
[thyRowWidth]="i % 3 === 1 ? '70%' : i % 3 === 2 ? '85%' : '60%'" | ||
[thyRowHeight]="thyRowHeight" | ||
[thyBorderRadius]="thyBorderRadius" | ||
[thyAnimated]="thyAnimated" | ||
[thyAnimatedInterval]="thyAnimatedInterval" | ||
[thyPrimaryColor]="thyPrimaryColor" | ||
[thySecondaryColor]="thySecondaryColor" | ||
></thy-skeleton-rectangle> | ||
</div> | ||
</td> | ||
<td> | ||
<div class="d-flex" style="align-items:center"> | ||
<thy-skeleton-circle | ||
class="mr-2" | ||
[thySize]="avatarSize" | ||
[thyAnimated]="thyAnimated" | ||
[thyAnimatedInterval]="thyAnimatedInterval" | ||
[thyPrimaryColor]="thyPrimaryColor" | ||
[thySecondaryColor]="thySecondaryColor" | ||
></thy-skeleton-circle> | ||
|
||
<thy-skeleton-rectangle | ||
[thyRowWidth]="i % 3 === 1 ? '50%' : i % 3 === 2 ? '60%' : '40%'" | ||
[thyRowHeight]="thyRowHeight" | ||
[thyBorderRadius]="thyBorderRadius" | ||
[thyAnimated]="thyAnimated" | ||
[thyAnimatedInterval]="thyAnimatedInterval" | ||
[thyPrimaryColor]="thyPrimaryColor" | ||
[thySecondaryColor]="thySecondaryColor" | ||
></thy-skeleton-rectangle> | ||
</div> | ||
</td> | ||
<td *ngFor="let item of columnCount.slice(2)"> | ||
<th *ngFor="let column of columns; trackBy: trackByFn"> | ||
<thy-skeleton-rectangle | ||
[thyRowWidth]="'70%'" | ||
[thyRowHeight]="thyRowHeight" | ||
[thyRowWidth]="titleWidth" | ||
[thyRowHeight]="titleHeight" | ||
[thyBorderRadius]="thyBorderRadius" | ||
[thyAnimated]="thyAnimated" | ||
[thyAnimatedInterval]="thyAnimatedInterval" | ||
[thyPrimaryColor]="thyPrimaryColor" | ||
[thySecondaryColor]="thySecondaryColor" | ||
></thy-skeleton-rectangle> | ||
</td> | ||
[thyPrimaryColor]="thyTheme === 'bordered' || thyTheme === 'boxed' ? '#eee' : thyPrimaryColor" | ||
[thySecondaryColor]="thySecondaryColor"></thy-skeleton-rectangle> | ||
</th> | ||
</tr> | ||
</thead> | ||
</ng-container> | ||
<tbody> | ||
<ng-container *ngFor="let item of rowCount; let i = index"> | ||
<tr> | ||
<ng-container *ngFor="let column of columns; trackBy: trackByFn"> | ||
<td> | ||
<ng-container | ||
*thyViewOutlet=" | ||
column.type === columnType.title | ||
? titleTemplate | ||
: column.type === columnType.member | ||
? memberTemplate | ||
: defaultTemplate; | ||
context:{ | ||
trIndex: i, | ||
} | ||
"></ng-container> | ||
</td> | ||
</ng-container> | ||
</tr> | ||
</ng-template> | ||
</ng-container> | ||
</tbody> | ||
</table> | ||
|
||
<ng-template #titleTemplate let-trIndex="trIndex"> | ||
<div class="d-flex align-items-center"> | ||
<thy-skeleton-rectangle | ||
class="mr-2 flex-shrink-0" | ||
[thyRowWidth]="checkBoxWidth" | ||
[thyRowHeight]="thyRowHeight" | ||
[thyBorderRadius]="thyBorderRadius" | ||
[thyAnimated]="thyAnimated" | ||
[thyAnimatedInterval]="thyAnimatedInterval" | ||
[thyPrimaryColor]="thyPrimaryColor" | ||
[thySecondaryColor]="thySecondaryColor"></thy-skeleton-rectangle> | ||
|
||
<ng-container | ||
*thyViewOutlet="defaultTemplate; | ||
context:{ | ||
rowWidth: trIndex % 3 === 0 ? '75%' : trIndex % 3 === 1 ? '100%' : trIndex % 3 === 2 ? '65%' : '', | ||
}"></ng-container> | ||
</div> | ||
</ng-template> | ||
|
||
<ng-template #memberTemplate> | ||
<div class="d-flex align-items-center"> | ||
<thy-skeleton-circle | ||
class="mr-2 flex-shrink-0" | ||
[thySize]="avatarSize" | ||
[thyAnimated]="thyAnimated" | ||
[thyAnimatedInterval]="thyAnimatedInterval" | ||
[thyPrimaryColor]="thyPrimaryColor" | ||
[thySecondaryColor]="thySecondaryColor"></thy-skeleton-circle> | ||
|
||
<ng-container *thyViewOutlet="defaultTemplate"></ng-container> | ||
</div> | ||
</ng-template> | ||
|
||
<ng-template #defaultTemplate let-rowWidth="rowWidth"> | ||
<thy-skeleton-rectangle | ||
[thyRowWidth]="rowWidth" | ||
[thyRowHeight]="thyRowHeight" | ||
[thyBorderRadius]="thyBorderRadius" | ||
[thyAnimated]="thyAnimated" | ||
[thyAnimatedInterval]="thyAnimatedInterval" | ||
[thyPrimaryColor]="thyPrimaryColor" | ||
[thySecondaryColor]="thySecondaryColor"></thy-skeleton-rectangle> | ||
</ng-template> |
Oops, something went wrong.
89d5cd5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
tethys – ./
tethys-vert.vercel.app
tethys-tethys.vercel.app
tethys-git-master-tethys.vercel.app