Rework task pane UI and document design guidelines
- Add a header, a shared accordion, a docked status region, and token-based styles - Use the blue primary style for every action button and collapse all sections by default - Improve labels, selection hints, destructive confirmations, grid semantics, and narrow-pane layout - Add docs/UI_GUIDELINES.md and update the README, user guide, and developer guide
This commit is contained in:
1 parent
89989c04e9
commit
e223dc61c8
23 files changed
+719
-549
No files matched your search
@@ -6,11 +6,16 @@
|
||||
*/
|
||||
|
||||
import * as React from "react";
|
||||
import {
|
||||
Button,
|
||||
makeStyles
|
||||
import {
|
||||
makeStyles,
|
||||
Text,
|
||||
tokens,
|
||||
Toolbar,
|
||||
ToolbarButton,
|
||||
ToolbarDivider,
|
||||
Tooltip
|
||||
} from "@fluentui/react-components";
|
||||
import {
|
||||
import {
|
||||
TextAlignLeftRegular,
|
||||
TextAlignCenterRegular,
|
||||
TextAlignRightRegular,
|
||||
@@ -39,42 +44,57 @@ type VerticalAlignmentType = 'top' | 'middle' | 'bottom';
|
||||
* Component-specific styles
|
||||
*/
|
||||
const useStyles = makeStyles({
|
||||
alignmentGrid: {
|
||||
display: "grid",
|
||||
gridTemplateColumns: "repeat(3, 1fr)",
|
||||
gap: "8px",
|
||||
width: "100%"
|
||||
},
|
||||
alignButton: {
|
||||
toolbar: {
|
||||
width: "100%",
|
||||
minWidth: 0,
|
||||
padding: "8px 4px",
|
||||
"& span": {
|
||||
justifyContent: "center"
|
||||
}
|
||||
flexWrap: "wrap",
|
||||
gap: tokens.spacingHorizontalXS,
|
||||
padding: 0,
|
||||
backgroundColor: "transparent"
|
||||
}
|
||||
});
|
||||
|
||||
interface AlignButtonProps {
|
||||
label: string;
|
||||
icon: React.ReactElement;
|
||||
disabled: boolean;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Icon-only alignment button with a tooltip that doubles as its accessible name.
|
||||
*/
|
||||
const AlignButton: React.FC<AlignButtonProps> = ({ label, icon, disabled, onClick }) => (
|
||||
<Tooltip content={label} relationship="description">
|
||||
<ToolbarButton
|
||||
appearance="primary"
|
||||
aria-label={label}
|
||||
icon={icon}
|
||||
disabled={disabled}
|
||||
onClick={onClick}
|
||||
/>
|
||||
</Tooltip>
|
||||
);
|
||||
|
||||
/**
|
||||
* AlignmentButtons component provides UI and functionality to align
|
||||
* selected shapes in PowerPoint presentations.
|
||||
*
|
||||
*
|
||||
* @returns React component
|
||||
*/
|
||||
export const AlignmentButtons: React.FC = () => {
|
||||
const styles = useStyles();
|
||||
const commonStyles = useCommonStyles();
|
||||
const { slideSize } = useSettings();
|
||||
const {
|
||||
const {
|
||||
setStatusMessage,
|
||||
setStatusType,
|
||||
isProcessing,
|
||||
isProcessing,
|
||||
setIsProcessing
|
||||
} = useStatusContext();
|
||||
|
||||
/**
|
||||
* Handles errors and updates the status message
|
||||
*
|
||||
*
|
||||
* @param error - The error object
|
||||
* @param operation - The operation being performed (for logging)
|
||||
*/
|
||||
@@ -86,7 +106,7 @@ export const AlignmentButtons: React.FC = () => {
|
||||
|
||||
/**
|
||||
* Generic function to handle horizontal alignment of shapes
|
||||
*
|
||||
*
|
||||
* @param alignmentType - The type of horizontal alignment to apply
|
||||
*/
|
||||
const handleHorizontalAlignment = async (alignmentType: HorizontalAlignmentType): Promise<void> => {
|
||||
@@ -142,7 +162,7 @@ export const AlignmentButtons: React.FC = () => {
|
||||
|
||||
/**
|
||||
* Generic function to handle vertical alignment of shapes
|
||||
*
|
||||
*
|
||||
* @param alignmentType - The type of vertical alignment to apply
|
||||
*/
|
||||
const handleVerticalAlignment = async (alignmentType: VerticalAlignmentType): Promise<void> => {
|
||||
@@ -240,68 +260,48 @@ export const AlignmentButtons: React.FC = () => {
|
||||
|
||||
return (
|
||||
<div className={commonStyles.container}>
|
||||
<div className={styles.alignmentGrid}>
|
||||
<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>
|
||||
<Button
|
||||
appearance="primary"
|
||||
className={styles.alignButton}
|
||||
onClick={alignLeft}
|
||||
<Text size={200} className={commonStyles.hint}>
|
||||
Select objects on the slide, then align them to the slide edges or center.
|
||||
</Text>
|
||||
<Toolbar aria-label="Align selected objects" className={styles.toolbar}>
|
||||
<AlignButton
|
||||
label="Align left"
|
||||
icon={<TextAlignLeftRegular />}
|
||||
disabled={isProcessing}
|
||||
title="Align Left"
|
||||
>
|
||||
Left
|
||||
</Button>
|
||||
<Button
|
||||
appearance="primary"
|
||||
className={styles.alignButton}
|
||||
onClick={alignCenter}
|
||||
onClick={alignLeft}
|
||||
/>
|
||||
<AlignButton
|
||||
label="Align center"
|
||||
icon={<TextAlignCenterRegular />}
|
||||
disabled={isProcessing}
|
||||
title="Align Center"
|
||||
>
|
||||
Center
|
||||
</Button>
|
||||
<Button
|
||||
appearance="primary"
|
||||
className={styles.alignButton}
|
||||
onClick={alignRight}
|
||||
onClick={alignCenter}
|
||||
/>
|
||||
<AlignButton
|
||||
label="Align right"
|
||||
icon={<TextAlignRightRegular />}
|
||||
disabled={isProcessing}
|
||||
title="Align Right"
|
||||
>
|
||||
Right
|
||||
</Button>
|
||||
</div>
|
||||
onClick={alignRight}
|
||||
/>
|
||||
<ToolbarDivider />
|
||||
<AlignButton
|
||||
label="Align top"
|
||||
icon={<TextboxAlignTopRegular />}
|
||||
disabled={isProcessing}
|
||||
onClick={alignTop}
|
||||
/>
|
||||
<AlignButton
|
||||
label="Align middle"
|
||||
icon={<TextboxAlignMiddleRegular />}
|
||||
disabled={isProcessing}
|
||||
onClick={alignMiddle}
|
||||
/>
|
||||
<AlignButton
|
||||
label="Align bottom"
|
||||
icon={<TextboxAlignBottomRegular />}
|
||||
disabled={isProcessing}
|
||||
onClick={alignBottom}
|
||||
/>
|
||||
</Toolbar>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user