Skip to content

Commit

Permalink
Merge pull request #304 from open-source-labs/dev
Browse files Browse the repository at this point in the history
feat: added connect and disconnect methods to Node component
  • Loading branch information
briangregoryholmes authored Apr 30, 2023
2 parents 86942c8 + 7e30eb1 commit 3612ea4
Show file tree
Hide file tree
Showing 52 changed files with 1,104 additions and 603 deletions.
27 changes: 27 additions & 0 deletions src/example-components/Connector.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script lang="ts">
import { Svelvet, Node, Anchor } from '$lib';
import { getContext } from 'svelte';
function addAndConnect(connect: (connections: string | number) => void) {
connect(totalNodes + 4);
totalNodes++;
}
let totalNodes = 0;
</script>

<Node
position={{ x: 100, y: 300 }}
dimensions={{ width: 400, height: 300 }}
let:connect
let:disconnect
useDefaults
>
<div>
<button on:click={() => connect(2)}>Connect 2</button>
<button on:click={() => addAndConnect(connect)}>Connect and Add</button>
<button on:click={() => disconnect(2)}>Disconnect Last From 2</button>
<button on:click={() => disconnect([[2, '3']])}>Disconnect Node 2/Anchor 3</button>
<button on:click={() => connect(3)}>Connect 3</button>
<button on:click={() => disconnect(3)}>Disconnect Last From 3</button>
</div>
<Anchor />
</Node>
2 changes: 1 addition & 1 deletion src/example-components/CustomControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Controls } from '$lib';
</script>

<Controls let:zoomIn let:zoomOut let:reset let:unhideAll corner="SW">
<Controls let:zoomIn let:zoomOut let:fitView let:unhideAll corner="SW">
<button on:click|stopPropagation={zoomIn}>ZOOMER</button>
<button on:click|stopPropagation={zoomOut}>UN ZOOMER</button>
</Controls>
17 changes: 17 additions & 0 deletions src/example-components/CustomEdge.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { SvelteComponentTyped } from 'svelte';
declare const __propDef: {
props: Record<string, never>;
events: {
[evt: string]: CustomEvent<any>;
};
slots: {};
};
export type CustomEdgeProps = typeof __propDef.props;
export type CustomEdgeEvents = typeof __propDef.events;
export type CustomEdgeSlots = typeof __propDef.slots;
export default class CustomEdge extends SvelteComponentTyped<
CustomEdgeProps,
CustomEdgeEvents,
CustomEdgeSlots
> {}
export {};
17 changes: 17 additions & 0 deletions src/example-components/CustomNode.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { SvelteComponentTyped } from 'svelte';
declare const __propDef: {
props: Record<string, never>;
events: {
[evt: string]: CustomEvent<any>;
};
slots: {};
};
export type CustomNodeProps = typeof __propDef.props;
export type CustomNodeEvents = typeof __propDef.events;
export type CustomNodeSlots = typeof __propDef.slots;
export default class CustomNode extends SvelteComponentTyped<
CustomNodeProps,
CustomNodeEvents,
CustomNodeSlots
> {}
export {};
17 changes: 17 additions & 0 deletions src/example-components/InputNode.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { SvelteComponentTyped } from 'svelte';
declare const __propDef: {
props: Record<string, never>;
events: {
[evt: string]: CustomEvent<any>;
};
slots: {};
};
export type InputNodeProps = typeof __propDef.props;
export type InputNodeEvents = typeof __propDef.events;
export type InputNodeSlots = typeof __propDef.slots;
export default class InputNode extends SvelteComponentTyped<
InputNodeProps,
InputNodeEvents,
InputNodeSlots
> {}
export {};
Loading

0 comments on commit 3612ea4

Please sign in to comment.