this repo has no description
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 51 lines 1.4 kB view raw
1<script lang="ts" context="module"> 2 import type { 3 Action, 4 ShelfBasedPageScrollAction, 5 } from '@jet-app/app-store/api/models'; 6 7 export function isShelfBasedPageScrollAction( 8 action: Action, 9 ): action is ShelfBasedPageScrollAction { 10 return ( 11 action.$kind === 'ShelfBasedPageScrollAction' && 'shelfId' in action 12 ); 13 } 14</script> 15 16<script lang="ts"> 17 import type { HTMLAnchorAttributes } from 'svelte/elements'; 18 19 interface $$Props extends HTMLAnchorAttributes { 20 destination: ShelfBasedPageScrollAction; 21 } 22 23 export let destination: ShelfBasedPageScrollAction; 24 25 function handleLinkClick(e: Event) { 26 const anchorElement = e.currentTarget as HTMLAnchorElement; 27 const hash = anchorElement.hash; 28 const elementToScrollTo = document.querySelector(hash); 29 if (!elementToScrollTo) { 30 return; 31 } 32 elementToScrollTo.scrollIntoView({ 33 behavior: 'smooth', 34 block: 'start', 35 }); 36 history.replaceState(null, '', hash); 37 } 38</script> 39 40{#if destination.shelfId} 41 <a 42 {...$$restProps} 43 data-test-id="scroll-link" 44 href={`#${destination.shelfId}`} 45 on:click|preventDefault|stopPropagation={handleLinkClick} 46 > 47 <slot /> 48 </a> 49{:else} 50 <slot /> 51{/if}