sveltejs/sapper

Route as modal

Closed this issue · 4 comments

Question: Is it possible to implement a route so that it opens as a modal / on top of the current page / not replacing the current page, but reflecting in URL, such as asked in https://stackoverflow.com/questions/61185073/route-as-modal-in-sapper

Thanks for any advice.

Yes it's possible. Simply append a query string to the url like /users?action=new. You can then get the action from the page store

const { page } = stores();

and show the modal when page.query.action === 'new'.

It'd be easier to help you if you would first try to actually implement it and then tell us where you're actual problem is.

@HibiscusJordan thanks a lot. I'm not sure if that's what I need since that would not create a static html file for that URL on export, correct? I'm basically looking for a solution for a portfolio website where /projects will be the list of projects and /projects/project1 etc. will be each unique project details. But since the page architecture is a single page app I don't want to lose the scroll position when returing from /projects/project1 to /projects

I'm just beginning with Sapper and Svelte so there are a lot of questions.

Why don't you simply save the scroll position to localStorage then? That would be easier.

That's a legit option, too :)

Thanks for the suggestion above using a query string, that's good to know you can do that. I think I can go on from here now. Closing this 👍