Skip to content

Commit

Permalink
Documentation UX updates (#139)
Browse files Browse the repository at this point in the history
* Keeps the active page in view on the navigation

* Installed hotkeys for FF support fixes #107
  • Loading branch information
danpastori authored Dec 10, 2024
1 parent 6c14613 commit 3b14189
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
17 changes: 10 additions & 7 deletions docs/components/Docs/Navigation.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<nav>
<nav id="docs-navigation">
<ul role="list">
<li class="relative my-6">
<h2 class="text-xs font-semibold text-white">
Expand Down Expand Up @@ -39,12 +39,6 @@
'md:mt-0': groupIndex === 0
}"
/>

<li class="sticky bottom-0 z-10 mt-6 min-[416px]:hidden">
<AppLink :href="'#'" :variant="'filled'" class="w-full">
Sign in
</AppLink>
</li>
</ul>
</nav>
</template>
Expand All @@ -53,4 +47,13 @@
const route = useRoute();
const { navigation, toc } = useContent();
onMounted(() => {
console.log(route.path);
const element = document.querySelector(`[data-attr-link-id="${route.path}"]`);
if (element) {
// Can we scroll to this element without using smooth?
element.scrollIntoView();
}
})
</script>
4 changes: 3 additions & 1 deletion docs/components/Docs/NavigationGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
}">
<NuxtLink
:to="link._path"
:data-attr-link-id="link._path"
class="flex justify-between gap-2 py-1 pr-3 text-sm transition"
:class="{
'text-white': link._path === route.path,
Expand Down Expand Up @@ -55,4 +56,5 @@ const route = useRoute();
const scrollTo = (id) => {
document.getElementById( id.replace('#', '') ).scrollIntoView(true, {behavior: "smooth"})
}
</script>
</script>
12 changes: 7 additions & 5 deletions docs/components/content/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,19 @@ import DocsIcon from './DocsIcon.vue';
import HeartIcon from './HeartIcon.vue';
import GitHubIcon from './GitHubIcon.vue';
import hotkeys from 'hotkeys-js';
/**
* CMD + K shortcut for activating the modal
*/
const show = ref(false);
const { meta, k } = useMagicKeys();
watchEffect(() => {
if (meta.value && k.value) {
if( import.meta.client ){
hotkeys('ctrl+k,command+k', (event, handler) => {
show.value = true;
}
});
event.preventDefault();
});
}
/**
* Event handler for opening the modal
Expand Down
3 changes: 2 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"surge": "^0.23.1"
},
"dependencies": {
"@heroicons/vue": "^2.1.1"
"@heroicons/vue": "^2.1.1",
"hotkeys-js": "^3.13.7"
}
}
5 changes: 5 additions & 0 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4284,6 +4284,11 @@ hosted-git-info@^7.0.0:
dependencies:
lru-cache "^10.0.1"

hotkeys-js@^3.13.7:
version "3.13.7"
resolved "https://registry.yarnpkg.com/hotkeys-js/-/hotkeys-js-3.13.7.tgz#0188d8e2fca16a3f1d66541b48de0bb9df613726"
integrity sha512-ygFIdTqqwG4fFP7kkiYlvayZppeIQX2aPpirsngkv1xM1lP0piDY5QEh68nQnIKvz64hfocxhBaD/uK3sSK1yQ==

html-tags@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-3.3.1.tgz#a04026a18c882e4bba8a01a3d39cfe465d40b5ce"
Expand Down

0 comments on commit 3b14189

Please sign in to comment.