@@ -18,6 +18,9 @@ import { Font } from "../../../types/font";
1818import { Border , BorderStyle } from "../../../types/border" ;
1919import { MacroContext } from "../../../types/macros" ;
2020import { ExitFileContext , FileContext } from "../../../misc/fileContext" ;
21+ import { Button } from "@mui/material" ;
22+ import { ThemeProvider } from "@mui/material" ;
23+ import { defaultColours } from "../../../colourscheme" ;
2124
2225export interface ActionButtonProps {
2326 text : string ;
@@ -32,44 +35,6 @@ export interface ActionButtonProps {
3235 visible ?: boolean ;
3336}
3437
35- export const ActionButtonComponent = (
36- props : ActionButtonProps
37- ) : JSX . Element => {
38- const style = commonCss ( props ) ;
39- if ( props . disabled ) {
40- style [ "cursor" ] = "not-allowed" ;
41- }
42- style [ "whiteSpace" ] = "normal" ;
43- // Use default button style if no border defined.
44- if ( props . border ?. style === BorderStyle . None ) {
45- style [ "borderStyle" ] = undefined ;
46- style [ "borderWidth" ] = undefined ;
47- style [ "borderColor" ] = undefined ;
48- style [ "padding" ] = "0" ;
49- }
50- return (
51- < button
52- className = { classes . actionbutton }
53- disabled = { props . disabled }
54- onClick = { props . onClick }
55- style = { style }
56- >
57- { props . image !== undefined ? (
58- < figure className = { classes . figure } >
59- < img
60- style = { { width : "100%" , display : "block" } }
61- src = { props . image }
62- alt = { props . image }
63- > </ img >
64- < figcaption > { props . text } </ figcaption >
65- </ figure >
66- ) : (
67- < span style = { { whiteSpace : "normal" } } > { props . text || "" } </ span >
68- ) }
69- </ button >
70- ) ;
71- } ;
72-
7338const ActionButtonPropType = {
7439 text : StringPropOpt ,
7540 actions : ActionsPropType ,
@@ -104,18 +69,32 @@ export const ActionButtonWidget = (
10469 ) ;
10570 }
10671 return (
107- < ActionButtonComponent
108- text = { props . text ?? "" }
109- disabled = { props . readonly }
110- onClick = { onClick }
111- image = { props . image }
112- backgroundColor = { props . backgroundColor }
113- foregroundColor = { props . foregroundColor }
114- font = { props . font }
115- border = { props . border }
116- actions = { props . actions as WidgetActions }
117- visible = { props . visible }
118- />
72+ < ThemeProvider theme = { defaultColours } >
73+ < Button
74+ variant = "contained"
75+ sx = { {
76+ height : "100%" ,
77+ width : "100%" ,
78+ fontFamily : props . font ?. css ( ) ?? "" ,
79+ color : props . foregroundColor ?. toString ( ) ?? defaultColours . palette . primary . contrastText ,
80+ backgroundColor : props . backgroundColor ?. toString ( ) ?? defaultColours . palette . primary . main ,
81+ } }
82+ onClick = { onClick }
83+ >
84+ { props . image !== undefined ? (
85+ < figure className = { classes . figure } >
86+ < img
87+ style = { { width : "100%" , display : "block" } }
88+ src = { props . image }
89+ alt = { props . image }
90+ > </ img >
91+ < figcaption > { props . text } </ figcaption >
92+ </ figure >
93+ ) : (
94+ props . text ?? ""
95+ ) }
96+ </ Button >
97+ </ ThemeProvider >
11998 ) ;
12099} ;
121100
0 commit comments