Skip to content
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

Dynamically change between primary and secondary panes #5

Open
Thuhaa opened this issue Feb 20, 2023 · 1 comment
Open

Dynamically change between primary and secondary panes #5

Thuhaa opened this issue Feb 20, 2023 · 1 comment

Comments

@Thuhaa
Copy link

Thuhaa commented Feb 20, 2023

I want dynamically change between the primary and secondary panes. I can't seem to be able to do that while maintaining the content in my components.

Using if else statements works, but it will re-render the components, which is not what I want, as I want to maintain the state, but switch the positions of the panes.

svelte has a limitation in that I can't really use dynamic slot naming,
something like
<div slot={slotPos === 'left' ? 'primary' : 'secondary'}></div>
will not work.

Please show me how this can be done.

@Thuhaa Thuhaa changed the title I can't dynamically change between primary and secondary panes Dynamically change between primary and secondary panes Feb 20, 2023
@GeoffCox
Copy link
Owner

@Thuhaa I would have the split with divs that have primary and secondary and not change them. Instead, I would use the svelte:component technique to swap in the content into either the primary or secondary pane.

https://svelte.dev/tutorial/svelte-component provides an example of how to use svelte:component. This allows you to choose a component to render via the script rather than trying to wrestle the #if limitations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants