Skip to content

Commit

Permalink
chore: update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Aug 1, 2023
1 parent eb4038f commit 70ae908
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/abc/st/demo/type.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,34 @@ Support for ten different column types: no, checkbox, radio, badge, tag, image,

```ts
import { Component } from '@angular/core';
import { STColumn, STColumnBadge, STColumnTag } from '@delon/abc/st';

import { STColumn, STColumnBadge, STColumnTag, STData } from '@delon/abc/st';

const BADGE: STColumnBadge = {
1: { text: '成功', color: 'success' },
2: { text: '错误', color: 'error' },
2: { text: '错误', color: 'error', tooltip: 'TIPS' },
3: { text: '进行中', color: 'processing' },
4: { text: '默认', color: 'default' },
5: { text: '警告', color: 'warning' },
5: { text: '警告', color: 'warning' }
};
const TAG: STColumnTag = {
1: { text: '成功', color: 'green' },
2: { text: '错误', color: 'red' },
3: { text: '进行中', color: 'blue' },
4: { text: '默认', color: '' },
5: { text: '警告', color: 'orange' },
5: { text: '警告', color: 'orange', tooltip: 'TIPS' }
};
const r = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1) + min);
const r = (min: number, max: number): number => Math.floor(Math.random() * (max - min + 1) + min);

@Component({
selector: 'app-demo',
template: `
<button nz-button (click)="reload()">Reload</button>
<st #st [data]="users" [columns]="columns" [page]="{ position: 'both' }"></st>
`,
`
})
export class DemoComponent {
users: any[] = [];
users: STData[] = [];
columns: STColumn[] = [
{ title: '行号', type: 'no' },
{ title: '姓名', index: 'name' },
Expand All @@ -51,7 +52,7 @@ export class DemoComponent {
{ title: 'tag', index: 'tag', type: 'tag', tag: TAG },
{ title: 'badge', index: 'badge', type: 'badge', badge: BADGE },
{ title: 'Enum', index: 'enum', type: 'enum', enum: { 1: '', 2: '', 3: '' } },
{ title: 'yn', index: 'yn', type: 'yn' },
{ title: 'yn', index: 'yn', type: 'yn' }
];

reload(): void {
Expand All @@ -65,7 +66,7 @@ export class DemoComponent {
badge: r(1, 5),
enum: r(1, 3),
yn: [true, false][r(1, 5) % 2],
html: `<strong>${idx + 1}</strong> Other`,
html: `<strong>${idx + 1}</strong> Other`
}));
}

Expand Down

0 comments on commit 70ae908

Please sign in to comment.