chore(a11y): add custom control labels Svelte

This commit is contained in:
Abbey Yacoe
2025-05-21 16:56:35 +02:00
parent 3858d3b08b
commit 6081f687bf
2 changed files with 23 additions and 13 deletions
@@ -29,11 +29,20 @@
</script> </script>
<SvelteFlow bind:nodes bind:edges fitView labelConfig={{ <SvelteFlow
'a11yDescription.node.default': 'Svelte Custom node description', bind:nodes
'a11yDescription.node.keyboardDisabled': 'Svelte Custom keyboard-disabled node description', bind:edges
'a11yDescription.edge.default': 'Svelte Custom edge description', fitView
}}> labelConfig={{
'a11yDescription.node.default': 'Svelte Custom Node Desc.',
'a11yDescription.node.keyboardDisabled': 'Svelte Custom Keyboard Desc.',
'a11yDescription.edge.default': 'Svelte Custom Edge Desc.',
'controls.zoomin.title': 'Svelte Custom Zoom in',
'controls.zoomout.title': 'Svelte Custom Zoom Out',
'controls.fitview.title': 'Svelte Custom Fit View',
'controls.interactive.title': 'Svelte Custom Toggle Interactivity',
}}
>
<Controls /> <Controls />
<Background /> <Background />
<MiniMap /> <MiniMap />
@@ -46,6 +46,7 @@
); );
let minZoomReached = $derived(store.viewport.zoom <= store.minZoom); let minZoomReached = $derived(store.viewport.zoom <= store.minZoom);
let maxZoomReached = $derived(store.viewport.zoom >= store.maxZoom); let maxZoomReached = $derived(store.viewport.zoom >= store.maxZoom);
let labelConfig = $derived(store.labelConfig);
let orientationClass = $derived(orientation === 'horizontal' ? 'horizontal' : 'vertical'); let orientationClass = $derived(orientation === 'horizontal' ? 'horizontal' : 'vertical');
const onZoomInHandler = () => { const onZoomInHandler = () => {
@@ -83,8 +84,8 @@
<ControlButton <ControlButton
onclick={onZoomInHandler} onclick={onZoomInHandler}
class="svelte-flow__controls-zoomin" class="svelte-flow__controls-zoomin"
title="zoom in" title={labelConfig['controls.zoomin.title']}
aria-label="zoom in" aria-label={labelConfig['controls.zoomin.title']}
disabled={maxZoomReached} disabled={maxZoomReached}
{...buttonProps} {...buttonProps}
> >
@@ -93,8 +94,8 @@
<ControlButton <ControlButton
onclick={onZoomOutHandler} onclick={onZoomOutHandler}
class="svelte-flow__controls-zoomout" class="svelte-flow__controls-zoomout"
title="zoom out" title={labelConfig['controls.zoomout.title']}
aria-label="zoom out" aria-label={labelConfig['controls.zoomout.title']}
disabled={minZoomReached} disabled={minZoomReached}
{...buttonProps} {...buttonProps}
> >
@@ -105,8 +106,8 @@
<ControlButton <ControlButton
class="svelte-flow__controls-fitview" class="svelte-flow__controls-fitview"
onclick={onFitViewHandler} onclick={onFitViewHandler}
title="fit view" title={labelConfig['controls.fitview.title']}
aria-label="fit view" aria-label={labelConfig['controls.fitview.title']}
{...buttonProps} {...buttonProps}
> >
<FitViewIcon /> <FitViewIcon />
@@ -116,8 +117,8 @@
<ControlButton <ControlButton
class="svelte-flow__controls-interactive" class="svelte-flow__controls-interactive"
onclick={onToggleInteractivity} onclick={onToggleInteractivity}
title="toggle interactivity" title={labelConfig['controls.interactive.title']}
aria-label="toggle interactivity" aria-label={labelConfig['controls.interactive.title']}
{...buttonProps} {...buttonProps}
> >
{#if isInteractive}<UnlockIcon />{:else}<LockIcon />{/if} {#if isInteractive}<UnlockIcon />{:else}<LockIcon />{/if}