Automatically go to navigation section when clicking navigation in preview

This commit is contained in:
Andrew Kingston 2022-05-06 13:59:16 +01:00
parent eb4d8d5e52
commit 85a619c6ea
3 changed files with 16 additions and 0 deletions

View File

@ -182,6 +182,10 @@
store.actions.components.copy(source, true)
await store.actions.components.paste(destination, data.mode)
}
} else if (type === "click-nav") {
if (!$isActive("./navigation")) {
$goto("./navigation")
}
} else {
console.warn(`Client sent unknown event type: ${type}`)
}

View File

@ -121,6 +121,8 @@
class="nav-wrapper"
class:sticky
class:hidden={isPeeking}
class:clickable={$builderStore.inBuilder}
on:click={$builderStore.inBuilder ? builderStore.actions.clickNav : null}
style={navStyle}
>
<div class="nav nav--{typeClass} size--{navWidthClass}">
@ -221,6 +223,12 @@
border-bottom: 1px solid var(--spectrum-global-color-gray-300);
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.05);
}
.nav-wrapper.clickable {
cursor: pointer;
}
.nav-wrapper.clickable .nav {
pointer-events: none;
}
.nav-wrapper.hidden {
display: none;
}

View File

@ -76,6 +76,10 @@ const createBuilderStore = () => {
}
store.update(state => ({ ...state, editMode: enabled }))
},
clickNav: () => {
console.log("click nav")
dispatchEvent("click-nav")
},
}
return {
...store,