Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 31 additions & 19 deletions src/blueapi/BlueapiComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { parseInstrumentSession, readVisitFromPv } from "./visit";
type SeverityLevel = "success" | "info" | "warning" | "error";
type VariantChoice = "outlined" | "contained";
type ButtonSize = "small" | "medium" | "large";
type ButtonColor = "primary" | "secondary" | "custom";

type RunPlanButtonProps = {
btnLabel: string;
Expand All @@ -21,20 +22,20 @@ type RunPlanButtonProps = {
title?: string;
btnVariant?: VariantChoice;
btnSize?: ButtonSize;
btnColor?: ButtonColor;
disabled?: boolean;
sx?: object;
tooltipSx?: object;
typographySx?: object;
};

// @{todo} Ideally we should be able to set up the stylings for
// a custom button in the proper way by doing something like:
// const CustomRunButton = styled(Button)({
// width: "100%",
// height: "85%",
// color: "var(--color)",
// backgroundColor: "var(--backgroundColor)",
// padding: "var(--padding)",
// margin: "var(--margin)",
// });
// This will be another PR
// See https://github.com/DiamondLightSource/mx-daq-ui/issues/71
const buttonStyles = {
color: "white",
padding: "12px",
backgroundColor: "#1c2025",
width: "90%",
height: "85%",
};

export function RunPlanButton(props: RunPlanButtonProps) {
const [openSnackbar, setOpenSnackbar] = React.useState<boolean>(false);
Expand All @@ -47,6 +48,10 @@ export function RunPlanButton(props: RunPlanButtonProps) {
const params = props.planParams ? props.planParams : {};
const variant = props.btnVariant ? props.btnVariant : "outlined";
const size = props.btnSize ? props.btnSize : "medium";
const color = props.btnColor ? props.btnColor : "primary";
const disabled = props.disabled ? props.disabled : false;
const sx = props.sx ? { ...buttonStyles, ...props.sx } : buttonStyles; // Style for the button component which is the most likely to be customised
const tooltipSx = props.tooltipSx ? props.tooltipSx : {};

const handleClick = () => {
setOpenSnackbar(true);
Expand Down Expand Up @@ -85,18 +90,25 @@ export function RunPlanButton(props: RunPlanButtonProps) {

return (
<div>
<Tooltip title={props.title ? props.title : ""} placement="bottom">
<Tooltip
title={props.title ? props.title : ""}
placement="bottom"
slotProps={{
tooltip: {
sx: tooltipSx,
},
}}
arrow
>
<Button
variant={variant}
color="custom"
color={color}
size={size}
disabled={disabled}
onClick={handleClick}
sx={sx}
>
<Typography
variant="button"
fontWeight="fontWeightBold"
sx={{ display: "block" }}
>
<Typography variant="button" fontWeight="fontWeightBold">
{props.btnLabel}
</Typography>
</Button>
Expand Down
25 changes: 9 additions & 16 deletions src/screens/OavMover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ import oxfordChipDiagram from "../assets/Oxford Chip Diagram.excalidraw.svg";
import { RunPlanButton } from "../blueapi/BlueapiComponents";
import { parseInstrumentSession, readVisitFromPv } from "../blueapi/visit";

const buttonStyle = {
color: "white",
margin: "5px",
padding: "15px",
backgroundColor: "#1c2025",
};

function BacklightControl(props: PvDescription) {
const theme = useTheme();
return (
Expand Down Expand Up @@ -241,7 +234,15 @@ export function PresetPositionsSideDrawer() {

return (
<>
<Button style={buttonStyle} onClick={toggleDrawer(true)}>
<Button
style={{
color: "white",
margin: "5px",
padding: "15px",
backgroundColor: "#1c2025",
}}
onClick={toggleDrawer(true)}
>
Preset Positions
</Button>
<Drawer open={open} onClose={toggleDrawer(false)}>
Expand All @@ -261,14 +262,6 @@ export function CoordinateSystem() {
setOpen(false);
};

// const buttonStyle = {
// color: "white",
// padding: "12px",
// backgroundColor: "#1c2025",
// width: "100%",
// height: "85%",
// };

return (
<>
<Box>
Expand Down