Skip to content

Commit

Permalink
refactor(module:comment): refactor and aync Ant Design 4 (NG-ZORRO#4664)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsuanxyz authored Mar 2, 2020
1 parent bc5dbb5 commit 802f244
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 73 deletions.
File renamed without changes.
65 changes: 65 additions & 0 deletions components/comment/comment.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* @license
* Copyright Alibaba.com All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

import { ChangeDetectionStrategy, Component, ContentChildren, Input, QueryList, TemplateRef, ViewEncapsulation } from '@angular/core';

import { NzCommentActionComponent as CommentAction } from './comment-cells';

@Component({
selector: 'nz-comment',
exportAs: 'nzComment',
template: `
<div class="ant-comment-inner">
<div class="ant-comment-avatar">
<ng-content select="nz-avatar[nz-comment-avatar]"></ng-content>
</div>
<div class="ant-comment-content">
<div class="ant-comment-content-author">
<span *ngIf="nzAuthor" class="ant-comment-content-author-name">
<ng-container *nzStringTemplateOutlet="nzAuthor">{{ nzAuthor }}</ng-container>
</span>
<span *ngIf="nzDatetime" class="ant-comment-content-author-time">
<ng-container *nzStringTemplateOutlet="nzDatetime">{{ nzDatetime }}</ng-container>
</span>
</div>
<ng-content select="nz-comment-content"></ng-content>
<ul class="ant-comment-actions" *ngIf="actions?.length">
<li *ngFor="let action of actions">
<span><ng-template [nzCommentActionHost]="action.content"></ng-template></span>
</li>
</ul>
</div>
</div>
<div class="ant-comment-nested">
<ng-content></ng-content>
</div>
`,
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'ant-comment'
},
styles: [
`
nz-comment {
display: block;
}
nz-comment-content {
display: block;
}
`
]
})
export class NzCommentComponent {
@Input() nzAuthor: string | TemplateRef<void>;
@Input() nzDatetime: string | TemplateRef<void>;

@ContentChildren(CommentAction) actions: QueryList<CommentAction>;
constructor() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
NzCommentActionHostDirective,
NzCommentAvatarDirective,
NzCommentContentDirective
} from './nz-comment-cells';
import { NzCommentComponent } from './nz-comment.component';
} from './comment-cells';
import { NzCommentComponent } from './comment.component';

const NZ_COMMENT_CELLS = [NzCommentAvatarDirective, NzCommentContentDirective, NzCommentActionComponent, NzCommentActionHostDirective];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { NzDemoCommentEditorComponent } from './demo/editor';
import { NzDemoCommentListComponent } from './demo/list';
import { NzDemoCommentNestedComponent } from './demo/nested';

import { NzCommentComponent } from './nz-comment.component';
import { NzCommentModule } from './nz-comment.module';
import { NzCommentComponent } from './comment.component';
import { NzCommentModule } from './comment.module';

describe('NzCommentComponent', () => {
beforeEach(async(() => {
Expand Down
4 changes: 2 additions & 2 deletions components/comment/demo/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { distanceInWords } from 'date-fns';
</p>
</nz-comment-content>
<nz-comment-action>
<i nz-tooltip nzTitle="Like" nz-icon nzType="like" [theme]="likes > 0 ? 'twotone' : 'outline'" (click)="like()"></i>
<i nz-tooltip nzTitle="Like" nz-icon nzType="like" [nzTheme]="likes > 0 ? 'twotone' : 'outline'" (click)="like()"></i>
<span class="count like">{{ likes }}</span>
</nz-comment-action>
<nz-comment-action>
<i nz-tooltip nzTitle="Dislike" nz-icon nzType="dislike" [theme]="dislikes > 0 ? 'twotone' : 'outline'" (click)="dislike()"></i>
<i nz-tooltip nzTitle="Dislike" nz-icon nzType="dislike" [nzTheme]="dislikes > 0 ? 'twotone' : 'outline'" (click)="dislike()"></i>
<span class="count dislike">{{ dislikes }}</span>
</nz-comment-action>
<nz-comment-action>Reply to</nz-comment-action>
Expand Down
24 changes: 0 additions & 24 deletions components/comment/nz-comment.component.html

This file was deleted.

40 changes: 0 additions & 40 deletions components/comment/nz-comment.component.ts

This file was deleted.

6 changes: 3 additions & 3 deletions components/comment/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

export * from './nz-comment.module';
export * from './nz-comment.component';
export * from './nz-comment-cells';
export * from './comment.module';
export * from './comment.component';
export * from './comment-cells';

0 comments on commit 802f244

Please sign in to comment.