File tree 12 files changed +148
-19
lines changed
12 files changed +148
-19
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,11 @@ const config: IConfig = {
35
35
'babel-plugin-import' ,
36
36
{
37
37
libraryName : 'antd-mobile' ,
38
- libraryDirectory : 'es' ,
39
- style : true ,
38
+ libraryDirectory : 'es/components' ,
39
+ style : false ,
40
+ customStyleName : ( name : string ) => {
41
+ return `antd-mobile/es/components/${ name } /${ name } .css`
42
+ } ,
40
43
} ,
41
44
'antd-mobile' ,
42
45
] ,
Original file line number Diff line number Diff line change @@ -8,7 +8,9 @@ const mobileComponent: ComponentMenus = {
8
8
navigation : [ ] ,
9
9
dataDisplay : [ ] ,
10
10
dataEntry : [ ] ,
11
- feedback : [ ] ,
11
+ feedback : [
12
+ 'src/base-popup' ,
13
+ ] ,
12
14
guidance : [ ] ,
13
15
other : [ ] ,
14
16
}
Original file line number Diff line number Diff line change 24
24
"@babel/core" : " ^7.18.10" ,
25
25
"@babel/preset-env" : " ^7.18.10" ,
26
26
"ahooks" : " ^3.7.0" ,
27
- "antd" : " ^4.22.7" ,
27
+ "antd" : " 4.x" ,
28
+ "antd-mobile" : " 5.x" ,
28
29
"classnames" : " ^2.3.1" ,
29
30
"less" : " ^4.1.3" ,
30
31
"less-plugin-npm-import" : " ^2.1.0" ,
Original file line number Diff line number Diff line change
1
+ import React , { useRef } from 'react'
2
+ import { Button } from 'antd-mobile'
3
+ import type { UseModalEnhancedAction , UseModalEnhancedContext } from '@template-pro/mobile-ui'
4
+ import { BasePopup } from '@template-pro/mobile-ui'
5
+
6
+ const Content = ( { enhancedAction } : Partial < UseModalEnhancedContext > ) => (
7
+ < div style = { { padding : 24 } } >
8
+ < h3 > 这是弹出层内容</ h3 >
9
+ < Button onClick = { enhancedAction ?. close } >
10
+ 点击关闭弹出层
11
+ </ Button >
12
+ </ div >
13
+ )
14
+
15
+ function App ( ) {
16
+ const drawerRef = useRef < UseModalEnhancedAction > ( null )
17
+
18
+ return (
19
+ < BasePopup
20
+ content = { < Content /> }
21
+ bodyStyle = { { height : '40vh' } }
22
+ actionRef = { drawerRef }
23
+ >
24
+ < Button > 打开弹出层</ Button >
25
+ </ BasePopup >
26
+ )
27
+ }
28
+
29
+ export default App
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import { BasePopup } from '@template-pro/mobile-ui'
3
+ import { Button , Toast } from 'antd-mobile'
4
+
5
+ export default ( ) => (
6
+ < >
7
+ < BasePopup
8
+ content = { < span style = { { height : '10vh' , display : 'inline-block' } } > 这是弹出层内容</ span > }
9
+ triggerClick = { ( event , action ) => {
10
+ window . console . log ( { event, action } )
11
+ Toast . show ( {
12
+ content : '1秒后打开弹出层' ,
13
+ icon : 'loading' ,
14
+ duration : 1000 ,
15
+ afterClose : action . open ,
16
+ } )
17
+ } }
18
+ >
19
+ < Button > Click me</ Button >
20
+ </ BasePopup >
21
+ </ >
22
+ )
Original file line number Diff line number Diff line change
1
+ # BasePopup
2
+
3
+ ## 基础用法
4
+
5
+ <code hideActions =' ["CSB", "EXTERNAL"] ' src =" ./demo/Base.tsx " />
6
+
7
+ ## 通过事件手动控制打开
8
+
9
+ <code hideActions =' ["CSB", "EXTERNAL"] ' src =" ./demo/Event.tsx " />
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import classNames from 'classnames'
3
+ import type { PopupProps } from 'antd-mobile/es/components/popup'
4
+ import Popup from 'antd-mobile/es/components/popup'
5
+ import type { UseModalEnhancedProps } from '@template-pro/utils'
6
+ import { useModalEnhanced } from '@template-pro/utils'
7
+ import { defaultPrefixCls } from '../constants'
8
+
9
+ export type BasePopupProps = PopupProps & Omit < UseModalEnhancedProps , 'onClick' > & {
10
+ triggerClick ?: UseModalEnhancedProps [ 'onClick' ]
11
+ }
12
+
13
+ const BasePopup = ( props : BasePopupProps ) => {
14
+ const {
15
+ className,
16
+ onClose,
17
+ onClick,
18
+ triggerClick,
19
+ ...restProps
20
+ } = props
21
+
22
+ const [
23
+ visible ,
24
+ { close } ,
25
+ { trigger, content } ,
26
+ ] = useModalEnhanced ( { ...restProps , onClick : triggerClick } )
27
+
28
+ const handlePopupClose = ( ) => {
29
+ if ( onClose )
30
+ onClose ( )
31
+
32
+ return close ( )
33
+ }
34
+
35
+ return (
36
+ < >
37
+ { trigger }
38
+ < Popup
39
+ visible = { visible }
40
+ onClose = { handlePopupClose }
41
+ className = { classNames ( `${ defaultPrefixCls } -base-popup` , className ) }
42
+ destroyOnClose
43
+ closeOnMaskClick
44
+ onClick = { onClick }
45
+ { ...restProps }
46
+ >
47
+ { content }
48
+ </ Popup >
49
+ </ >
50
+ )
51
+ }
52
+
53
+ export default BasePopup
Original file line number Diff line number Diff line change
1
+ @import (less ) ' ~antd-mobile/es/components/popup/popup.css' ;
2
+ @import ' ../../styles/themes/default.less' ;
3
+
4
+ .@{cls-prefix} -base-popup {
5
+
6
+ }
Original file line number Diff line number Diff line change
1
+ import './index.less'
Original file line number Diff line number Diff line change 1
1
export type { ButtonProps } from './button'
2
2
export { default as Button } from './button'
3
+
4
+ export type { BasePopupProps } from './base-popup'
5
+ export { default as BasePopup } from './base-popup'
6
+
7
+ // Third-party library
8
+ export { ConditionInput } from '@template-pro/rc-ui'
9
+ export type { ConditionInputProps , ConditionInputCoverProps } from '@template-pro/rc-ui'
10
+ export type {
11
+ UseModalEnhancedAction ,
12
+ UseModalEnhancedContext ,
13
+ UseModalEnhancedProps ,
14
+ } from '@template-pro/utils'
Original file line number Diff line number Diff line change
1
+ @import ' ~antd-mobile/es/global/global.css' ;
2
+
1
3
@cls-prefix : temp- m;
You can’t perform that action at this time.
0 commit comments