Skip to content

Commit

Permalink
refactor(module:card): migrate demo to standalone mode (#8742)
Browse files Browse the repository at this point in the history
* refactor(module:card): migrate demo to standalone mode

* refactor(module:card): migrate demo to standalone mode
  • Loading branch information
Laffery authored Sep 12, 2024
1 parent 99b6b15 commit 66f0a04
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 43 deletions.
39 changes: 20 additions & 19 deletions components/card/card.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { BidiModule, Dir } from '@angular/cdk/bidi';
import { BidiModule, Dir, Direction } from '@angular/cdk/bidi';
import { Component, NO_ERRORS_SCHEMA, ViewChild } from '@angular/core';
import { TestBed, waitForAsync } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

import { EditOutline, EllipsisOutline, SettingOutline } from '@ant-design/icons-angular/icons';

import { NzSizeDSType } from 'ng-zorro-antd/core/types';
import { NzIconModule } from 'ng-zorro-antd/icon';

import { NzCardComponent } from './card.component';
import { NzCardModule } from './card.module';
Expand All @@ -19,22 +25,13 @@ import { NzDemoCardTabsComponent } from './demo/tabs';
describe('card', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [BidiModule, NzCardModule],
schemas: [NO_ERRORS_SCHEMA],
declarations: [
NzDemoCardBasicComponent,
NzDemoCardBorderLessComponent,
NzDemoCardFlexibleContentComponent,
NzDemoCardGridCardComponent,
NzDemoCardInColumnComponent,
NzDemoCardInnerComponent,
NzDemoCardLoadingComponent,
NzDemoCardMetaComponent,
NzDemoCardSimpleComponent,
NzDemoCardTabsComponent,
TestCardSizeComponent,
NzTestCardRtlComponent
]
imports: [
BidiModule,
NzCardModule,
NoopAnimationsModule,
NzIconModule.forRoot([SettingOutline, EditOutline, EllipsisOutline])
],
schemas: [NO_ERRORS_SCHEMA]
});
TestBed.compileComponents();
}));
Expand Down Expand Up @@ -138,6 +135,8 @@ describe('card', () => {
});

@Component({
standalone: true,
imports: [NzCardModule],
template: `
<nz-card [nzSize]="size">
<p>Card content</p>
Expand All @@ -147,10 +146,12 @@ describe('card', () => {
`
})
class TestCardSizeComponent {
size = 'default';
size: NzSizeDSType = 'default';
}

@Component({
standalone: true,
imports: [NzCardModule],
template: `
<div [dir]="direction">
<nz-card>
Expand All @@ -163,5 +164,5 @@ class TestCardSizeComponent {
})
export class NzTestCardRtlComponent {
@ViewChild(Dir) dir!: Dir;
direction = 'rtl';
direction: Direction = 'rtl';
}
4 changes: 4 additions & 0 deletions components/card/demo/basic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';

import { NzCardModule } from 'ng-zorro-antd/card';

@Component({
selector: 'nz-demo-card-basic',
standalone: true,
imports: [NzCardModule],
template: `
<nz-card style="width:300px;" nzTitle="Card title" [nzExtra]="extraTemplate">
<p>Card content</p>
Expand Down
6 changes: 5 additions & 1 deletion components/card/demo/border-less.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { Component } from '@angular/core';

import { NzCardModule } from 'ng-zorro-antd/card';

@Component({
selector: 'nz-demo-card-border-less',
standalone: true,
imports: [NzCardModule],
template: `
<div style="background: #ECECEC;padding:30px;">
<div style="background: #ECECEC; padding:30px;">
<nz-card style="width:300px;" [nzBordered]="false" nzTitle="Card title" [nzExtra]="extraTemplate">
<p>Card content</p>
<p>Card content</p>
Expand Down
4 changes: 4 additions & 0 deletions components/card/demo/flexible-content.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';

import { NzCardModule } from 'ng-zorro-antd/card';

@Component({
selector: 'nz-demo-card-flexible-content',
standalone: true,
imports: [NzCardModule],
template: `
<nz-card nzHoverable style="width:240px" [nzCover]="coverTemplate">
<nz-card-meta nzTitle="Europe Street beat" nzDescription="www.instagram.com"></nz-card-meta>
Expand Down
35 changes: 21 additions & 14 deletions components/card/demo/grid-card.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
import { Component } from '@angular/core';

import { NzCardModule } from 'ng-zorro-antd/card';

@Component({
selector: 'nz-demo-card-grid-card',
standalone: true,
imports: [NzCardModule],
template: `
<nz-card nzTitle="Cart Title">
<div nz-card-grid [ngStyle]="gridStyle">Content</div>
<div nz-card-grid [ngStyle]="gridStyle">Content</div>
<div nz-card-grid [ngStyle]="gridStyle">Content</div>
<div nz-card-grid [ngStyle]="gridStyle">Content</div>
<div nz-card-grid [ngStyle]="gridStyle">Content</div>
<div nz-card-grid [ngStyle]="gridStyle">Content</div>
<div nz-card-grid [ngStyle]="gridStyle">Content</div>
<div nz-card-grid>Content</div>
<div nz-card-grid>Content</div>
<div nz-card-grid>Content</div>
<div nz-card-grid>Content</div>
<div nz-card-grid>Content</div>
<div nz-card-grid>Content</div>
<div nz-card-grid>Content</div>
</nz-card>
`
`,
styles: [
`
[nz-card-grid] {
width: 25%;
text-align: center;
}
`
]
})
export class NzDemoCardGridCardComponent {
gridStyle = {
width: '25%',
textAlign: 'center'
};
}
export class NzDemoCardGridCardComponent {}
7 changes: 6 additions & 1 deletion components/card/demo/in-column.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { Component } from '@angular/core';

import { NzCardModule } from 'ng-zorro-antd/card';
import { NzGridModule } from 'ng-zorro-antd/grid';

@Component({
selector: 'nz-demo-card-in-column',
standalone: true,
imports: [NzCardModule, NzGridModule],
template: `
<div style="background: #ECECEC;padding:30px;">
<div style="background: #ECECEC; padding:30px;">
<div nz-row [nzGutter]="8">
<div nz-col [nzSpan]="8">
<nz-card nzTitle="Card title">
Expand Down
4 changes: 4 additions & 0 deletions components/card/demo/inner.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';

import { NzCardModule } from 'ng-zorro-antd/card';

@Component({
selector: 'nz-demo-card-inner',
standalone: true,
imports: [NzCardModule],
template: `
<nz-card nzTitle="Card Title">
<p style="font-size:14px;color:rgba(0, 0, 0, 0.85);margin-bottom:16px;font-weight: 500;">Group title</p>
Expand Down
9 changes: 9 additions & 0 deletions components/card/demo/loading.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { NzAvatarModule } from 'ng-zorro-antd/avatar';
import { NzCardModule } from 'ng-zorro-antd/card';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { NzSkeletonModule } from 'ng-zorro-antd/skeleton';
import { NzSwitchModule } from 'ng-zorro-antd/switch';

@Component({
selector: 'nz-demo-card-loading',
standalone: true,
imports: [FormsModule, NzAvatarModule, NzCardModule, NzIconModule, NzSwitchModule, NzSkeletonModule],
template: `
<nz-switch [(ngModel)]="loading"></nz-switch>
<nz-card style="width: 300px;margin-top: 16px" [nzLoading]="loading">
Expand Down
6 changes: 6 additions & 0 deletions components/card/demo/meta.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { Component } from '@angular/core';

import { NzAvatarModule } from 'ng-zorro-antd/avatar';
import { NzCardModule } from 'ng-zorro-antd/card';
import { NzIconModule } from 'ng-zorro-antd/icon';

@Component({
selector: 'nz-demo-card-meta',
standalone: true,
imports: [NzAvatarModule, NzCardModule, NzIconModule],
template: `
<nz-card style="width:300px;" [nzCover]="coverTemplate" [nzActions]="[actionSetting, actionEdit, actionEllipsis]">
<nz-card-meta
Expand Down
8 changes: 0 additions & 8 deletions components/card/demo/module

This file was deleted.

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

import { NzCardModule } from 'ng-zorro-antd/card';

@Component({
selector: 'nz-demo-card-simple',
standalone: true,
imports: [NzCardModule],
template: `
<nz-card style="width:300px;">
<p>Card content</p>
Expand Down
5 changes: 5 additions & 0 deletions components/card/demo/tabs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Component } from '@angular/core';

import { NzCardModule } from 'ng-zorro-antd/card';
import { NzTabsModule } from 'ng-zorro-antd/tabs';

@Component({
selector: 'nz-demo-card-tabs',
standalone: true,
imports: [NzCardModule, NzTabsModule],
template: `
<nz-card style="width: 100%;" nzTitle="Card title" [nzExtra]="extraTemplate">
<nz-card-tab>
Expand Down

0 comments on commit 66f0a04

Please sign in to comment.