Skip to content

Commit

Permalink
Merge pull request #4 from frorong/feature/convenience
Browse files Browse the repository at this point in the history
Add scrollToTopButton and openGraph
  • Loading branch information
frorong committed Mar 28, 2024
2 parents 69548fd + 25b4a49 commit 26ccbaf
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 18 deletions.
35 changes: 35 additions & 0 deletions src/components/scrollToTopButton.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<script lang="ts">
function scrollToTop() {
const scrollStep =
-window.scrollY / (500 / 15)
const scrollInterval = setInterval(
function () {
if (window.scrollY !== 0)
window.scrollBy(0, scrollStep)
else
clearInterval(scrollInterval)
},
15
)
}
</script>

<button
class="fixed bottom-16 right-16 rounded-full bg-blue-500 px-4 py-2 text-white shadow-md transition duration-300 hover:bg-blue-600"
on:click="{scrollToTop}"
>
<svg
class="h-6 w-6"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M5 10l7-7m0 0l7 7m-7-7v18"
></path>
</svg>
</button>
Empty file added src/lib/images/.gitkeep
Empty file.
16 changes: 0 additions & 16 deletions src/lib/images/github.svg

This file was deleted.

Binary file added src/lib/images/openGraph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/lib/images/svelte-logo.svg

This file was deleted.

Binary file removed src/lib/images/svelte-welcome.png
Binary file not shown.
Binary file removed src/lib/images/svelte-welcome.webp
Binary file not shown.
18 changes: 18 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@
import '../app.postcss'
import '../prism.css'
import Header from '@components/header.svelte'
import ScrollToTopButton from '@components/scrollToTopButton.svelte'
</script>

<svelte:head>
<title>Frorong's history</title>
<meta
property="og:type"
content="article"
/>
<meta
property="og:title"
content="Frorong's history"
/>
<meta
property="og:image"
content="{'/lib/images/openGraph.png'}"
/>
</svelte:head>

<div
class="w-full p-4 md:p-6 lg:p-8 xl:p-12"
>
Expand All @@ -12,5 +29,6 @@
class="flex w-full flex-col items-center"
>
<slot />
<ScrollToTopButton />
</main>
</div>
2 changes: 1 addition & 1 deletion src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const prerender = true
export const prerender = false

0 comments on commit 26ccbaf

Please sign in to comment.