diff --git a/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap b/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap
index c43a1755..d5362d2d 100644
--- a/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap
+++ b/src/ui/widgets/ActionButton/__snapshots__/actionButton.test.tsx.snap
@@ -2,7 +2,7 @@
exports[` > it matches the snapshot 1`] = `
> it matches the snapshot 1`] = `
{
"display": "block",
"lineHeight": 1,
- "transform": "rotate(0deg)",
}
}
>
diff --git a/src/ui/widgets/ActionButton/actionButton.tsx b/src/ui/widgets/ActionButton/actionButton.tsx
index 4335b5cf..175463ae 100644
--- a/src/ui/widgets/ActionButton/actionButton.tsx
+++ b/src/ui/widgets/ActionButton/actionButton.tsx
@@ -15,35 +15,38 @@ import {
FuncPropOpt,
FloatPropOpt
} from "../propTypes";
-import { Color } from "../../../types/color";
-import { Font } from "../../../types/font";
-import { Border } from "../../../types/border";
import { MacroContext } from "../../../types/macros";
import { ExitFileContext, FileContext } from "../../../misc/fileContext";
import { styled, Button as MuiButton, useTheme } from "@mui/material";
+import { WIDGET_DEFAULT_SIZES } from "../EmbeddedDisplay/bobParser";
+import { calculateRotationTransform } from "../utils";
export interface ActionButtonProps {
- text: string;
- enabled?: boolean;
onClick: (event: React.MouseEvent) => void;
- image?: string;
- backgroundColor?: Color;
- foregroundColor?: Color;
- border?: Border;
- font?: Font;
- actions?: WidgetActions;
- visible?: boolean;
- rotationStep?: number;
- transparent?: boolean;
}
+const ActionButtonPropType = {
+ text: StringPropOpt,
+ actions: ActionsPropType,
+ image: StringPropOpt,
+ backgroundColor: ColorPropOpt,
+ foregroundColor: ColorPropOpt,
+ font: FontPropOpt,
+ border: BorderPropOpt,
+ visible: BoolPropOpt,
+ enabled: BoolPropOpt,
+ onClick: FuncPropOpt,
+ transparent: BoolPropOpt,
+ rotationStep: FloatPropOpt,
+ height: FloatPropOpt,
+ width: FloatPropOpt
+};
+
const Button = styled(MuiButton)({
"&.MuiButton-root": {
display: "block",
alignItems: "center",
justifyContent: "center",
- height: "100%",
- width: "100%",
minWidth: 0,
minHeight: 0,
padding: 0,
@@ -59,14 +62,16 @@ const Button = styled(MuiButton)({
});
export const ActionButtonComponent = (
- props: ActionButtonProps
+ props: InferWidgetProps & ActionButtonProps
): JSX.Element => {
const theme = useTheme();
const {
enabled = true,
foregroundColor = theme.palette.primary.contrastText,
rotationStep = 0,
- transparent = false
+ transparent = false,
+ height = WIDGET_DEFAULT_SIZES["action_button"][1],
+ width = WIDGET_DEFAULT_SIZES["action_button"][0]
} = props;
const backgroundColor = transparent
@@ -75,16 +80,27 @@ export const ActionButtonComponent = (
const font = props.font?.css() ?? theme.typography;
const border = props.border?.css() ?? null;
+ const [inputWidth, inputHeight, transform] = calculateRotationTransform(
+ rotationStep,
+ width,
+ height
+ );
+
return (