Re-organisation of Draft and Confidential code
This commit is contained in:
1 parent
2c23c9adfc
commit
09ff4a6555
4 files changed
+603
-10
No files matched your search
@@ -0,0 +1,219 @@
|
||||
import * as React from "react";
|
||||
import {
|
||||
Button,
|
||||
makeStyles
|
||||
} from "@fluentui/react-components";
|
||||
import {
|
||||
TextAlignLeftRegular,
|
||||
TextAlignCenterRegular,
|
||||
TextAlignRightRegular,
|
||||
TextboxAlignTopRegular,
|
||||
TextboxAlignMiddleRegular,
|
||||
TextboxAlignBottomRegular
|
||||
} from "@fluentui/react-icons";
|
||||
import { useStatusContext } from "./App";
|
||||
import { useCommonStyles } from "./commonStyles";
|
||||
|
||||
const useStyles = makeStyles({
|
||||
alignmentGrid: {
|
||||
display: "grid",
|
||||
gridTemplateColumns: "repeat(3, 1fr)",
|
||||
gap: "8px",
|
||||
width: "100%"
|
||||
},
|
||||
alignButton: {
|
||||
width: "100%",
|
||||
minWidth: 0,
|
||||
padding: "8px 4px",
|
||||
"& span": {
|
||||
justifyContent: "center"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export const AlignmentButtons: React.FC = () => {
|
||||
const styles = useStyles();
|
||||
const commonStyles = useCommonStyles();
|
||||
const {
|
||||
statusMessage, setStatusMessage,
|
||||
statusType, setStatusType,
|
||||
isProcessing, setIsProcessing
|
||||
} = useStatusContext();
|
||||
|
||||
const alignLeft = async () => {
|
||||
setIsProcessing(true);
|
||||
try {
|
||||
await PowerPoint.run(async (context) => {
|
||||
const shapes = context.presentation.getSelectedShapes();
|
||||
// Implementation will go here
|
||||
setStatusMessage("Objects aligned to left.");
|
||||
setStatusType("success");
|
||||
});
|
||||
} catch (error) {
|
||||
setStatusMessage(`Error: ${error.message}`);
|
||||
setStatusType("error");
|
||||
console.error("Align left error:", error);
|
||||
} finally {
|
||||
setIsProcessing(false);
|
||||
}
|
||||
};
|
||||
|
||||
const alignCenter = async () => {
|
||||
setIsProcessing(true);
|
||||
try {
|
||||
await PowerPoint.run(async (context) => {
|
||||
const shapes = context.presentation.getSelectedShapes();
|
||||
// Implementation will go here
|
||||
setStatusMessage("Objects aligned to center.");
|
||||
setStatusType("success");
|
||||
});
|
||||
} catch (error) {
|
||||
setStatusMessage(`Error: ${error.message}`);
|
||||
setStatusType("error");
|
||||
console.error("Align center error:", error);
|
||||
} finally {
|
||||
setIsProcessing(false);
|
||||
}
|
||||
};
|
||||
|
||||
const alignRight = async () => {
|
||||
setIsProcessing(true);
|
||||
try {
|
||||
await PowerPoint.run(async (context) => {
|
||||
const shapes = context.presentation.getSelectedShapes();
|
||||
// Implementation will go here
|
||||
setStatusMessage("Objects aligned to right.");
|
||||
setStatusType("success");
|
||||
});
|
||||
} catch (error) {
|
||||
setStatusMessage(`Error: ${error.message}`);
|
||||
setStatusType("error");
|
||||
console.error("Align right error:", error);
|
||||
} finally {
|
||||
setIsProcessing(false);
|
||||
}
|
||||
};
|
||||
|
||||
const alignTop = async () => {
|
||||
setIsProcessing(true);
|
||||
try {
|
||||
await PowerPoint.run(async (context) => {
|
||||
const shapes = context.presentation.getSelectedShapes();
|
||||
// Implementation will go here
|
||||
setStatusMessage("Objects aligned to top.");
|
||||
setStatusType("success");
|
||||
});
|
||||
} catch (error) {
|
||||
setStatusMessage(`Error: ${error.message}`);
|
||||
setStatusType("error");
|
||||
console.error("Align top error:", error);
|
||||
} finally {
|
||||
setIsProcessing(false);
|
||||
}
|
||||
};
|
||||
|
||||
const alignMiddle = async () => {
|
||||
setIsProcessing(true);
|
||||
try {
|
||||
await PowerPoint.run(async (context) => {
|
||||
const shapes = context.presentation.getSelectedShapes();
|
||||
// Implementation will go here
|
||||
setStatusMessage("Objects aligned to middle.");
|
||||
setStatusType("success");
|
||||
});
|
||||
} catch (error) {
|
||||
setStatusMessage(`Error: ${error.message}`);
|
||||
setStatusType("error");
|
||||
console.error("Align middle error:", error);
|
||||
} finally {
|
||||
setIsProcessing(false);
|
||||
}
|
||||
};
|
||||
|
||||
const alignBottom = async () => {
|
||||
setIsProcessing(true);
|
||||
try {
|
||||
await PowerPoint.run(async (context) => {
|
||||
const shapes = context.presentation.getSelectedShapes();
|
||||
// Implementation will go here
|
||||
setStatusMessage("Objects aligned to bottom.");
|
||||
setStatusType("success");
|
||||
});
|
||||
} catch (error) {
|
||||
setStatusMessage(`Error: ${error.message}`);
|
||||
setStatusType("error");
|
||||
console.error("Align bottom error:", error);
|
||||
} finally {
|
||||
setIsProcessing(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={commonStyles.container}>
|
||||
<div className={styles.alignmentGrid}>
|
||||
<Button
|
||||
appearance="primary"
|
||||
className={styles.alignButton}
|
||||
onClick={alignLeft}
|
||||
icon={<TextAlignLeftRegular />}
|
||||
disabled={isProcessing}
|
||||
title="Align Left"
|
||||
>
|
||||
Left
|
||||
</Button>
|
||||
<Button
|
||||
appearance="primary"
|
||||
className={styles.alignButton}
|
||||
onClick={alignCenter}
|
||||
icon={<TextAlignCenterRegular />}
|
||||
disabled={isProcessing}
|
||||
title="Align Center"
|
||||
>
|
||||
Center
|
||||
</Button>
|
||||
<Button
|
||||
appearance="primary"
|
||||
className={styles.alignButton}
|
||||
onClick={alignRight}
|
||||
icon={<TextAlignRightRegular />}
|
||||
disabled={isProcessing}
|
||||
title="Align Right"
|
||||
>
|
||||
Right
|
||||
</Button>
|
||||
<Button
|
||||
appearance="primary"
|
||||
className={styles.alignButton}
|
||||
onClick={alignTop}
|
||||
icon={<TextboxAlignTopRegular />}
|
||||
disabled={isProcessing}
|
||||
title="Align Top"
|
||||
>
|
||||
Top
|
||||
</Button>
|
||||
<Button
|
||||
appearance="primary"
|
||||
className={styles.alignButton}
|
||||
onClick={alignMiddle}
|
||||
icon={<TextboxAlignMiddleRegular />}
|
||||
disabled={isProcessing}
|
||||
title="Align Middle"
|
||||
>
|
||||
Middle
|
||||
</Button>
|
||||
<Button
|
||||
appearance="primary"
|
||||
className={styles.alignButton}
|
||||
onClick={alignBottom}
|
||||
icon={<TextboxAlignBottomRegular />}
|
||||
disabled={isProcessing}
|
||||
title="Align Bottom"
|
||||
>
|
||||
Bottom
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default AlignmentButtons;
|
||||
Reference in new issue
Block a user