chore(controls): add aria-label #3775
This commit is contained in:
@@ -34,6 +34,7 @@ function ControlsComponent({
|
|||||||
className,
|
className,
|
||||||
children,
|
children,
|
||||||
position = 'bottom-left',
|
position = 'bottom-left',
|
||||||
|
'aria-label': ariaLabel = 'React Flow controls',
|
||||||
}: ControlProps) {
|
}: ControlProps) {
|
||||||
const store = useStoreApi();
|
const store = useStoreApi();
|
||||||
const { isInteractive, minZoomReached, maxZoomReached } = useStore(selector, shallow);
|
const { isInteractive, minZoomReached, maxZoomReached } = useStore(selector, shallow);
|
||||||
@@ -70,6 +71,7 @@ function ControlsComponent({
|
|||||||
position={position}
|
position={position}
|
||||||
style={style}
|
style={style}
|
||||||
data-testid="rf__controls"
|
data-testid="rf__controls"
|
||||||
|
aria-label={ariaLabel}
|
||||||
>
|
>
|
||||||
{showZoom && (
|
{showZoom && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import type { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
|
import type { ButtonHTMLAttributes, ReactNode } from 'react';
|
||||||
import type { PanelPosition } from '@xyflow/system';
|
import type { PanelPosition } from '@xyflow/system';
|
||||||
|
|
||||||
import type { FitViewOptions } from '../../types';
|
import type { FitViewOptions } from '../../types';
|
||||||
|
|
||||||
export type ControlProps = HTMLAttributes<HTMLDivElement> & {
|
export type ControlProps = {
|
||||||
showZoom?: boolean;
|
showZoom?: boolean;
|
||||||
showFitView?: boolean;
|
showFitView?: boolean;
|
||||||
showInteractive?: boolean;
|
showInteractive?: boolean;
|
||||||
@@ -14,6 +14,9 @@ export type ControlProps = HTMLAttributes<HTMLDivElement> & {
|
|||||||
onInteractiveChange?: (interactiveStatus: boolean) => void;
|
onInteractiveChange?: (interactiveStatus: boolean) => void;
|
||||||
position?: PanelPosition;
|
position?: PanelPosition;
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
|
style?: React.CSSProperties;
|
||||||
|
className?: string;
|
||||||
|
'aria-label'?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ControlButtonProps = ButtonHTMLAttributes<HTMLButtonElement>;
|
export type ControlButtonProps = ButtonHTMLAttributes<HTMLButtonElement>;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
export let buttonColor: $$Props['buttonColor'] = undefined;
|
export let buttonColor: $$Props['buttonColor'] = undefined;
|
||||||
export let buttonColorHover: $$Props['buttonColorHover'] = undefined;
|
export let buttonColorHover: $$Props['buttonColorHover'] = undefined;
|
||||||
export let buttonBorderColor: $$Props['buttonColorHover'] = undefined;
|
export let buttonBorderColor: $$Props['buttonColorHover'] = undefined;
|
||||||
|
export let ariaLabel: $$Props['aria-label'] = undefined;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
zoomIn,
|
zoomIn,
|
||||||
@@ -67,7 +68,12 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Panel class="svelte-flow__controls" {position} data-testid="svelte-flow__controls">
|
<Panel
|
||||||
|
class="svelte-flow__controls"
|
||||||
|
{position}
|
||||||
|
data-testid="svelte-flow__controls"
|
||||||
|
aria-label={ariaLabel ?? 'Svelte Flow controls'}
|
||||||
|
>
|
||||||
{#if showZoom}
|
{#if showZoom}
|
||||||
<ControlButton
|
<ControlButton
|
||||||
on:click={onZoomInHandler}
|
on:click={onZoomInHandler}
|
||||||
|
|||||||
@@ -9,4 +9,5 @@ export type ControlsProps = {
|
|||||||
buttonBgColorHover?: string;
|
buttonBgColorHover?: string;
|
||||||
buttonColor?: string;
|
buttonColor?: string;
|
||||||
buttonColorHover?: string;
|
buttonColorHover?: string;
|
||||||
|
'aria-label'?: string;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user