Skip to content

Commit

Permalink
docs(module:message,notification): use global configuration service (#…
Browse files Browse the repository at this point in the history
…4327)

* docs(module:message,notification): use global configuration service

* docs: add notification
  • Loading branch information
Wendell authored and vthinkxie committed Oct 23, 2019
1 parent cc9308d commit 5b6086b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 76 deletions.
21 changes: 4 additions & 17 deletions components/message/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@ You can get more detail [here](/docs/getting-started/en#import-a-component-indiv
import { NzMessageModule } from 'ng-zorro-antd/message';
```

## How To Use

If you want to modify the global default configuration, you can modify the value of provider `NZ_MESSAGE_CONFIG`.
(eg, add `{ provide: NZ_MESSAGE_CONFIG, useValue: { nzDuration: 3000 }}` to `providers` of your module, `NZ_MESSAGE_CONFIG` can be imported from `ng-zorro-antd`)

The default global configuration is:
```js
{
nzDuration: 3000,
nzMaxStack: 7,
nzPauseOnHover: true,
nzAnimate: true
}
```

## API

### NzMessageService
Expand Down Expand Up @@ -64,12 +49,14 @@ Methods for destruction are also provided:

- `message.remove(id)` // Remove the message with the specified id. When the id is empty, remove all messages (the message id is returned by the above method)

### Global configuration (NZ_MESSAGE_CONFIG)
### Global Configuration

You can use `NzConfigService` to configure this component globally. Please check the Global Configuration chapter for more information.

| Argument | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
| nzDuration | Duration (milliseconds), does not disappear when set to 0 | `number` | `3000` |
| nzMaxStack | The maximum number of messages that can be displayed at the same time | `number` | `8` |
| nzMaxStack | The maximum number of messages that can be displayed at the same time | `number` | `7` |
| nzPauseOnHover | Do not remove automatically when mouse is over while setting to `true` | `boolean` | `true` |
| nzAnimate | Whether to turn on animation | `boolean` | `true` |
| nzTop | Distance from top | `number \| string` | `24` |
Expand Down
25 changes: 6 additions & 19 deletions components/message/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,6 @@ title: Message
import { NzMessageModule } from 'ng-zorro-antd/message';
```

## 如何使用

如果要修改全局默认配置,你可以设置提供商 `NZ_MESSAGE_CONFIG` 的值来修改。
(如:在你的模块的`providers`中加入 `{ provide: NZ_MESSAGE_CONFIG, useValue: { nzDuration: 3000 }}``NZ_MESSAGE_CONFIG` 可以从 `ng-zorro-antd` 中导入)

默认全局配置为:
```js
{
nzDuration: 3000,
nzMaxStack: 7,
nzPauseOnHover: true,
nzAnimate: true
}
```

## API

### NzMessageService
Expand Down Expand Up @@ -65,12 +50,14 @@ import { NzMessageModule } from 'ng-zorro-antd/message';

- `NzMessageService.remove(id)` // 移除特定id的消息,当id为空时,移除所有消息(该消息id通过上述方法返回值中得到)

### 全局配置(NZ_MESSAGE_CONFIG)
### 全局配置

可以通过 `NzConfigService` 进行全局配置,详情请见文档中“全局配置项”章节。

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| nzDuration | 持续时间(毫秒),当设置为0时不消失 | `number` | `3000` |
| nzMaxStack | 同一时间可展示的最大提示数量 | `number` | `8` |
| nzDuration | 持续时间(毫秒),当设置为 0 时不消失 | `number` | `3000` |
| nzMaxStack | 同一时间可展示的最大提示数量 | `number` | `7` |
| nzPauseOnHover | 鼠标移上时禁止自动移除 | `boolean` | `true` |
| nzAnimate | 开关动画效果 | `boolean` | `true` |
| nzTop | 消息距离顶部的位置 | `number \| string` | `24` |
Expand All @@ -83,4 +70,4 @@ import { NzMessageModule } from 'ng-zorro-antd/message';
export interface NzMessageDataFilled {
onClose: Subject<false>; // 当 message 关闭时它会派发一个事件
}
```
```
4 changes: 3 additions & 1 deletion components/message/nz-message-base.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { Overlay } from '@angular/cdk/overlay';
import { ApplicationRef, ComponentFactoryResolver, EmbeddedViewRef, Injector, Type } from '@angular/core';
import { NzSingletonService } from 'ng-zorro-antd/core';
import { warnDeprecation, NzSingletonService } from 'ng-zorro-antd/core';

import { NzMessageConfigLegacy } from './nz-message-config';
import { NzMessageContainerComponent } from './nz-message-container.component';
Expand Down Expand Up @@ -59,6 +59,8 @@ export class NzMessageBaseService<
}

config(config: MessageConfig): void {
warnDeprecation(`'config' of 'NzMessageService' and 'NzNotificationService' is deprecated and will be removed in 9.0.0. Please use 'set' of 'NzConfigService' instead.`);

this._container.setConfig(config);
}

Expand Down
24 changes: 4 additions & 20 deletions components/notification/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,6 @@ You can get more detail [here](/docs/getting-started/en#import-a-component-indiv
import { NzNotificationModule } from 'ng-zorro-antd/notification';
```

## How To Use

Similar to `NzMessage`, if you want to modify the global default configuration, you can modify the value of provider `NZ_NOTIFICATION_CONFIG`.
(Example: Add `{ provide: NZ_NOTIFICATION_CONFIG, useValue: { nzDuration: 3000 }}` to `providers` of your module, `NZ_NOTIFICATION_CONFIG` can be imported from `ng-zorro-antd`)

The default global configuration is:
```js
{
nzTop : '24px',
nzBottom : '24px',
nzPlacement : 'topRight',
nzDuration : 4500,
nzMaxStack : 7,
nzPauseOnHover: true,
nzAnimate : true
}
```

## API

### NzNotificationService
Expand Down Expand Up @@ -77,9 +59,11 @@ Methods for destruction are also provided:

- `NzNotificationService.remove(id)` // Remove the notification with the specified id. When the id is empty, remove all notifications (the notification id is returned by the above method)

### Global configuration (NZ_MESSAGE_CONFIG)
### Global Configuration

You can use `NzConfigService` to configure this component globally.

| 参数 | 说明 | 类型 | 默认值 |
| Parameter | Description | Type | Default |
| --- | --- | --- | --- |
| nzDuration | Duration (milliseconds), does not disappear when set to 0 | `number` | 4500 |
| nzMaxStack | The maximum number of notifications that can be displayed at the same time | `number` | 8 |
Expand Down
22 changes: 3 additions & 19 deletions components/notification/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,6 @@ subtitle: 通知提醒框
import { NzNotificationModule } from 'ng-zorro-antd/notification';
```

## 如何使用

`NzMessage`类似,如果要修改全局默认配置,你可以设置提供商 `NZ_NOTIFICATION_CONFIG` 的值来修改。
(如:在你的模块的`providers`中加入 `{ provide: NZ_NOTIFICATION_CONFIG, useValue: { nzDuration: 3000 }}``NZ_NOTIFICATION_CONFIG` 可以从 `ng-zorro-antd` 中导入)

默认全局配置为:
```js
{
nzTop : '24px',
nzBottom : '24px',
nzPlacement : 'topRight',
nzDuration : 4500,
nzMaxStack : 7,
nzPauseOnHover: true,
nzAnimate : true
}
```

## API

### NzNotificationService
Expand Down Expand Up @@ -77,7 +59,9 @@ import { NzNotificationModule } from 'ng-zorro-antd/notification';

- `NzNotificationService.remove(id)` // 移除特定id的消息,当id为空时,移除所有消息(该消息id通过上述方法返回值中得到)

### 全局配置(NZ_MESSAGE_CONFIG)
### 全局配置

可以通过 `NzConfigService` 进行全局配置。

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
Expand Down

0 comments on commit 5b6086b

Please sign in to comment.