-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Canvas #267
Canvas #267
Conversation
Xenon27
commented
Feb 4, 2025
•
edited by AbdelazizTina-dev
Loading
edited by AbdelazizTina-dev

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next steps will be to make your code dynamic : a lot is hard coded.
packages/plugins/io-center/src/ui/components/canvas/canvas.svelte
Outdated
Show resolved
Hide resolved
connections = [ | ||
{ | ||
from: { node: 'DO X', side: 'right' }, | ||
to: { node: 'Logical Component X', side: 'left' } | ||
}, | ||
{ | ||
from: { node: 'DO Y', side: 'right' }, | ||
to: { node: 'Logical Component X', side: 'left' } | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this default state can be passed as initialization of the $state variable like this :
let connections = $state<Connection[]>([
{
from: { node: 'DO X', side: 'right' },
to: { node: 'Logical Component X', side: 'left' }
},
{
from: { node: 'DO Y', side: 'right' },
to: { node: 'Logical Component X', side: 'left' }
}
])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is intended to be dynamic in the future, you'll be able to initialize it in an action and a centralized store (like I did here to init a plugin). I can show you how if you are interested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, this should be dynamic. Currently, I implemented it this way because I don't yet receive data from the SCD, and I needed an initial reactive action to trigger the drawing. However, a function or action will likely be needed to initialize the default view, ensuring that something is always displayed immediately.
packages/plugins/io-center/src/ui/components/canvas/canvas.svelte
Outdated
Show resolved
Hide resolved
packages/plugins/io-center/src/ui/components/canvas/canvas.svelte
Outdated
Show resolved
Hide resolved
packages/plugins/io-center/src/ui/components/canvas/canvas.svelte
Outdated
Show resolved
Hide resolved
packages/plugins/io-center/src/ui/components/canvas/canvas.svelte
Outdated
Show resolved
Hide resolved
@@ -26,16 +26,6 @@ | |||
|
|||
onMount(() => { | |||
window.addEventListener("resize", redrawConnections); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it probably does not belong to this PR but we shouldn't add event listeners manually.
in this case we should use: https://svelte.dev/docs/svelte/svelte-window
4f1068e
to
4c775f6
Compare