2023-08-22 21:57:53 -04:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { Handle, Position } from "@xyflow/svelte";
|
2023-08-25 14:03:32 -04:00
|
|
|
import { removeNode } from "./stores.js";
|
2023-08-22 21:57:53 -04:00
|
|
|
|
2023-08-24 23:17:49 -04:00
|
|
|
export let data = { nodeType: "", name: "", inputs: [], outputs: [] };
|
|
|
|
|
export let id;
|
|
|
|
|
|
|
|
|
|
function remove() {
|
|
|
|
|
removeNode(id);
|
|
|
|
|
}
|
2023-08-22 21:57:53 -04:00
|
|
|
</script>
|
|
|
|
|
|
2023-08-24 23:17:49 -04:00
|
|
|
<div class="node {data.nodeType}">
|
|
|
|
|
<div class="head">
|
|
|
|
|
<div class="node-type">{data.nodeType}</div>
|
2023-08-25 14:03:32 -04:00
|
|
|
{#if data.nodeType != "output"}
|
|
|
|
|
<button on:click={remove}>X</button>
|
|
|
|
|
{/if}
|
2023-08-24 23:17:49 -04:00
|
|
|
</div>
|
|
|
|
|
<div class="body">
|
|
|
|
|
{#if data.nodeType == "input"}
|
|
|
|
|
<select bind:value={data.name}>
|
|
|
|
|
<option value="punch.mp4">punch.mp4</option>
|
|
|
|
|
<option value="shoe.mp4">shoe.mp4</option>
|
|
|
|
|
</select>
|
|
|
|
|
{:else}
|
|
|
|
|
{data.name}
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
2023-08-22 21:57:53 -04:00
|
|
|
</div>
|
|
|
|
|
{#each data.inputs as inp, index}
|
2023-08-24 23:17:49 -04:00
|
|
|
<Handle
|
|
|
|
|
type="target"
|
|
|
|
|
position={Position.Left}
|
|
|
|
|
id={inp + "_" + index}
|
|
|
|
|
class="handle {inp}"
|
2023-08-24 23:40:01 -04:00
|
|
|
style="top: {index * 12 + 4}px; left: -8px;">{inp}</Handle
|
2023-08-24 23:17:49 -04:00
|
|
|
>
|
2023-08-22 21:57:53 -04:00
|
|
|
{/each}
|
|
|
|
|
{#each data.outputs as out, index}
|
2023-08-24 23:17:49 -04:00
|
|
|
<Handle
|
|
|
|
|
type="source"
|
|
|
|
|
id={out + "_" + index}
|
|
|
|
|
position={Position.Right}
|
|
|
|
|
class="handle {out}"
|
2023-08-24 23:40:01 -04:00
|
|
|
style="top: {index * 12 + 4}px; right: -18px; left: auto;">{out}</Handle
|
2023-08-24 23:17:49 -04:00
|
|
|
>
|
2023-08-22 21:57:53 -04:00
|
|
|
{/each}
|
2023-08-24 23:17:49 -04:00
|
|
|
|
2023-08-23 18:10:28 -04:00
|
|
|
<style>
|
2023-08-24 23:17:49 -04:00
|
|
|
:global(:root) {
|
|
|
|
|
--edge-color: var(--b1) !important;
|
|
|
|
|
--edge-color-selected: black;
|
|
|
|
|
}
|
|
|
|
|
:global(.svelte-flow__node) {
|
|
|
|
|
box-shadow: 2px 2px 0px var(--b2);
|
|
|
|
|
}
|
|
|
|
|
:global(.svelte-flow__node.selected) {
|
|
|
|
|
outline: 1px solid var(--b1) !important;
|
|
|
|
|
}
|
|
|
|
|
:global(.handle) {
|
|
|
|
|
width: 10px !important;
|
|
|
|
|
height: 10px !important;
|
|
|
|
|
border: 1px solid var(--b1) !important;
|
|
|
|
|
border-radius: 0px !important;
|
|
|
|
|
background-color: white !important;
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
line-height: 6px;
|
|
|
|
|
}
|
|
|
|
|
:global(.handle.a) {
|
|
|
|
|
/* border: 1px solid var(--b2) !important; */
|
|
|
|
|
}
|
|
|
|
|
.node {
|
|
|
|
|
padding: 5px;
|
|
|
|
|
}
|
|
|
|
|
.head {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
margin-bottom: 5px;
|
|
|
|
|
}
|
|
|
|
|
.head button {
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
line-height: 8px;
|
|
|
|
|
padding: 2px 2px;
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
}
|
|
|
|
|
.node-type {
|
|
|
|
|
font-size: 0.8em;
|
|
|
|
|
color: #999;
|
|
|
|
|
}
|
|
|
|
|
.node.input {
|
|
|
|
|
}
|
|
|
|
|
.node.filter {
|
|
|
|
|
}
|
|
|
|
|
.node.output {
|
|
|
|
|
}
|
2023-08-23 18:10:28 -04:00
|
|
|
</style>
|