diff --git a/packages/histoire/package.json b/packages/histoire/package.json index cb23fc28..2fded61b 100644 --- a/packages/histoire/package.json +++ b/packages/histoire/package.json @@ -60,6 +60,7 @@ "picocolors": "^1.0.0", "pinia": "^2.0.11", "sade": "^1.8.1", + "scroll-into-view-if-needed": "^2.2.29", "shiki": "^0.10.1", "vite-node": "^0.3.6", "vue-router": "^4.0.12" diff --git a/packages/histoire/src/client/app/components/story/StoryListItem.vue b/packages/histoire/src/client/app/components/story/StoryListItem.vue index 44e75c16..1d5135d1 100644 --- a/packages/histoire/src/client/app/components/story/StoryListItem.vue +++ b/packages/histoire/src/client/app/components/story/StoryListItem.vue @@ -2,7 +2,9 @@ import type { Story } from '../../types' import BaseListItemLink from '../base/BaseListItemLink.vue' import { Icon } from '@iconify/vue' -import { computed, withDefaults } from 'vue' +import { computed, ref, withDefaults } from 'vue' +import { useRoute } from 'vue-router' +import { useScrollOnActive } from '../../util/scroll.js' const props = withDefaults(defineProps<{ story: Story @@ -14,10 +16,15 @@ const props = withDefaults(defineProps<{ const filePadding = computed(() => { return (props.depth * 16) + 'px' }) + +const route = useRoute() +const active = computed(() => route.params.storyId === props.story.id) +const el = ref() +useScrollOnActive(active, el)