diff --git a/src/ui/widgets/BoolButton/boolButton.tsx b/src/ui/widgets/BoolButton/boolButton.tsx index 39be94b9..832b5ef5 100644 --- a/src/ui/widgets/BoolButton/boolButton.tsx +++ b/src/ui/widgets/BoolButton/boolButton.tsx @@ -45,7 +45,9 @@ const BoolButtonProps = { enabled: BoolPropOpt, font: FontPropOpt, textAlign: ChoicePropOpt(["left", "center", "right"]), - textAlignV: ChoicePropOpt(["top", "center", "bottom"]) + textAlignV: ChoicePropOpt(["top", "center", "bottom"]), + onImage: StringPropOpt, + offImage: StringPropOpt }; const Button = styled(MuiButton)({ @@ -102,7 +104,9 @@ export const BoolButtonComponent = ( labelsFromPv = false, enabled = true, textAlign = "center", - textAlignV = "center" + textAlignV = "center", + onImage, + offImage } = newProps as BoolButtonComponentProps; const { value, @@ -132,6 +136,7 @@ export const BoolButtonComponent = ( const [label, setLabel] = useState(showBooleanLabel ? offLabel : ""); const doubleValue = dTypeGetDoubleValue(value); const [ledColor, setLedColor] = useState(style?.customColors?.offColor); + const [imageFileName, setImageFileName] = useState(offImage); // Establish LED style const ledDiameter = showLed ? getDimensions(size.width, size.height) : 0; @@ -143,9 +148,11 @@ export const BoolButtonComponent = ( useEffect(() => { if (doubleValue === onState) { if (showBooleanLabel) setLabel(onLabel); + setImageFileName(onImage); setLedColor(style?.customColors?.onColor); } else if (doubleValue === offState) { if (showBooleanLabel) setLabel(offLabel); + setImageFileName(offImage); setLedColor(style?.customColors?.offColor); } }, [ @@ -156,7 +163,9 @@ export const BoolButtonComponent = ( style?.customColors?.onColor, offState, offLabel, - showBooleanLabel + showBooleanLabel, + onImage, + offImage ]); function handleClick() { @@ -194,19 +203,29 @@ export const BoolButtonComponent = ( } }} startIcon={ - showLed ? ( -