1
0
Fork 0
mirror of synced 2024-07-07 07:15:43 +12:00

when navigating between fronend & backend,

you return to the last url you worked on
This commit is contained in:
Michael Shanks 2020-06-29 21:26:16 +01:00
parent f902414941
commit a3de20162f

View file

@ -5,7 +5,7 @@
import { get } from "builderStore/api" import { get } from "builderStore/api"
import { fade } from "svelte/transition" import { fade } from "svelte/transition"
import { isActive, goto, layout } from "@sveltech/routify" import { isActive, goto, layout, url } from "@sveltech/routify"
import { SettingsIcon, PreviewIcon } from "components/common/Icons/" import { SettingsIcon, PreviewIcon } from "components/common/Icons/"
import IconButton from "components/common/IconButton.svelte" import IconButton from "components/common/IconButton.svelte"
@ -27,6 +27,17 @@
throw new Error(pkg) throw new Error(pkg)
} }
} }
const topItemNavigate = path => () => {
const activeTopNav = $layout.children.find(c => $isActive(c.path))
if (!activeTopNav) return
store.update(state => {
if (!state.previousTopNavPath) state.previousTopNavPath = {}
state.previousTopNavPath[activeTopNav.path] = window.location.pathname.replace("/_builder", "")
$goto(state.previousTopNavPath[path] || path)
return state
})
}
</script> </script>
<Modal> <Modal>
@ -46,7 +57,7 @@
<span <span
class:active={$isActive(path)} class:active={$isActive(path)}
class="topnavitem" class="topnavitem"
on:click={() => $goto(path)}> on:click={topItemNavigate(path)}>
{title} {title}
</span> </span>
{/each} {/each}