From 297aaae9268c24e7e8a40ab953550d374d3ef26c Mon Sep 17 00:00:00 2001 From: Wanli Song Date: Sun, 28 Nov 2021 00:26:31 +0800 Subject: [PATCH] feat(notification): max, placement & destroyAll (#1685) * feat(notification): add max & placement * feat(notification): add destroyAll method * doc: add changelog * test(notification): fix test lint Co-authored-by: wanli.song@tusimple.ai --- CHANGELOG.en-US.md | 5 + CHANGELOG.zh-CN.md | 5 + .../demos/enUS/index.demo-entry.md | 5 + src/notification/demos/enUS/max.demo.md | 44 ++++++++ src/notification/demos/enUS/placement.demo.md | 64 +++++++++++ .../demos/zhCN/index.demo-entry.md | 5 + src/notification/demos/zhCN/max.demo.md | 44 ++++++++ src/notification/demos/zhCN/placement.demo.md | 64 +++++++++++ .../src/NotificationContainer.tsx | 16 ++- src/notification/src/NotificationProvider.tsx | 28 ++++- src/notification/src/styles/index.cssr.ts | 64 +++++++++-- src/notification/tests/Notification.spec.tsx | 106 +++++++++++++++++- 12 files changed, 435 insertions(+), 15 deletions(-) create mode 100644 src/notification/demos/enUS/max.demo.md create mode 100644 src/notification/demos/enUS/placement.demo.md create mode 100644 src/notification/demos/zhCN/max.demo.md create mode 100644 src/notification/demos/zhCN/placement.demo.md diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index fb53eae3b70..6f5bb9dade8 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -14,6 +14,11 @@ - `n-input-number` add `keyboard` prop. - Add `tableColorStriped` theme variable, closes [#1686](https://github.com/TuSimple/naive-ui/issues/1686). +### Feats + +- `n-notification-provider` add `max` & `placement` prop. +- `n-notification` add `destroyAll` method, closes [#333](https://github.com/TuSimple/naive-ui/issues/333). + ## 2.21.1 (2021-11-23) ### Fixes diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index ec89f384915..938734d8a26 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -14,6 +14,11 @@ - `n-input-number` 新增 `keyboard` 属性 - 新增 `tableColorStriped` 主题变量,关闭 [#1686](https://github.com/TuSimple/naive-ui/issues/1686) +### Feats + +- `n-notification-provider` 新增 `max` & `placement` 属性 +- `n-notification` 新增 `detroyAll` 方法,关闭 [#333](https://github.com/TuSimple/naive-ui/issues/333) + ## 2.21.1 (2021-11-23) ### Fixes diff --git a/src/notification/demos/enUS/index.demo-entry.md b/src/notification/demos/enUS/index.demo-entry.md index c553db64639..bdffc8dfb1c 100644 --- a/src/notification/demos/enUS/index.demo-entry.md +++ b/src/notification/demos/enUS/index.demo-entry.md @@ -46,6 +46,8 @@ change-content scrollable closable duration +max +placement ``` ## API @@ -54,6 +56,8 @@ duration | Name | Type | Default | Description | | --- | --- | --- | --- | +| placement | `'top-right' \| 'top-left' \| 'bottom-left' \| 'bottom -right'` | `'top-right'` | Placement of all notifications. | +| max | `number` | `undefined` | Limit the number of notifications to display. | | scrollable | `boolean` | `true` | Whether notification can be scroll. | | to | `string \| HTMLElement` | `'body'` | Container node of notification container. | @@ -62,6 +66,7 @@ duration | Name | Type | Description | | --- | --- | --- | | create | `(option: NotificationOption) => NotificationReactive` | Create a notification. | +| destroyAll | `() => void` | Destroy all popup notifications. | | error | `(option: NotificationOption) => NotificationReactive` | Use `error` type notification. | | info | `(option: NotificationOption) => NotificationReactive` | Use `info` type notification. | | success | `(option: NotificationOption) => NotificationReactive` | Use `success` type notification. | diff --git a/src/notification/demos/enUS/max.demo.md b/src/notification/demos/enUS/max.demo.md new file mode 100644 index 00000000000..4328cc89f14 --- /dev/null +++ b/src/notification/demos/enUS/max.demo.md @@ -0,0 +1,44 @@ +# Max + +```html + +