feat: Add option to toggle connector arrows

Implements a toggle switch in the connector controls menu that allows
users to show or hide arrows on individual connectors. Arrows are
shown by default for new connectors but can be toggled off for each
connector independently.

Closes #74
This commit is contained in:
Stan
2025-08-14 11:36:20 +01:00
parent 055e2b1aa7
commit dea6a1e934
4 changed files with 22 additions and 3 deletions

View File

@@ -6,7 +6,9 @@ import {
Select,
MenuItem,
TextField,
IconButton as MUIIconButton
IconButton as MUIIconButton,
FormControlLabel,
Switch
} from '@mui/material';
import { useConnector } from 'src/hooks/useConnector';
import { ColorSelector } from 'src/components/ColorSelector/ColorSelector';
@@ -97,6 +99,21 @@ export const ConnectorControls = ({ id }: Props) => {
})}
</Select>
</Section>
<Section>
<FormControlLabel
control={
<Switch
checked={connector.showArrow !== false}
onChange={(e) => {
updateConnector(connector.id, {
showArrow: e.target.checked
});
}}
/>
}
label="Show Arrow"
/>
</Section>
<Section>
<Box>
<DeleteButton

View File

@@ -144,7 +144,7 @@ export const Connector = ({ connector: _connector, isSelected }: Props) => {
);
})}
{directionIcon && (
{directionIcon && connector.showArrow !== false && (
<g transform={`translate(${directionIcon.x}, ${directionIcon.y})`}>
<g transform={`rotate(${directionIcon.rotation})`}>
<polygon

View File

@@ -49,7 +49,8 @@ export const CONNECTOR_DEFAULTS: Required<Omit<Connector, 'id' | 'color'>> = {
width: 10,
description: '',
anchors: [],
style: 'SOLID'
style: 'SOLID',
showArrow: true
};
// The boundaries of the search area for the pathfinder algorithm

View File

@@ -20,5 +20,6 @@ export const connectorSchema = z.object({
color: id.optional(),
width: z.number().optional(),
style: z.enum(connectorStyleOptions).optional(),
showArrow: z.boolean().optional(),
anchors: z.array(anchorSchema)
});