Skip to content

Commit

Permalink
refactor(module:modal): migrate demo to standalone mode (#8796)
Browse files Browse the repository at this point in the history
  • Loading branch information
Laffery authored Sep 25, 2024
1 parent 334ce11 commit 4f536ce
Show file tree
Hide file tree
Showing 14 changed files with 108 additions and 86 deletions.
5 changes: 5 additions & 0 deletions components/modal/demo/async.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Component } from '@angular/core';

import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzModalModule } from 'ng-zorro-antd/modal';

@Component({
selector: 'nz-demo-modal-async',
standalone: true,
imports: [NzButtonModule, NzModalModule],
template: `
<button nz-button nzType="primary" (click)="showModal()">
<span>Show Modal</span>
Expand Down
7 changes: 5 additions & 2 deletions components/modal/demo/basic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Component } from '@angular/core';

import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzModalModule } from 'ng-zorro-antd/modal';

@Component({
selector: 'nz-demo-modal-basic',
standalone: true,
imports: [NzButtonModule, NzModalModule],
template: `
<button nz-button [nzType]="'primary'" (click)="showModal()"><span>Show Modal</span></button>
<nz-modal [(nzVisible)]="isVisible" nzTitle="The first Modal" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
Expand All @@ -16,8 +21,6 @@ import { Component } from '@angular/core';
export class NzDemoModalBasicComponent {
isVisible = false;

constructor() {}

showModal(): void {
this.isVisible = true;
}
Expand Down
7 changes: 5 additions & 2 deletions components/modal/demo/confirm-promise.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Component } from '@angular/core';

import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzModalModule, NzModalRef, NzModalService } from 'ng-zorro-antd/modal';

@Component({
selector: 'nz-demo-modal-confirm-promise',
template: ` <button nz-button nzType="primary" (click)="showConfirm()">Confirm</button> `
standalone: true,
imports: [NzButtonModule, NzModalModule],
template: `<button nz-button nzType="primary" (click)="showConfirm()">Confirm</button>`
})
export class NzDemoModalConfirmPromiseComponent {
confirmModal?: NzModalRef; // For testing by now
Expand Down
5 changes: 4 additions & 1 deletion components/modal/demo/confirm.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Component } from '@angular/core';

import { NzModalService } from 'ng-zorro-antd/modal';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzModalModule, NzModalService } from 'ng-zorro-antd/modal';

@Component({
selector: 'nz-demo-modal-confirm',
standalone: true,
imports: [NzButtonModule, NzModalModule],
template: `
<button nz-button nzType="primary" (click)="showConfirm()">Confirm</button>
<button nz-button nzType="dashed" (click)="showDeleteConfirm()">Delete</button>
Expand Down
7 changes: 5 additions & 2 deletions components/modal/demo/draggable.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Component } from '@angular/core';

import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzModalModule } from 'ng-zorro-antd/modal';

@Component({
selector: 'nz-demo-modal-draggable',
standalone: true,
imports: [NzButtonModule, NzModalModule],
template: `
<button nz-button nzType="default" (click)="showModal()">
<span>Open Draggable Modal</span>
Expand All @@ -25,8 +30,6 @@ import { Component } from '@angular/core';
export class NzDemoModalDraggableComponent {
isVisible = false;

constructor() {}

showModal(): void {
this.isVisible = true;
}
Expand Down
7 changes: 5 additions & 2 deletions components/modal/demo/footer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Component } from '@angular/core';

import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzModalModule } from 'ng-zorro-antd/modal';

@Component({
selector: 'nz-demo-modal-footer',
standalone: true,
imports: [NzButtonModule, NzModalModule],
template: `
<button nz-button nzType="primary" (click)="showModal()">
<span>Show Modal</span>
Expand Down Expand Up @@ -35,8 +40,6 @@ export class NzDemoModalFooterComponent {
isVisible = false;
isConfirmLoading = false;

constructor() {}

showModal(): void {
this.isVisible = true;
}
Expand Down
7 changes: 6 additions & 1 deletion components/modal/demo/footer2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import { Component } from '@angular/core';

import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzModalModule, NzModalRef, NzModalService } from 'ng-zorro-antd/modal';

@Component({
selector: 'nz-demo-modal-footer2',
standalone: true,
imports: [NzButtonModule, NzModalModule],
template: `
<button nz-button nzType="primary" (click)="showModal1()">
<span>In Template</span>
Expand Down Expand Up @@ -64,6 +67,8 @@ export class NzDemoModalFooter2Component {

@Component({
selector: 'nz-modal-custom-footer-component',
standalone: true,
imports: [NzButtonModule, NzModalModule],
template: `
<div>
<p>Modal Content</p>
Expand Down
5 changes: 4 additions & 1 deletion components/modal/demo/info.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Component } from '@angular/core';

import { NzModalService } from 'ng-zorro-antd/modal';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzModalModule, NzModalService } from 'ng-zorro-antd/modal';

@Component({
selector: 'nz-demo-modal-info',
standalone: true,
imports: [NzButtonModule, NzModalModule],
template: `
<button nz-button (click)="info()">Info</button>
<button nz-button (click)="success()">Success</button>
Expand Down
5 changes: 4 additions & 1 deletion components/modal/demo/locale.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Component } from '@angular/core';

import { NzModalService } from 'ng-zorro-antd/modal';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzModalModule, NzModalService } from 'ng-zorro-antd/modal';

@Component({
selector: 'nz-demo-modal-locale',
standalone: true,
imports: [NzButtonModule, NzModalModule],
template: `
<div>
<button nz-button nzType="primary" (click)="showModal()">Modal</button>
Expand Down
7 changes: 5 additions & 2 deletions components/modal/demo/manual.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Component } from '@angular/core';

import { NzModalService } from 'ng-zorro-antd/modal';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzModalModule, NzModalService } from 'ng-zorro-antd/modal';

@Component({
selector: 'nz-demo-modal-manual',
template: ` <button nz-button (click)="success()">Success</button> `
standalone: true,
imports: [NzButtonModule, NzModalModule],
template: `<button nz-button (click)="success()">Success</button>`
})
export class NzDemoModalManualComponent {
constructor(private modalService: NzModalService) {}
Expand Down
5 changes: 0 additions & 5 deletions components/modal/demo/module

This file was deleted.

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

import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzModalModule } from 'ng-zorro-antd/modal';

@Component({
selector: 'nz-demo-modal-position',
standalone: true,
imports: [NzButtonModule, NzModalModule],
template: `
<button nz-button nzType="primary" (click)="showModalTop()">Display a modal dialog at 20px to Top</button>
<nz-modal
Expand Down
7 changes: 6 additions & 1 deletion components/modal/demo/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { Component, inject, Input, TemplateRef, ViewContainerRef } from '@angular/core';

import { NzModalRef, NzModalService, NZ_MODAL_DATA } from 'ng-zorro-antd/modal';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzModalRef, NzModalService, NZ_MODAL_DATA, NzModalModule } from 'ng-zorro-antd/modal';

interface IModalData {
favoriteLibrary: string;
Expand All @@ -11,6 +12,8 @@ interface IModalData {

@Component({
selector: 'nz-demo-modal-service',
standalone: true,
imports: [NzButtonModule, NzModalModule],
template: `
<button nz-button nzType="primary" (click)="createModal()">
<span>String</span>
Expand Down Expand Up @@ -183,6 +186,8 @@ export class NzDemoModalServiceComponent {

@Component({
selector: 'nz-modal-custom-component',
standalone: true,
imports: [NzButtonModule],
template: `
<div>
<h2>{{ title }}</h2>
Expand Down
Loading

0 comments on commit 4f536ce

Please sign in to comment.