Browse Source

when navigating between fronend & backend,

you return to the last url you worked on
gh-pages
Michael Shanks 6 years ago
parent
commit
a3de20162f
  1. 15
      packages/builder/src/pages/[application]/_reset.svelte

15
packages/builder/src/pages/[application]/_reset.svelte

@ -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}

Loading…
Cancel
Save