Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions apps/svelte.dev/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@
injectSpeedInsights();

let { data, children: layout_children } = $props();

/** @type {import('@sveltejs/site-kit/components').Shell} */
let shell;

export const snapshot = {
capture() {
return {
shell: shell.snapshot.capture()
};
},
restore(data) {
shell.snapshot.restore(data?.shell);
}
};
</script>

<svelte:head>
Expand All @@ -35,7 +21,7 @@
{/if}
</svelte:head>

<Shell nav_visible={$page.route.id !== '/(authed)/repl/[id]/embed'} bind:this={shell}>
<Shell nav_visible={$page.route.id !== '/(authed)/repl/[id]/embed'}>
{#snippet top_nav()}
<Nav title={data.nav_title} links={data.nav_links}>
{#snippet search()}
Expand Down
29 changes: 1 addition & 28 deletions packages/site-kit/src/lib/components/Shell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ The main shell of the application. It provides a slot for the top navigation, th
-->

<script lang="ts">
import { afterNavigate } from '$app/navigation';
import { navigating } from '$app/stores';
import { overlay_open } from '../stores';
import PreloadingIndicator from '../nav/PreloadingIndicator.svelte';
import SkipLink from '../nav/SkipLink.svelte';
import '../styles/index.css';
import Icons from './Icons.svelte';
import type { Snippet } from 'svelte';
import type { Snapshot } from '@sveltejs/kit';

let {
nav_visible = true,
Expand All @@ -24,29 +22,6 @@ The main shell of the application. It provides a slot for the top navigation, th
children?: Snippet;
banner_bottom?: Snippet;
} = $props();

let main_el = $state() as HTMLElement;
let scroll_restored = false;

afterNavigate(() => {
if (!scroll_restored) {
main_el.scrollTop = 0;
}
scroll_restored = false;
});

export const snapshot: Snapshot<number> = {
capture() {
return main_el.scrollTop;
},
restore(scroll_top) {
main_el.scrollTop = scroll_top;

// Restore is not called for the first navigation to a page,
// use this flag to track whether to reset the scroll to top or not in afterNavigate
scroll_restored = true;
}
};
</script>

<Icons />
Expand All @@ -63,7 +38,7 @@ The main shell of the application. It provides a slot for the top navigation, th

<div class="modal-overlay" class:visible={$overlay_open} aria-hidden="true"></div>

<main id="main" bind:this={main_el}>
<main id="main">
{@render children?.()}
</main>

Expand Down Expand Up @@ -99,8 +74,6 @@ The main shell of the application. It provides a slot for the top navigation, th
margin: 0 auto;
padding-top: var(--sk-nav-height);
padding-bottom: var(--sk-banner-bottom-height);
overflow: hidden;
overflow-y: auto;
height: 100%;
}

Expand Down
Loading