Skip to content

Commit

Permalink
refactor(module:time-picker,timeline): migrate demo to standalone mode (
Browse files Browse the repository at this point in the history
#8815)

* refactor(module:time-picker): migrate demo to standalone mode

* refactor(module:timeline): migrate demo to standalone mode
  • Loading branch information
Laffery authored Oct 2, 2024
1 parent d69fd33 commit d36d73d
Show file tree
Hide file tree
Showing 26 changed files with 226 additions and 220 deletions.
6 changes: 6 additions & 0 deletions components/time-picker/demo/addon.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 { NzButtonModule } from 'ng-zorro-antd/button';
import { NzTimePickerModule } from 'ng-zorro-antd/time-picker';

@Component({
selector: 'nz-demo-time-picker-addon',
standalone: true,
imports: [FormsModule, NzButtonModule, NzTimePickerModule],
template: `
<nz-time-picker [(ngModel)]="time" [nzAddOn]="addOnTemplate" #timePicker></nz-time-picker>
<ng-template #addOnTemplate>
Expand Down
7 changes: 6 additions & 1 deletion components/time-picker/demo/basic.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { NzTimePickerModule } from 'ng-zorro-antd/time-picker';

@Component({
selector: 'nz-demo-time-picker-basic',
template: ` <nz-time-picker [(ngModel)]="time" [nzDefaultOpenValue]="defaultOpenValue"></nz-time-picker> `
standalone: true,
imports: [FormsModule, NzTimePickerModule],
template: `<nz-time-picker [(ngModel)]="time" [nzDefaultOpenValue]="defaultOpenValue"></nz-time-picker>`
})
export class NzDemoTimePickerBasicComponent {
time: Date | null = null;
Expand Down
7 changes: 5 additions & 2 deletions components/time-picker/demo/bordered.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Component } from '@angular/core';

import { NzTimePickerModule } from 'ng-zorro-antd/time-picker';

@Component({
selector: 'nz-demo-time-picker-bordered',
template: ` <nz-time-picker nzBorderless></nz-time-picker> `,
styles: []
standalone: true,
imports: [NzTimePickerModule],
template: `<nz-time-picker nzBorderless></nz-time-picker>`
})
export class NzDemoTimePickerBorderedComponent {}
4 changes: 4 additions & 0 deletions components/time-picker/demo/disabled-part.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';

import { NzTimePickerModule } from 'ng-zorro-antd/time-picker';

@Component({
selector: 'nz-demo-time-picker-disabled-part',
standalone: true,
imports: [NzTimePickerModule],
template: `
<nz-time-picker
[nzDisabledHours]="disabledHours"
Expand Down
6 changes: 5 additions & 1 deletion components/time-picker/demo/disabled.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';

import { NzTimePickerModule } from 'ng-zorro-antd/time-picker';

@Component({
selector: 'nz-demo-time-picker-disabled',
template: ` <nz-time-picker nzDisabled></nz-time-picker> `
standalone: true,
imports: [NzTimePickerModule],
template: `<nz-time-picker nzDisabled></nz-time-picker>`
})
export class NzDemoTimePickerDisabledComponent {}
7 changes: 6 additions & 1 deletion components/time-picker/demo/hide-column.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { NzTimePickerModule } from 'ng-zorro-antd/time-picker';

@Component({
selector: 'nz-demo-time-picker-hide-column',
template: ` <nz-time-picker [(ngModel)]="time" nzFormat="HH:mm"></nz-time-picker> `
standalone: true,
imports: [FormsModule, NzTimePickerModule],
template: `<nz-time-picker [(ngModel)]="time" nzFormat="HH:mm"></nz-time-picker>`
})
export class NzDemoTimePickerHideColumnComponent {
time = new Date();
Expand Down
6 changes: 5 additions & 1 deletion components/time-picker/demo/interval-options.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';

import { NzTimePickerModule } from 'ng-zorro-antd/time-picker';

@Component({
selector: 'nz-demo-time-picker-interval-options',
template: ` <nz-time-picker [nzMinuteStep]="15" [nzSecondStep]="10"></nz-time-picker> `
standalone: true,
imports: [NzTimePickerModule],
template: `<nz-time-picker [nzMinuteStep]="15" [nzSecondStep]="10"></nz-time-picker>`
})
export class NzDemoTimePickerIntervalOptionsComponent {}
5 changes: 0 additions & 5 deletions components/time-picker/demo/module

This file was deleted.

5 changes: 5 additions & 0 deletions components/time-picker/demo/size.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 { NzTimePickerModule } from 'ng-zorro-antd/time-picker';

@Component({
selector: 'nz-demo-time-picker-size',
standalone: true,
imports: [FormsModule, NzTimePickerModule],
template: `
<nz-time-picker [(ngModel)]="time" nzSize="large"></nz-time-picker>
<nz-time-picker [(ngModel)]="time"></nz-time-picker>
Expand Down
12 changes: 8 additions & 4 deletions components/time-picker/demo/status.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { Component } from '@angular/core';

import { NzTimePickerModule } from 'ng-zorro-antd/time-picker';

@Component({
selector: 'nz-demo-time-picker-status',
standalone: true,
imports: [NzTimePickerModule],
template: `
<nz-space nzDirection="vertical">
<nz-time-picker *nzSpaceItem nzStatus="error"></nz-time-picker>
<nz-time-picker *nzSpaceItem nzStatus="warning">></nz-time-picker>
</nz-space>
<nz-time-picker nzStatus="error"></nz-time-picker>
<br />
<br />
<nz-time-picker nzStatus="warning">></nz-time-picker>
`
})
export class NzDemoTimePickerStatusComponent {}
29 changes: 10 additions & 19 deletions components/time-picker/demo/use12-hours.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { NzTimePickerModule } from 'ng-zorro-antd/time-picker';

@Component({
selector: 'nz-demo-time-picker-use12-hours',
standalone: true,
imports: [FormsModule, NzTimePickerModule],
template: `
<nz-time-picker [(ngModel)]="time" [nzUse12Hours]="true" (ngModelChange)="log($event)"></nz-time-picker>
<nz-time-picker
[(ngModel)]="time"
[nzUse12Hours]="true"
(ngModelChange)="log($event)"
nzFormat="h:mm a"
></nz-time-picker>
`,
styles: [
`
nz-time-picker {
margin: 0 8px 12px 0;
}
`
]
<nz-time-picker [(ngModel)]="time" nzUse12Hours></nz-time-picker>
<br />
<br />
<nz-time-picker [(ngModel)]="time" nzUse12Hours nzFormat="h:mm a"></nz-time-picker>
`
})
export class NzDemoTimePickerUse12HoursComponent {
time: Date | null = null;

log(value: Date): void {
console.log(value);
}
}
11 changes: 6 additions & 5 deletions components/time-picker/demo/value.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { NzTimePickerModule } from 'ng-zorro-antd/time-picker';

@Component({
selector: 'nz-demo-time-picker-value',
template: ` <nz-time-picker [(ngModel)]="time" (ngModelChange)="log($event)"></nz-time-picker> `
standalone: true,
imports: [FormsModule, NzTimePickerModule],
template: `<nz-time-picker [(ngModel)]="time"></nz-time-picker>`
})
export class NzDemoTimePickerValueComponent {
time: Date | null = null;

log(time: Date): void {
console.log(time && time.toTimeString());
}
}
2 changes: 2 additions & 0 deletions components/time-picker/time-holder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ describe('time holder', () => {
const date = new Date(0, 0, 0, 15, 0, 0, 0);
expect(mathSecondRound(holder.value!)).toEqual(mathSecondRound(date));
});

it('should set default selected 12-hours with value', () => {
const holderPM = new TimeHolder().setValue(new Date(0, 0, 0, 15, 2, 3), true);
expect(holderPM.selected12Hours).toBe('PM');
const holderAM = new TimeHolder().setValue(new Date(0, 0, 0, 0, 2, 3), true);
expect(holderAM.selected12Hours).toBe('AM');
});

it('should transform special value in 12-hour', () => {
const holder = new TimeHolder().setValue(new Date(), true);
holder.setSelected12Hours('am');
Expand Down
Loading

0 comments on commit d36d73d

Please sign in to comment.