-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description - Upgrade `svelvet` to v8(using new `Anchor`, `Edge` and `Node` components) - Maintain Node positions, so running workflow one after workflow two will no long cause the Nodes to jump up to the first row ## Link to issue #337 ## Type of change - [x] Bug fix (non-breaking change that fixes an issue) - [x] Refactor (non-breaking change that updates existing functionality) ## Test plan (required) 1. Run `cargo run -- start -c config/settings.toml` from `homestar/examples/websocket-relay` 2. Run `npm run dev` from `homestar/examples/websocket-relay/relay-app` 3. Visit http://localhost:5173/ 4. Run workflow one and expect the Nodes and edges to appear mostly as they did before(black edges with arrows and labels describing the associated tasks) 5. Run workflow two and expect the grayscale Node to appear in the bottom row with an edge connected to its north side 6. Refresh the page 7. Run workflow two and expect the Nodes, Edges and labels to appear correctly in the bottom row 8. Run workflow one and expect the Nodes that have already been executed to stay in the bottom row, but also have the blurred Node rendered in the top row with an Edge connected to it ## Screenshots/Screencaps https://www.loom.com/share/acc35d252e8b4d5a94a6f0d53aecfa91?sid=54cdb36b-1837-4082-b759-f8e80f36503e --------- Co-authored-by: Brian Ginsburg <[email protected]>
- Loading branch information
Showing
11 changed files
with
445 additions
and
1,263 deletions.
There are no files selected for viewing
1,364 changes: 175 additions & 1,189 deletions
1,364
examples/websocket-relay/relay-app/package-lock.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
examples/websocket-relay/relay-app/src/components/node/Anchor.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<script lang="ts"> | ||
import { Anchor, type Connections, type Direction } from "svelvet"; | ||
import Edge from "./Edge.svelte"; | ||
export let connections: Connections | null = null | ||
export let direction: Direction | ||
export let edgeLabel: string | null = null | ||
export let id: string | ||
</script> | ||
|
||
<Anchor | ||
{direction} | ||
dynamic | ||
{...(connections ? { connections }: {})} | ||
{...(edgeLabel ? { edgeLabel }: {})} | ||
{id} | ||
invisible | ||
multiple | ||
> | ||
<Edge slot="edge" /> | ||
</Anchor> |
33 changes: 33 additions & 0 deletions
33
examples/websocket-relay/relay-app/src/components/node/Edge.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<script lang="ts"> | ||
import { Edge } from "svelvet"; | ||
export let arrowDirection: string = 'left' | ||
</script> | ||
|
||
<Edge let:path labelColor="white"> | ||
<defs> | ||
<marker | ||
id="arrow" | ||
viewBox="0 0 10 10" | ||
refX="11" | ||
refY="5" | ||
markerWidth="6" | ||
markerHeight="6" | ||
orient="auto-start-reverse" | ||
fill="#000000" | ||
> | ||
<path d="M 0 0 L 10 5 L 0 10 z" /> | ||
</marker> | ||
</defs> | ||
<path | ||
d={path} | ||
{...(arrowDirection === 'right' ? { 'marker-end': "url(#arrow)" } : { 'marker-start': "url(#arrow)" })} | ||
/> | ||
</Edge> | ||
|
||
<style> | ||
path { | ||
stroke: #000000; | ||
stroke-width: 2px; | ||
} | ||
</style> |
116 changes: 116 additions & 0 deletions
116
examples/websocket-relay/relay-app/src/components/node/Node.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<script lang="ts"> | ||
import { Node } from "svelvet"; | ||
import type { CSSColorString } from "svelvet"; | ||
import { base64CatStore, edgeStore } from "../../stores"; | ||
import type { Position } from "$lib/node"; | ||
import type { Task } from "$lib/task"; | ||
import Anchor from "./Anchor.svelte"; | ||
export let base64Cat: string = $base64CatStore; | ||
export let bgColor: CSSColorString = "white"; | ||
export let borderColor: CSSColorString = "transparent"; | ||
export let dimensions = { | ||
height: 150, | ||
width: 150, | ||
}; | ||
export let label = "Default Node"; | ||
export let tempcat = false; | ||
export let id: string; | ||
export let position: Position; | ||
export let task: Task | null = null; | ||
const matchingEdge = $edgeStore.find((edge) => edge?.target === id) | ||
</script> | ||
|
||
<Node | ||
{id} | ||
{...dimensions} | ||
{bgColor} | ||
{borderColor} | ||
{label} | ||
{position} | ||
> | ||
<div class="relative w-full h-full"> | ||
{#if task === null} | ||
{#if !tempcat} | ||
<img | ||
src={`data:image/png;base64,${base64Cat}`} | ||
draggable="false" | ||
alt="A cat in space chilling on a synth." | ||
/> | ||
<Anchor | ||
id="1-east" | ||
direction="east" | ||
/> | ||
{:else} | ||
<img | ||
src={`data:image/png;base64,${base64Cat}`} | ||
draggable="false" | ||
alt="A cat in space chilling on a synth." | ||
/> | ||
<Anchor | ||
id="1-east" | ||
direction="east" | ||
/> | ||
{/if} | ||
{:else if task.status === "replayed"} | ||
<img | ||
src={`data:image/png;base64,${task.receipt?.out[1]}`} | ||
draggable="false" | ||
style="filter: opacity(75%)" | ||
alt={`A cat image after a ${task.operation} performed by Homestar. The operation was replayed.`} | ||
/> | ||
{#if matchingEdge} | ||
<!-- If difference between `target` and `source` is greater than 1, we're breaking to a new row, so we'll use north/south directions --> | ||
{#if (matchingEdge.target - matchingEdge.source) > 1} | ||
<Anchor | ||
id={`${id}-north`} | ||
direction="north" | ||
connections={[[`${matchingEdge.source}`, `${matchingEdge.source}-south`]]} | ||
edgeLabel={matchingEdge.label} | ||
/> | ||
{:else} | ||
<Anchor | ||
id={`${id}-west`} | ||
direction="west" | ||
connections={[[`${matchingEdge.source}`, `${matchingEdge.source}-east`]]} | ||
edgeLabel={matchingEdge.label} | ||
/> | ||
{/if} | ||
{/if} | ||
{:else} | ||
<img | ||
src={`data:image/png;base64,${task.receipt?.out[1]}`} | ||
draggable="false" | ||
alt={`A cat image after a ${task.operation} performed by Homestar`} | ||
/> | ||
{#if matchingEdge} | ||
<!-- If difference between `target` and `source` is greater than 1, we're breaking to a new row, so we'll use north/south directions --> | ||
{#if (matchingEdge.target - matchingEdge.source) > 1} | ||
<Anchor | ||
id={`${id}-north`} | ||
direction="north" | ||
connections={[[`${matchingEdge.source}`, `${matchingEdge.source}-south`]]} | ||
edgeLabel={matchingEdge.label} | ||
/> | ||
{:else} | ||
<Anchor | ||
id={`${id}-west`} | ||
direction="west" | ||
connections={[[`${matchingEdge.source}`, `${matchingEdge.source}-east`]]} | ||
edgeLabel={matchingEdge.label} | ||
/> | ||
{/if} | ||
{/if} | ||
{/if} | ||
<Anchor | ||
id={`${id}-east`} | ||
direction="east" | ||
/> | ||
<Anchor | ||
id={`${id}-south`} | ||
direction="south" | ||
/> | ||
</div> | ||
</Node> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export type Position = { | ||
x: number; | ||
y: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.