File tree Expand file tree Collapse file tree
src/components/notification Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ order : 1
3+ title : Drawer
4+ desc : 抽屉组件基础用法
5+ ---
6+
7+ ``` jsx
8+ import React , { useState } from ' react' ;
9+ import { Notification , Button } from ' cloud-react' ;
10+
11+ export default function NotificationDemo () {
12+ const open = () => {
13+ Notification .open ({
14+ title: ' 这里是标题' ,
15+ content: ' 消息通知内容消息通知内容消息' ,
16+ showCancelBtn: true ,
17+ showConfirmBtn: true ,
18+ img: < img alt= " img" src= " https://brand-guide.shuyun.com/IAM/9677a408554b.png" / >
19+ // img: <img alt="img" src="https://brand-guide.shuyun.com/IAM/3791de5591a7.jpg"/>
20+
21+ });
22+ }
23+ return (
24+ < Button onClick= {open}> 打开消息< / Button>
25+
26+
27+ );
28+ }
29+ ```
Original file line number Diff line number Diff line change 99 path : /action
1010---
1111
12- ### 何时使用
12+ ## 何时使用
1313在系统四个角显示通知提醒信息。经常用于以下情况:
1414- 较为复杂的通知内容。
1515- 带有交互的通知,给出用户下一步的行动点。
1616- 系统主动推送。
1717
1818
19- ### API
19+ ## API
2020
21- #### Drawer 基础配置项
21+ ### Drawer 基础配置项
2222
2323| 属性 | 说明 | 类型 | 默认值
2424| -------------- | ---------------------- | ----------------- | ------ |
2727| duration | 自动关闭的延时,单位毫秒。设为 0 时不自动关闭 | number | 4500 | |
2828| title | 标题 | ReactNode | - | |
2929| content | 内容 | ReactNode | - | |
30+ | img | 内容下方图片 | ReactNode | - | |
3031| showCloseIcon | 是否展示右上角关闭图标 | ReactNode | - | |
3132| btn | 自定义右下角按钮 | ReactNode | - | |
3233| className | 自定义类名 | string | - | |
4546| onDetailClick | 查看详情回调 | function | - |
4647
4748
48- ### 代码演示
49+ ## 代码演示
4950
5051### 基础用法
5152<embed src =" @components/notification/demos/basic.md " />
5859
5960### 自定义样式
6061<embed src =" @components/notification/demos/custom.md " />
62+
63+ ### 带图片(可支持jpg、png、gif格式)
64+ <embed src =" @components/notification/demos/image.md " />
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ const ICON_TYPE_MAP = {
1616export default function NotificationBody ( {
1717 title,
1818 content,
19+ img,
1920 duration,
2021 showIcon,
2122 iconType,
@@ -48,16 +49,30 @@ export default function NotificationBody({
4849 } , [ dataSetId , duration ] ) ;
4950
5051 return (
51- < section className = { `${ notificationPrefix } ${ borderRadiusSize } ${ className } ${ isLightTheme && 'light-theme' } ` } style = { style } >
52- { icon || (
53- showIcon && < Icon className = { `info-icon ${ iconType } ` } type = { ICON_TYPE_MAP [ iconType ] } />
54- ) }
52+ < section
53+ className = { `${ notificationPrefix } ${ borderRadiusSize } ${ className } ${
54+ isLightTheme && 'light-theme'
55+ } `}
56+ style = { style }
57+ >
58+ { icon
59+ || ( showIcon && (
60+ < Icon
61+ className = { `info-icon ${ iconType } ` }
62+ type = { ICON_TYPE_MAP [ iconType ] }
63+ />
64+ ) ) }
5565 < div className = { `${ notificationPrefix } -content` } >
5666 < header >
5767 < p > { title } </ p >
58- < Icon className = "close-icon" type = "close" onClick = { ( ) => close ( dataSetId , placement ) } />
68+ < Icon
69+ className = "close-icon"
70+ type = "close"
71+ onClick = { ( ) => close ( dataSetId , placement ) }
72+ />
5973 </ header >
6074 < main > { content } </ main >
75+ { ! ! img && < div className = { `${ notificationPrefix } -img-area` } > { img } </ div > }
6176 { ( showDetailBtn || showConfirmBtn || showCancelBtn ) && (
6277 < footer >
6378 { showDetailBtn && (
@@ -82,7 +97,7 @@ export default function NotificationBody({
8297 ) }
8398 { showCancelBtn && (
8499 < Button
85- type = "normal "
100+ type = "secondary "
86101 onClick = { ( ) => {
87102 close ( dataSetId , placement ) ;
88103 onClose ( ) ;
Original file line number Diff line number Diff line change 9494 gap : 16px ;
9595 margin-top : 20px ;
9696 }
97+ &-img-area {
98+ width : 320px ;
99+ height : 180px ;
100+ margin : 20px auto ;
101+ img {
102+ width : 100% ;
103+ height : 100% ;
104+ border-radius : 6px ;
105+ }
106+ }
97107}
You can’t perform that action at this time.
0 commit comments