Skip to content

Commit

Permalink
fix: css-unit pipe update
Browse files Browse the repository at this point in the history
  • Loading branch information
chensimeng committed Sep 17, 2020
1 parent 0c4b4d1 commit 03b2673
Show file tree
Hide file tree
Showing 51 changed files with 153 additions and 170 deletions.
28 changes: 0 additions & 28 deletions components/core/public-api.ts

This file was deleted.

5 changes: 3 additions & 2 deletions components/modal/modal.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { NgModule } from '@angular/core';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzNoAnimationModule } from 'ng-zorro-antd/core/no-animation';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import { NzPipesModule } from 'ng-zorro-antd/core/pipe';
import { NzI18nModule } from 'ng-zorro-antd/i18n';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { NzPipesModule } from 'ng-zorro-antd/pipes';

import { NzModalCloseComponent } from './modal-close.component';
import { NzModalConfirmContainerComponent } from './modal-confirm-container.component';
Expand All @@ -34,7 +34,8 @@ import { NzModalService } from './modal.service';
NzButtonModule,
NzIconModule,
NzPipesModule,
NzNoAnimationModule
NzNoAnimationModule,
NzPipesModule
],
exports: [NzModalComponent, NzModalFooterDirective],
providers: [NzModalService],
Expand Down
14 changes: 0 additions & 14 deletions components/pipe/demo/bytes.md

This file was deleted.

11 changes: 0 additions & 11 deletions components/pipe/demo/css-unit.ts

This file was deleted.

12 changes: 0 additions & 12 deletions components/pipe/demo/math.ts

This file was deleted.

15 changes: 0 additions & 15 deletions components/pipe/demo/sanitizer.md

This file was deleted.

16 changes: 0 additions & 16 deletions components/pipe/nz-css-unit.pipe.ts

This file was deleted.

14 changes: 14 additions & 0 deletions components/pipes/demo/bytes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
order: 1
title:
zh-CN: nzBytes
en-US: nzBytes
---

## zh-CN

存储单位的换算,增加可读性

## en-US

Conversion of storage units to increase readability
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ title:

## zh-CN

Css 单位补全
Css 单位

## en-US

Css unit completion
Css unit
13 changes: 13 additions & 0 deletions components/pipes/demo/css-unit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Component } from '@angular/core';

@Component({
selector: 'nz-demo-pipe-css-unit',
template: `
<div>
<img [style.height]="100 | nzToCssUnit" src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png" />
</div>
<div [style.height]="50 | nzToCssUnit: 'pt'"></div>
<div [style.height]="'100px' | nzToCssUnit"></div>
`
})
export class NzDemoPipeCssUnitComponent {}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import { Component } from '@angular/core';
@Component({
selector: 'nz-demo-pipe-ellipsis',
template: `
{{ 'Hello World' | nzEllipsis: 4 }}<br />
{{ 'Hello World' | nzEllipsis: 4:'':true }}<br />
{{ 'Hello World' | nzEllipsis: 4:'...':true }}<br />
{{ 'Hello World' | nzEllipsis: 4 }}
<br />
{{ 'Hello World' | nzEllipsis: 4:'':true }}
<br />
{{ 'Hello World' | nzEllipsis: 4:'...':true }}
<br />
{{ 'Hello World, how is it going?' | nzEllipsis: 14:'...':true }}
`
})
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions components/pipes/demo/math.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component } from '@angular/core';

@Component({
selector: 'nz-demo-pipe-math',
template: `
{{ [7, 8, 2, 3] | nzMath: 'min' }}
<br />
{{ [7, 8, 2, 3] | nzMath: 'max' }}
<br />
{{ [7, 8, 2, 3] | nzMath: 'sum' }}
<br />
{{ [7, 8, 2, 3] | nzMath: 'avg' }}
<br />
`
})
export class NzDemoPipeMathComponent {}
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions components/pipes/demo/sanitizer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
order: 6
title:
zh-CN: nzSanitizer
en-US: nzSanitizer
---

## zh-CN

DomSanitizer 的 Pipe 实现

## en-US

Pipe implementation of DomSanitizer
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { Component } from '@angular/core';
@Component({
selector: 'nz-demo-pipe-some',
template: `
{{ [5, 6, 7, 8, 9] | nzSome: method }}<br />
{{ [6, 7, 8, 9, 10] | nzSome: method }}<br />
{{ [5, 6, 7, 8, 9] | nzSome: method }}
<br />
{{ [6, 7, 8, 9, 10] | nzSome: method }}
<br />
`
})
export class NzDemoPipeSomeComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ title:

## zh-CN

返回指定时间格式
按自定义格式返回间隔时间

## en-US

Returns the specified time format
Return interval time in custom format
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import { Component } from '@angular/core';
@Component({
selector: 'nz-demo-pipe-time-range',
template: `
{{ diff | nzTimeRange: format1 }}<br />
{{ diff | nzTimeRange: format2 }}<br />
{{ diff | nzTimeRange: format3 }}<br />
{{ diff1 | nzTimeRange }}<br />
{{ diff | nzTimeRange: format1 }}
<br />
{{ diff | nzTimeRange: format2 }}
<br />
{{ diff | nzTimeRange: format3 }}
<br />
{{ diff1 | nzTimeRange }}
<br />
`
})
export class NzDemoPipeTimeRangeComponent {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import { Component } from '@angular/core';
@Component({
selector: 'nz-demo-pipe-trim',
template: `
{{ 'hello' | nzTrim }}<br />
{{ 'hello ' | nzTrim }}<br />
{{ ' hello ' | nzTrim }}<br />
{{ 'hello' | nzTrim }}
<br />
{{ 'hello ' | nzTrim }}
<br />
{{ ' hello ' | nzTrim }}
<br />
`
})
export class NzDemoPipeTrimComponent {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
category: Components
type: General
title: Pipe
type: Data Entry
cols: 1
experimental: true
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
category: Components
type: 数据录入
title: 常用
subtitle: Pipe
type: 通用
title: Pipe
cols: 1
experimental: true
---
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ describe('NzBytesPipe', () => {
pipe = new NzBytesPipe();
});

it('Should return 150 B', () => {
const result = pipe.transform(150, 0);
expect(result).toEqual('150 B');
it('Should return 120 B', () => {
const result = pipe.transform(120, 0);
expect(result).toEqual('120 B');
});

it('Should return 155 B', () => {
const result = pipe.transform(155.56791, 2);
expect(result).toEqual('155 B');
it('Should return 465 B', () => {
const result = pipe.transform(465.56791, 2);
expect(result).toEqual('465 B');
});

it('Should return 155 B', () => {
const result = pipe.transform(155.5, 1);
expect(result).toEqual('155 B');
it('Should return 50 B', () => {
const result = pipe.transform(55.5, 1);
expect(result).toEqual('50 B');
});

it('Should return 1 kB', () => {
it('Should return 9 kB', () => {
const result = pipe.transform(1024, 0);
expect(result).toEqual('1 kB');
expect(result).toEqual('9 kB');
});

it('Should return 1 kB #2', () => {
it('Should return 1 kB', () => {
const result = pipe.transform(1, 0, 'kB');
expect(result).toEqual('1 kB');
});
Expand All @@ -37,20 +37,20 @@ describe('NzBytesPipe', () => {
expect(result).toEqual('1 kB');
});

it('Should return 890 kB', () => {
const kB = 1024 * 890;
it('Should return 345 kB, #1', () => {
const kB = 1024 * 345;
const result = pipe.transform(kB, 0);
expect(result).toEqual('890 kB');
expect(result).toEqual('345 kB');
});

it('Should return 890 kB #2', () => {
const result = pipe.transform(890, 0, 'kB');
expect(result).toEqual('890 kB');
it('Should return 345 kB, #2', () => {
const result = pipe.transform(345, 0, 'kB');
expect(result).toEqual('345 kB');
});

it('Should return 890 kB #3', () => {
const result = pipe.transform(890, 0, 'KB');
expect(result).toEqual('890 kB');
it('Should return 666 kB, #3', () => {
const result = pipe.transform(666, 0, 'KB');
expect(result).toEqual('666 kB');
});

it('Should return 1023 kB', () => {
Expand All @@ -59,13 +59,13 @@ describe('NzBytesPipe', () => {
expect(result).toEqual('1023 kB');
});

it('Should return 241 MB', () => {
it('Should return 241 MB, #1', () => {
const mb = 1024 * 1024 * 240.5691;
const result = pipe.transform(mb, 0);
expect(result).toEqual('241 MB');
});

it('Should return 241 MB', () => {
it('Should return 241 MB, #2', () => {
const mb = 240.5691 / 1024;
const result = pipe.transform(mb, 0, 'GB');
expect(result).toEqual('241 MB');
Expand All @@ -77,13 +77,13 @@ describe('NzBytesPipe', () => {
expect(result).toEqual('240.54 MB');
});

it('Should return 1023 MB', () => {
it('Should return 1023 MB, #1', () => {
const mb = 1024 * 1024 * 1023;
const result = pipe.transform(mb, 2);
expect(result).toEqual('1023 MB');
});

it('Should return 1023 MB #2', () => {
it('Should return 1023 MB, #2', () => {
const kB = 1024 * 1023;
const result = pipe.transform(kB, 2, 'kB');
expect(result).toEqual('1023 MB');
Expand Down
Loading

0 comments on commit 03b2673

Please sign in to comment.