diff --git a/examples/react/src/examples/A11y/index.tsx b/examples/react/src/examples/A11y/index.tsx index 61627a8f..c837c14c 100644 --- a/examples/react/src/examples/A11y/index.tsx +++ b/examples/react/src/examples/A11y/index.tsx @@ -65,6 +65,10 @@ const A11y = () => { 'a11yDescription.node.default': 'Custom Node Desc.', 'a11yDescription.node.keyboardDisabled': 'Custom Keyboard Desc.', 'a11yDescription.edge.default': 'Custom Edge Desc.', + 'controls.zoomin.title': 'Custom Zoom in', + 'controls.zoomout.title': 'Custom Zoom Out', + 'controls.fitview.title': 'Custom Fit View', + 'controls.interactive.title': 'Custom Toggle Interactivity', }} > diff --git a/packages/react/src/additional-components/Controls/Controls.tsx b/packages/react/src/additional-components/Controls/Controls.tsx index 84337a28..1dca3548 100644 --- a/packages/react/src/additional-components/Controls/Controls.tsx +++ b/packages/react/src/additional-components/Controls/Controls.tsx @@ -19,6 +19,7 @@ const selector = (s: ReactFlowState) => ({ isInteractive: s.nodesDraggable || s.nodesConnectable || s.elementsSelectable, minZoomReached: s.transform[2] <= s.minZoom, maxZoomReached: s.transform[2] >= s.maxZoom, + labelConfig: s.labelConfig, }); function ControlsComponent({ @@ -38,7 +39,7 @@ function ControlsComponent({ 'aria-label': ariaLabel = 'React Flow controls', }: ControlProps) { const store = useStoreApi(); - const { isInteractive, minZoomReached, maxZoomReached } = useStore(selector, shallow); + const { isInteractive, minZoomReached, maxZoomReached, labelConfig } = useStore(selector, shallow); const { zoomIn, zoomOut, fitView } = useReactFlow(); const onZoomInHandler = () => { @@ -67,7 +68,6 @@ function ControlsComponent({ }; const orientationClass = orientation === 'horizontal' ? 'horizontal' : 'vertical'; - return ( @@ -90,8 +90,8 @@ function ControlsComponent({ @@ -102,8 +102,8 @@ function ControlsComponent({ @@ -112,8 +112,8 @@ function ControlsComponent({ {isInteractive ? : } diff --git a/packages/system/src/constants.ts b/packages/system/src/constants.ts index b3ff1d41..9a3259a2 100644 --- a/packages/system/src/constants.ts +++ b/packages/system/src/constants.ts @@ -44,6 +44,12 @@ export const defaultLabelConfig = { 'Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.', 'a11yDescription.edge.default': 'Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.', + + // Control elements + 'controls.zoomin.title': 'Zoom In', + 'controls.zoomout.title': 'Zoom Out', + 'controls.fitview.title': 'Fit View', + 'controls.interactive.title': 'Toggle Interactivity', }; export type LabelConfig = Partial;