Vašek Šraier
4 years ago
4 changed files with 60 additions and 42 deletions
@ -0,0 +1,17 @@ |
|||
<script lang="ts"> |
|||
import type { SimulationLinkDatum } from "d3"; |
|||
|
|||
import { onMount } from "svelte"; |
|||
|
|||
import type { TaskDescriptor } from "./task-loader"; |
|||
|
|||
export let edge: SimulationLinkDatum<TaskDescriptor>; |
|||
|
|||
$: x1 = edge === undefined || edge.source === undefined || edge.source.x === undefined ? 0 : edge.source.x; |
|||
$: y1 = edge === undefined || edge.source === undefined || edge.source.y === undefined ? 0 : edge.source.y; |
|||
$: x2 = edge === undefined || edge.target === undefined || edge.target.x === undefined ? 0 : edge.target.x; |
|||
$: y2 = edge === undefined || edge.target === undefined || edge.target.y === undefined ? 0 : edge.target.y; |
|||
</script> |
|||
|
|||
<line {x1} {x2} {y1} {y2} style="stroke: #aaa" /> |
|||
|
@ -1,18 +1,44 @@ |
|||
<script lang="ts"> |
|||
import { onMount } from "svelte"; |
|||
|
|||
import type { TaskDescriptor } from "./task-loader"; |
|||
import Hoverable from "./Hoverable.svelte"; |
|||
|
|||
export let task: TaskDescriptor; |
|||
let hovering: boolean = false; |
|||
let text_element: SVGTextElement; |
|||
|
|||
$: cx = task === undefined || task.x === undefined ? 0 : task.x; |
|||
$: cy = task === undefined || task.y === undefined ? 0 : task.y; |
|||
|
|||
function enter() { |
|||
hovering = true; |
|||
} |
|||
|
|||
function leave() { |
|||
hovering = false; |
|||
} |
|||
|
|||
$: cx = task === undefined || task.x === undefined ? 0 : task.x + 6; |
|||
$: cy = task === undefined || task.y === undefined ? 0 : task.y - 6; |
|||
let ellipse_rx = 20; |
|||
let ellipse_ry = 20; |
|||
onMount(() => { |
|||
const bbox = text_element.getBBox(); |
|||
ellipse_rx = bbox.width / 2 + 8; |
|||
ellipse_ry = bbox.height / 2 + 8; |
|||
}); |
|||
</script> |
|||
|
|||
<Hoverable let:hovering={focused}> |
|||
{#if !focused} |
|||
<circle r="20" style="fill: #69b3a2" {cx} {cy} /> |
|||
<g on:mouseenter={enter} on:mouseleave={leave}> |
|||
{#if !hovering} |
|||
<ellipse rx={ellipse_rx} ry={ellipse_ry} style="fill: #69b3a2" {cx} {cy} /> |
|||
{:else} |
|||
<circle r="20" style="fill: #ffb3a2" {cx} {cy} /> |
|||
{/if} --> |
|||
<text x={cx} y={cy}>{task.id}</text> |
|||
</Hoverable> |
|||
<ellipse rx={ellipse_rx} ry={ellipse_ry} style="fill: #ffb3a2" {cx} {cy} /> |
|||
{/if} |
|||
<text |
|||
bind:this={text_element} |
|||
x={cx} |
|||
y={cy + 5} |
|||
text-anchor="middle" |
|||
alignment-baseline="middle"> |
|||
{task.id} |
|||
</text> |
|||
</g> |
|||
|
Reference in new issue