1
0
Fork 0
mirror of synced 2024-10-01 01:28:51 +13:00

corrects page switching behaviour in page selection component

This commit is contained in:
kevmodrome 2020-04-28 14:28:23 +02:00
parent d931b9018b
commit 6cc8d7982e

View file

@ -1,5 +1,5 @@
<script> <script>
import { params } from "@sveltech/routify" import { params, goto } from "@sveltech/routify"
import { store } from "builderStore" import { store } from "builderStore"
import getIcon from "components/common/icon" import getIcon from "components/common/icon"
import { CheckIcon } from "components/common/Icons" import { CheckIcon } from "components/common/Icons"
@ -21,6 +21,11 @@
] ]
store.setCurrentPage($params.page ? $params.page : "main") store.setCurrentPage($params.page ? $params.page : "main")
const changePage = id => {
store.setCurrentPage(id)
$goto(`./${id}`)
}
</script> </script>
<div class="root"> <div class="root">
@ -28,14 +33,14 @@
{#each pages as { title, id }} {#each pages as { title, id }}
<li> <li>
<span class="icon"> <span class="icon">
{#if id === $store.currentPageName} {#if id === $params.page}
<CheckIcon /> <CheckIcon />
{/if} {/if}
</span> </span>
<button <button
class:active={id === $store.currentPageName} class:active={id === $params.page}
on:click={() => store.setCurrentPage(id)}> on:click={() => changePage(id)}>
{title} {title}
</button> </button>
</li> </li>