feat: moveup fab
This commit is contained in:
parent
71ea19d6cb
commit
94ca2a8a2a
3 changed files with 40 additions and 0 deletions
38
src/components/MoveUpButton.svelte
Normal file
38
src/components/MoveUpButton.svelte
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<script lang="ts">
|
||||
import { mdiChevronDoubleUp } from '@mdi/js';
|
||||
import Icon from 'mdi-svelte';
|
||||
let y: number = 0;
|
||||
|
||||
$: enabled = y > 100;
|
||||
|
||||
function onClick() {
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window bind:scrollY={y} />
|
||||
|
||||
{#if enabled}
|
||||
<button on:click={onClick}><Icon path={mdiChevronDoubleUp} /></button>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
button:focus {
|
||||
box-shadow: 0 0 5px var(--special-shadow-color);
|
||||
}
|
||||
button {
|
||||
border-radius: 35px;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
position: fixed;
|
||||
bottom: 32px;
|
||||
right: 32px;
|
||||
color: var(--text-soft-color);
|
||||
border: 2px solid var(--border-color);
|
||||
background-color: var(--light-color);
|
||||
}
|
||||
button:hover {
|
||||
color: var(--special-color);
|
||||
border: 4px solid var(--border-color);
|
||||
}
|
||||
</style>
|
||||
0
modules.d.ts → src/modules.d.ts
vendored
0
modules.d.ts → src/modules.d.ts
vendored
|
|
@ -9,6 +9,7 @@
|
|||
import Icon from 'mdi-svelte';
|
||||
import '@fontsource/ubuntu-mono/400.css';
|
||||
import Link from '../components/Link.svelte';
|
||||
import MoveUpButton from '../components/MoveUpButton.svelte';
|
||||
|
||||
const NAV_ITEMS = [
|
||||
{ href: '/blog', label: 'Blog' },
|
||||
|
|
@ -46,6 +47,7 @@
|
|||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
<MoveUpButton />
|
||||
<footer>
|
||||
<div class="container">
|
||||
<p>Copyright <Icon path={mdiCopyright} size="1rem" /> {year} Alexander Daichendt</p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue