refactor(svelte): cleanup components

This commit is contained in:
moklick
2023-03-01 11:48:08 +01:00
parent 00515e1f9b
commit 9391b36869
61 changed files with 600 additions and 196 deletions
@@ -0,0 +1,37 @@
<script lang="ts">
import { getRectOfNodes } from '@reactflow/utils';
import { useStore } from '$lib/store';
import { Selection } from '$lib/components/Selection';
import drag from '$lib/actions/drag';
const { selectionRectMode, nodes, nodeOrigin, transform, updateNodePositions } = useStore();
$: selectedNodes = $nodes.filter((n) => n.selected);
$: rect = getRectOfNodes(selectedNodes, $nodeOrigin);
</script>
{#if selectedNodes}
<div
class="selection-wrapper nopan"
style={`width: ${rect.width}px; height: ${rect.height}px; transform: translate(${rect.x}px, ${rect.y}px)`}
use:drag={{ nodes, transform, updateNodePositions }}
/>
<Selection
isVisible={$selectionRectMode === 'nodes'}
width={rect.width}
height={rect.height}
x={rect.x}
y={rect.y}
/>
{/if}
<style>
.selection-wrapper {
position: absolute;
top: 0;
left: 0;
z-index: 7;
pointer-events: all;
}
</style>