Skip to content
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: Message]feature Message component #36

Closed
1 task done
xuemanchi opened this issue Dec 18, 2020 · 4 comments
Closed
1 task done

[comp: Message]feature Message component #36

xuemanchi opened this issue Dec 18, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@xuemanchi
Copy link
Contributor

xuemanchi commented Dec 18, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

What does the proposed API look like?

Message 全局提示

全局展示操作反馈信息。

API

  • message.success(content, [duration])
  • message.error(content, [duration])
  • message.info(content, [duration])
  • message.warn(content, [duration])
  • message.remove([messageId])
  • message.getContainer() 获取message消息容器

也可以通过对象的形式传递参数

  • message.success(config)
  • message.error(config)
  • message.info(config)
  • message.warn(config)
  • message.create(config)
参数 说明 类型 默认值
content 提示内容 string|config|vnode -
duration 自动关闭的延时,单位秒。当设置为0时不消失 number 3

config对象属性如下:

参数 说明 类型 默认值
content 提示内容 string|vnode -
duration 自动关闭的延时,单位秒。设置为0立即关闭 number 3
icon 自定义图标 string|vnode -
messageId 当前提示的唯一标志 string|number -
onClose message关闭时触发的回调函数 function -
pauseOnHover 鼠标移上时禁止自动移除 boolean true

全局方法

组件还提供全局配置和全局销毁方法

通过useGlobalConfig方式设置message的默认全局配置

useGlobalConfig('message', {
  top: 100,
  duration: 2,
  maxCount: 3
});

options:

参数 说明 类型 默认值
duration 默认自动关闭延时,单位秒,设置为0立即关闭 number 3
maxCount 最大显示数, 超过限制时,最早的消息会被自动关闭 number -
top 消息距离顶部的位置 string|number
pauseOnHover 鼠标移上时禁止自动移除 boolean true
message.remove

销毁某个消息实例的方法

参数 说明 类型 默认值
messageId 需要销毁的消息实例对应的messageId。可选参数,如果不传参数则清除所有消息。 string|number|(string|number)[] -
@xuemanchi xuemanchi added the enhancement New feature or request label Dec 18, 2020
@danranVm danranVm mentioned this issue Dec 18, 2020
95 tasks
@danranVm
Copy link
Member

@clfeng @danranVm 负责此组件的 review, API 设计完成后请 @ 他们

@danranVm danranVm added this to the v1.0.0 milestone Dec 25, 2020
@xuemanchi
Copy link
Contributor Author

@clfeng @danranVm 有空看下message的api设计
另外我打算加上单条消息鼠标移入时停止定时清除,鼠标移出后重新开启定时清除这条消息的功能

@danranVm
Copy link
Member

看了下,我个人感觉 ng-zorro-antd 的API 设计会更好些?https://ng.ant.design/components/message/zh

  • 全局配置
    • 使用 useGlobalConfig 的方式,不用额外提供 config 函数。
    • prefixCls 不提供,感觉没什么意义。
    • rtl 不提供,我们暂不支持
    • getContainer 不提供, 暂时就默认到 body 吧,有需求再加。

@xuemanchi
Copy link
Contributor Author

API已修改 prefixCls rtl getContainer暂时移除 后面再看是否需要支持

xuemanchi pushed a commit to xuemanchi/components that referenced this issue Mar 8, 2021
xuemanchi added a commit to xuemanchi/components that referenced this issue Mar 11, 2021
xuemanchi added a commit to xuemanchi/components that referenced this issue Mar 11, 2021
xuemanchi added a commit to xuemanchi/components that referenced this issue Mar 13, 2021
danranVm added a commit that referenced this issue Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants