@@ -11,7 +11,8 @@ import {
11
11
ColorPropOpt ,
12
12
FontPropOpt ,
13
13
BorderPropOpt ,
14
- BoolPropOpt
14
+ BoolPropOpt ,
15
+ FuncPropOpt
15
16
} from "../propTypes" ;
16
17
import { Color } from "../../../types/color" ;
17
18
import { Font } from "../../../types/font" ;
@@ -35,6 +36,45 @@ export interface ActionButtonProps {
35
36
visible ?: boolean ;
36
37
}
37
38
39
+ export const ActionButtonComponent = (
40
+ props : ActionButtonProps
41
+ ) : JSX . Element => {
42
+ return (
43
+ < ThemeProvider theme = { defaultColours } >
44
+ < Button
45
+ variant = "contained"
46
+ disabled = { props . disabled }
47
+ sx = { {
48
+ height : "100%" ,
49
+ width : "100%" ,
50
+ fontFamily : props . font ?. css ( ) ?? "" ,
51
+ color :
52
+ props . foregroundColor ?. toString ( ) ??
53
+ defaultColours . palette . primary . contrastText ,
54
+ backgroundColor :
55
+ props . backgroundColor ?. toString ( ) ??
56
+ defaultColours . palette . primary . main ,
57
+ border : props . border ?. css ( ) ?? ""
58
+ } }
59
+ onClick = { props . onClick }
60
+ >
61
+ { props . image !== undefined ? (
62
+ < figure className = { classes . figure } >
63
+ < img
64
+ style = { { width : "100%" , display : "block" } }
65
+ src = { props . image }
66
+ alt = { props . image }
67
+ > </ img >
68
+ < figcaption > { props . text } </ figcaption >
69
+ </ figure >
70
+ ) : (
71
+ ( props . text ?? "" )
72
+ ) }
73
+ </ Button >
74
+ </ ThemeProvider >
75
+ ) ;
76
+ } ;
77
+
38
78
const ActionButtonPropType = {
39
79
text : StringPropOpt ,
40
80
actions : ActionsPropType ,
@@ -44,7 +84,8 @@ const ActionButtonPropType = {
44
84
font : FontPropOpt ,
45
85
border : BorderPropOpt ,
46
86
visible : BoolPropOpt ,
47
- disabled : BoolPropOpt
87
+ disabled : BoolPropOpt ,
88
+ onClick : FuncPropOpt
48
89
} ;
49
90
50
91
const ActionButtonWidgetProps = {
@@ -70,38 +111,18 @@ export const ActionButtonWidget = (
70
111
) ;
71
112
}
72
113
return (
73
- < ThemeProvider theme = { defaultColours } >
74
- < Button
75
- variant = "contained"
76
- disabled = { props . disabled }
77
- sx = { {
78
- height : "100%" ,
79
- width : "100%" ,
80
- fontFamily : props . font ?. css ( ) ?? "" ,
81
- color :
82
- props . foregroundColor ?. toString ( ) ??
83
- defaultColours . palette . primary . contrastText ,
84
- backgroundColor :
85
- props . backgroundColor ?. toString ( ) ??
86
- defaultColours . palette . primary . main ,
87
- border : props . border ?. css ( ) ?? ""
88
- } }
89
- onClick = { onClick }
90
- >
91
- { props . image !== undefined ? (
92
- < figure className = { classes . figure } >
93
- < img
94
- style = { { width : "100%" , display : "block" } }
95
- src = { props . image }
96
- alt = { props . image }
97
- > </ img >
98
- < figcaption > { props . text } </ figcaption >
99
- </ figure >
100
- ) : (
101
- ( props . text ?? "" )
102
- ) }
103
- </ Button >
104
- </ ThemeProvider >
114
+ < ActionButtonComponent
115
+ text = { props . text ?? "" }
116
+ disabled = { props . readonly }
117
+ onClick = { onClick }
118
+ image = { props . image }
119
+ backgroundColor = { props . backgroundColor }
120
+ foregroundColor = { props . foregroundColor }
121
+ font = { props . font }
122
+ border = { props . border }
123
+ actions = { props . actions as WidgetActions }
124
+ visible = { props . visible }
125
+ />
105
126
) ;
106
127
} ;
107
128
0 commit comments