chore(a11y): pass LabelConfig values through store SvelteFlow

This commit is contained in:
Abbey Yacoe
2025-05-21 14:03:50 +02:00
parent 54fc3c0717
commit 91ecfe73cc
9 changed files with 58 additions and 31 deletions
@@ -3,6 +3,7 @@
import { page } from '$app/stores';
const routes = [
'a11y',
'add-node-on-drop',
'color-mode',
'custom-connection-line',
@@ -0,0 +1,40 @@
<script lang="ts">
import {
SvelteFlow,
Controls,
Background,
MiniMap,
} from '@xyflow/svelte';
import '@xyflow/svelte/dist/style.css';
let nodes = $state.raw([
{
id: 'A',
position: { x: 0, y: 0 },
data: { label: 'A' },
},
{ id: 'B', position: { x: -100, y: 150 }, data: { label: 'B' } },
{ id: 'C', position: { x: 100, y: 150 }, data: { label: 'C' } },
{ id: 'D', position: { x: 0, y: 260 }, data: { label: 'D' } }
]);
let edges = $state.raw([
{ id: 'A-B', source: 'A', target: 'B' },
{ id: 'A-C', source: 'A', target: 'C' },
{ id: 'A-D', source: 'A', target: 'D' }
]);
</script>
<SvelteFlow bind:nodes bind:edges fitView labelConfig={{
'a11yDescription.node.default': 'Svelte Custom node description',
'a11yDescription.node.keyboardDisabled': 'Svelte Custom keyboard-disabled node description',
'a11yDescription.edge.default': 'Svelte Custom edge description',
}}>
<Controls />
<Background />
<MiniMap />
</SvelteFlow>
@@ -220,11 +220,6 @@
console.log('on selection changed via prop', { nodes, edges });
}}
selectNodesOnDrag
labelConfig={{
'a11yDescription.node.default': 'Svelte Custom Node Description.',
'a11yDescription.node.keyboardDisabled': 'Svelte Custom Keyboard Description',
'a11yDescription.edge.default': 'Svelte Custom Edge Desc.',
}}
>
<Controls orientation="horizontal" {fitViewOptions}>
{#snippet before()}