campfire/src/routes/+page.svelte

62 lines
1.3 KiB
Svelte
Raw Normal View History

<script>
import { page } from '$app/stores';
import { get } from 'svelte/store';
import { logged_in } from '$lib/stores/account.js';
import { timeline, getTimeline } from '$lib/timeline.js';
import LoginForm from '$lib/ui/LoginForm.svelte';
2024-06-29 10:46:27 +01:00
import Feed from '$lib/ui/Feed.svelte';
2024-07-04 16:55:57 +01:00
import Modal from '../lib/ui/Modal.svelte';
2024-07-02 20:21:34 +01:00
logged_in.subscribe(logged_in => {
if (logged_in) getTimeline();
});
document.addEventListener("scroll", event => {
2024-07-02 20:21:34 +01:00
if (get(logged_in) && get(page).url.pathname !== "/") return;
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 2048) {
getTimeline();
}
});
</script>
2024-07-02 20:21:34 +01:00
{#if $logged_in}
<Feed posts={$timeline} />
{:else}
<LoginForm />
2024-06-29 17:27:46 +01:00
{/if}
<style>
a {
color: var(--accent);
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
2024-06-29 17:27:46 +01:00
header {
width: 100%;
margin: 16px 0 8px 0;
display: flex;
flex-direction: row;
}
2024-06-29 17:27:46 +01:00
header h1 {
font-size: 1.5em;
}
2024-06-29 17:27:46 +01:00
header nav {
margin-left: auto;
display: flex;
flex-direction: row;
gap: 8px;
}
2024-06-30 17:37:19 +01:00
:global(.app-logo) {
height: auto;
width: 320px;
margin: 8px;
}
</style>