-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[comp:notification] 通知消息提醒 #545
Comments
offset区分verticalOffset (上下边缘距离)和horizontalOffset(左右边缘距离) |
单独使用IxNotification组件,不存在offset、placement配置 |
offset 支持一下数组格式? |
为什么? |
可以
|
保留这两个配置,但是在单独使用template时无效,建议采用useNotification。 单独使用notification组件的场景比较少,若单独使用,则需要每个组件都单独计算位置,还要避免和采用useNotification的弹窗出现位置冲突,更优的方式应该是统一对notification容器做定位。 如果是出于需要特殊场景样式覆盖,提供一个cls配置类名,由业务用此类名覆盖样式 |
placement修改如下:
|
notification中onClose和onDestroy重复 |
最新APIglobalConfig全局的通知提醒配置
IxNotificationProvider通过 NotificationProviderProps
<!-- App.vue -->
<IxNotificationProvider>
<MyComponent />
</IxNotificationProvider>
<!-- MyComponent.vue -->
<template>
<IxButton @click="openNotification">Open</IxButton>
</template>
<script setup lang="ts">
import { useNotification } from '@idux/components/notification'
const notification = useNotification()
const openNotification = ()=> notification.info({
title: 'info',
content: 'this is a notification'
})
</script> useNotification可以使用 NotificationOption
export const useNotification: () => NotificationProviderRef;
export interface NotificationProviderRef {
// 打开通知提醒
open: (options: NotificationProps) => NotificationRef
info: (options: Omit<NotificationProps, 'type'>) => NotificationRef
success: (options: Omit<NotificationProps, 'type'>) => NotificationRef
warning: (options: Omit<NotificationProps, 'type'>) => NotificationRef
error: (options: Omit<NotificationProps, 'type'>) => NotificationRef
// 更新指定 key 的通知的配置
update: (key: VKey, options: Omit<NotificationProps, 'key'>) => void
// 销毁指定 key 的通知信息
destroy: (key: VKey | VKey[]) => void
// 销毁所有通知信息
destroyAll: () => void
}
export interface NotificationRef {
// 通知提醒的唯一标识
key: VKey
// 更新当前配置信息
update: (options: Partial<NotificationOptions>) => void
// 销毁当前通知提醒
destroy: () => void
} |
What problem does this feature solve?
What does the proposed API look like?
Notification 通知提醒框
全局展示通知提醒信息。
API
IxNotification
NotificationProps
v-model:visible
boolean
destroyOnHover
boolean
false
duration
number
icon
string | VNode
closeIcon
string | VNode
type
'info' | 'success' | 'warning' | 'error'
info
key
string | number | symbol
offset
number | string
px
;string时可为`vhplacement
topLeft | topRight | bottomLeft | bottomRight
string
topRight
title
string | VNode
content
string | VNode
footer
string | VNode | ButtonProps[]
onClose
() => void
IxNotificationProvider
如果你想通过
useNotification
来创建通知,则你需要把组件包裹在IxNotificationProvider
内部,因为这样才不会丢失应用的上下文信息。NotificationProviderProps
全局的通知提醒配置,继承于
NotificationProps
maxCount
number
useNotification
可以使用
useNotification
来快速创建和管理通知提醒信息。NotificationSlot
title
default
footer
The text was updated successfully, but these errors were encountered: