Skip to content

Commit

Permalink
refactor(module:progress,statistic,rate,result): migrate demo to stan…
Browse files Browse the repository at this point in the history
…dalone mode (#8800)

* refactor(module:progress): migrate demo to standalone mode

* refactor(module:rate): migrate demo to standalone mode

* refactor(module:result): migrate demo to standalone mode

* refactor(module:statistic): migrate demo to standalone mode
  • Loading branch information
Laffery authored Oct 1, 2024
1 parent 6c43fab commit 7869fec
Show file tree
Hide file tree
Showing 42 changed files with 275 additions and 144 deletions.
6 changes: 6 additions & 0 deletions components/progress/demo/circle-dynamic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { Component } from '@angular/core';

import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { NzProgressModule } from 'ng-zorro-antd/progress';

@Component({
selector: 'nz-demo-progress-circle-dynamic',
standalone: true,
imports: [NzButtonModule, NzIconModule, NzProgressModule],
template: `
<nz-progress [nzPercent]="percent" nzType="circle"></nz-progress>
<nz-button-group>
Expand Down
4 changes: 4 additions & 0 deletions components/progress/demo/circle-mini.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';

import { NzProgressModule } from 'ng-zorro-antd/progress';

@Component({
selector: 'nz-demo-progress-circle-mini',
standalone: true,
imports: [NzProgressModule],
template: `
<nz-progress [nzPercent]="75" nzType="circle" [nzWidth]="80"></nz-progress>
<nz-progress [nzPercent]="70" nzType="circle" [nzWidth]="80" nzStatus="exception"></nz-progress>
Expand Down
4 changes: 4 additions & 0 deletions components/progress/demo/circle.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';

import { NzProgressModule } from 'ng-zorro-antd/progress';

@Component({
selector: 'nz-demo-progress-circle',
standalone: true,
imports: [NzProgressModule],
template: `
<nz-progress [nzPercent]="75" nzType="circle"></nz-progress>
<nz-progress [nzPercent]="70" nzType="circle" nzStatus="exception"></nz-progress>
Expand Down
10 changes: 8 additions & 2 deletions components/progress/demo/dashboard-layout.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { Component } from '@angular/core';

import { NzProgressModule } from 'ng-zorro-antd/progress';

@Component({
selector: 'nz-demo-progress-dashboard-layout',
template: `<nz-progress [nzPercent]="1" nzType="dashboard" [nzGapDegree]="90"></nz-progress>
standalone: true,
imports: [NzProgressModule],
template: `
<nz-progress [nzPercent]="1" nzType="dashboard" [nzGapDegree]="90"></nz-progress>
<nz-progress [nzPercent]="75" nzType="dashboard" [nzGapDegree]="180"></nz-progress>
<nz-progress [nzPercent]="75" nzType="dashboard" [nzGapDegree]="295"></nz-progress>
<nz-progress [nzPercent]="1" nzType="dashboard" [nzGapDegree]="340"></nz-progress>`
<nz-progress [nzPercent]="1" nzType="dashboard" [nzGapDegree]="340"></nz-progress>
`
})
export class NzDemoProgressDashboardLayoutComponent {}
6 changes: 5 additions & 1 deletion components/progress/demo/dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';

import { NzProgressModule } from 'ng-zorro-antd/progress';

@Component({
selector: 'nz-demo-progress-dashboard',
template: ` <nz-progress [nzPercent]="75" nzType="dashboard"></nz-progress> `
standalone: true,
imports: [NzProgressModule],
template: `<nz-progress [nzPercent]="75" nzType="dashboard"></nz-progress>`
})
export class NzDemoProgressDashboardComponent {}
6 changes: 6 additions & 0 deletions components/progress/demo/dynamic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { Component } from '@angular/core';

import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { NzProgressModule } from 'ng-zorro-antd/progress';

@Component({
selector: 'nz-demo-progress-dynamic',
standalone: true,
imports: [NzButtonModule, NzIconModule, NzProgressModule],
template: `
<nz-progress [nzPercent]="percent"></nz-progress>
<nz-button-group>
Expand Down
4 changes: 4 additions & 0 deletions components/progress/demo/format.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';

import { NzProgressModule } from 'ng-zorro-antd/progress';

@Component({
selector: 'nz-demo-progress-format',
standalone: true,
imports: [NzProgressModule],
template: `
<nz-progress [nzPercent]="75" nzType="circle" [nzFormat]="formatOne"></nz-progress>
<nz-progress [nzPercent]="100" nzType="circle" [nzFormat]="formatTwo"></nz-progress>
Expand Down
4 changes: 4 additions & 0 deletions components/progress/demo/gradient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component, ViewEncapsulation } from '@angular/core';

import { NzProgressModule } from 'ng-zorro-antd/progress';

@Component({
selector: 'nz-demo-progress-gradient',
standalone: true,
imports: [NzProgressModule],
template: `
<nz-progress [nzPercent]="99.9" [nzStrokeColor]="{ '0%': '#108ee9', '100%': '#87d068' }"></nz-progress>
<nz-progress
Expand Down
4 changes: 4 additions & 0 deletions components/progress/demo/line-mini.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';

import { NzProgressModule } from 'ng-zorro-antd/progress';

@Component({
selector: 'nz-demo-progress-line-mini',
standalone: true,
imports: [NzProgressModule],
template: `
<div style="width: 170px;">
<nz-progress [nzPercent]="30" nzSize="small"></nz-progress>
Expand Down
4 changes: 4 additions & 0 deletions components/progress/demo/line.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';

import { NzProgressModule } from 'ng-zorro-antd/progress';

@Component({
selector: 'nz-demo-progress-line',
standalone: true,
imports: [NzProgressModule],
template: `
<nz-progress [nzPercent]="30"></nz-progress>
<nz-progress [nzPercent]="50" nzStatus="active"></nz-progress>
Expand Down
5 changes: 0 additions & 5 deletions components/progress/demo/module

This file was deleted.

4 changes: 4 additions & 0 deletions components/progress/demo/round.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';

import { NzProgressModule } from 'ng-zorro-antd/progress';

@Component({
selector: 'nz-demo-progress-round',
standalone: true,
imports: [NzProgressModule],
template: `
<nz-progress nzStrokeLinecap="round" nzPercent="75"></nz-progress>
<nz-progress nzStrokeLinecap="round" nzType="circle" nzPercent="75"></nz-progress>
Expand Down
11 changes: 8 additions & 3 deletions components/progress/demo/segment.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
import { Component } from '@angular/core';

import { NzProgressModule } from 'ng-zorro-antd/progress';
import { NzToolTipModule } from 'ng-zorro-antd/tooltip';

@Component({
selector: 'nz-demo-progress-segment',
standalone: true,
imports: [NzProgressModule, NzToolTipModule],
template: `
<nz-progress
nz-tooltip
nzTitle="3 done / 3 in progress / 4 to do"
nzTooltipTitle="3 done / 3 in progress / 4 to do"
[nzPercent]="60"
[nzSuccessPercent]="30"
></nz-progress>
<nz-progress
nz-tooltip
nzTitle="3 done / 3 in progress / 4 to do"
nzTooltipTitle="3 done / 3 in progress / 4 to do"
nzType="circle"
[nzPercent]="60"
[nzSuccessPercent]="30"
></nz-progress>
<nz-progress
nz-tooltip
nzTitle="3 done / 3 in progress / 4 to do"
nzTooltipTitle="3 done / 3 in progress / 4 to do"
nzType="dashboard"
[nzPercent]="60"
[nzSuccessPercent]="30"
Expand Down
4 changes: 4 additions & 0 deletions components/progress/demo/step.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';

import { NzProgressModule } from 'ng-zorro-antd/progress';

@Component({
selector: 'nz-demo-progress-step',
standalone: true,
imports: [NzProgressModule],
template: `
<nz-progress [nzPercent]="50" [nzSteps]="3" nzStrokeColor="#1890ff"></nz-progress>
<nz-progress [nzPercent]="30" [nzSteps]="5" nzStrokeColor="#1890ff"></nz-progress>
Expand Down
56 changes: 29 additions & 27 deletions components/progress/progress.spec.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
import { BidiModule, Dir } from '@angular/cdk/bidi';
import { BidiModule, Dir, Direction } from '@angular/cdk/bidi';
import { Component, DebugElement, TemplateRef, ViewChild } from '@angular/core';
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';

import { NzProgressComponent } from './progress.component';
import { NzProgressModule } from './progress.module';
import { NzProgressFormatter, NzProgressGapPositionType, NzProgressStrokeColorType } from './typings';
import {
NzProgressFormatter,
NzProgressGapPositionType,
NzProgressStatusType,
NzProgressStrokeColorType,
NzProgressStrokeLinecapType
} from './typings';

describe('progress', () => {
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
imports: [BidiModule, NzProgressModule],
declarations: [
NzTestProgressLineComponent,
NzTestProgressDashBoardComponent,
NzTestProgressCircleComponent,
NzTestProgressCircleSuccessComponent,
NzTestProgressRtlComponent
]
});
TestBed.compileComponents();
}));

describe('progress line', () => {
let fixture: ComponentFixture<NzTestProgressLineComponent>;
let testComponent: NzTestProgressLineComponent;
Expand Down Expand Up @@ -99,7 +91,7 @@ describe('progress', () => {
it('should status work', () => {
fixture.detectChanges();
expect(progress.nativeElement.firstElementChild!.classList).toContain('ant-progress-status-normal');
const listOfStatus = ['success', 'exception', 'active', 'normal'];
const listOfStatus: NzProgressStatusType[] = ['success', 'exception', 'active', 'normal'];
testComponent.percent = 100;
listOfStatus.forEach(status => {
testComponent.status = status;
Expand Down Expand Up @@ -430,6 +422,8 @@ describe('progress', () => {
});

@Component({
standalone: true,
imports: [NzProgressModule],
template: `
<nz-progress
[nzSize]="size"
Expand All @@ -448,19 +442,21 @@ describe('progress', () => {
})
export class NzTestProgressLineComponent {
@ViewChild('formatterTemplate') formatterTemplate!: TemplateRef<{ $implicit: number }>;
size?: string;
status?: string;
size!: 'default' | 'small';
status?: NzProgressStatusType;
formatter?: NzProgressFormatter;
strokeWidth?: number;
percent = 0;
successPercent = 0;
showInfo = true;
strokeLinecap = 'round';
strokeLinecap: NzProgressStrokeLinecapType = 'round';
steps?: number;
strokeColor?: NzProgressStrokeColorType;
}

@Component({
standalone: true,
imports: [NzProgressModule],
template: `
<nz-progress
nzType="dashboard"
Expand All @@ -475,16 +471,18 @@ export class NzTestProgressLineComponent {
`
})
export class NzTestProgressDashBoardComponent {
status?: string;
status?: NzProgressStatusType;
format?: NzProgressFormatter;
strokeWidth?: number;
percent = 0;
showInfo = true;
width = 132;
strokeLinecap = 'round';
strokeLinecap: NzProgressStrokeLinecapType = 'round';
}

@Component({
standalone: true,
imports: [NzProgressModule],
template: `
<nz-progress
nzType="circle"
Expand All @@ -498,17 +496,21 @@ export class NzTestProgressDashBoardComponent {
})
export class NzTestProgressCircleComponent {
gapDegree?: number;
gapPosition?: NzProgressGapPositionType;
strokeLinecap = 'round';
gapPosition!: NzProgressGapPositionType;
strokeLinecap: NzProgressStrokeLinecapType = 'round';
strokeColor?: NzProgressStrokeColorType;
}

@Component({
template: ` <nz-progress nzType="circle" [nzPercent]="75" [nzSuccessPercent]="60"></nz-progress> `
standalone: true,
imports: [NzProgressModule],
template: ` <nz-progress nzType="circle" [nzPercent]="75" [nzSuccessPercent]="60"></nz-progress>`
})
export class NzTestProgressCircleSuccessComponent {}

@Component({
standalone: true,
imports: [BidiModule, NzProgressModule],
template: `
<div [dir]="direction">
<nz-progress nzType="circle" [nzPercent]="75" [nzSuccessPercent]="60"></nz-progress>
Expand All @@ -517,5 +519,5 @@ export class NzTestProgressCircleSuccessComponent {}
})
export class NzTestProgressRtlComponent {
@ViewChild(Dir) dir!: Dir;
direction = 'rtl';
direction: Direction = 'rtl';
}
7 changes: 6 additions & 1 deletion components/rate/demo/basic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { NzRateModule } from 'ng-zorro-antd/rate';

@Component({
selector: 'nz-demo-rate-basic',
template: ` <nz-rate [ngModel]="0"></nz-rate> `
standalone: true,
imports: [FormsModule, NzRateModule],
template: `<nz-rate [ngModel]="0"></nz-rate>`
})
export class NzDemoRateBasicComponent {}
6 changes: 6 additions & 0 deletions components/rate/demo/character.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { NzIconModule } from 'ng-zorro-antd/icon';
import { NzRateModule } from 'ng-zorro-antd/rate';

@Component({
selector: 'nz-demo-rate-character',
standalone: true,
imports: [FormsModule, NzIconModule, NzRateModule],
template: `
<nz-rate [ngModel]="0" nzAllowHalf [nzCharacter]="characterIcon"></nz-rate>
<br />
Expand Down
5 changes: 5 additions & 0 deletions components/rate/demo/clear.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { NzRateModule } from 'ng-zorro-antd/rate';

@Component({
selector: 'nz-demo-rate-clear',
standalone: true,
imports: [FormsModule, NzRateModule],
template: `
<nz-rate [(ngModel)]="value" nzAllowHalf></nz-rate>
<span class="ant-rate-text">allowClear: true</span>
Expand Down
6 changes: 6 additions & 0 deletions components/rate/demo/customize.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { NzIconModule } from 'ng-zorro-antd/icon';
import { NzRateModule } from 'ng-zorro-antd/rate';

@Component({
selector: 'nz-demo-rate-customize',
standalone: true,
imports: [FormsModule, NzIconModule, NzRateModule],
template: `
<nz-rate [ngModel]="2" [nzCharacter]="characterNumber"></nz-rate>
<br />
Expand Down
7 changes: 6 additions & 1 deletion components/rate/demo/disabled.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { NzRateModule } from 'ng-zorro-antd/rate';

@Component({
selector: 'nz-demo-rate-disabled',
template: ` <nz-rate [ngModel]="2" nzDisabled></nz-rate> `
standalone: true,
imports: [FormsModule, NzRateModule],
template: `<nz-rate [ngModel]="2" nzDisabled></nz-rate>`
})
export class NzDemoRateDisabledComponent {}
Loading

0 comments on commit 7869fec

Please sign in to comment.