aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Feed.svelte
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-12-20 17:41:40 -0800
committerAdam Soltys <[email protected]>2022-12-20 17:41:40 -0800
commit268d71cb57ff19382ff8834ca3406dda2f79343e (patch)
tree2cb012b7f74f0947f9b03304d62c4604ab79fdfd /src/components/Feed.svelte
parent70208aaa216a147f2f1d43a42a5fc8e1f4be767f (diff)
downloadcoinos-ui-268d71cb57ff19382ff8834ca3406dda2f79343e.tar.gz
coinos-ui-268d71cb57ff19382ff8834ca3406dda2f79343e.zip
new profile page
Diffstat (limited to 'src/components/Feed.svelte')
-rw-r--r--src/components/Feed.svelte49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/components/Feed.svelte b/src/components/Feed.svelte
new file mode 100644
index 00000000..973afa19
--- /dev/null
+++ b/src/components/Feed.svelte
@@ -0,0 +1,49 @@
+<script>
+ import { Avatar } from '$comp';
+ import { browser } from '$app/environment';
+ import VirtualScroll from 'svelte-virtual-scroll-list';
+ import { runner } from '$lib/utils';
+ export let events;
+
+ let distance = (d) => {
+ let diff = Math.round(Date.now() / 1000) - d;
+ return diff > 3600
+ ? Math.round(diff / 3600) + 'd'
+ : diff > 60
+ ? Math.round(diff / 60) + 'm'
+ : diff > 2
+ ? diff + 's'
+ : 'now';
+ };
+
+ let w;
+</script>
+
+<svelte:window bind:innerWidth={w} />
+
+{#if browser}
+ <VirtualScroll data={events} key="id" let:data pageMode={true} estimateSize={200}>
+ <div class="flex border-b py-4 text-sm lg:text-lg text-secondary" :key={data.id}>
+ <a href={`/${data.pubkey}`}>
+ <div class="mb-auto mr-2">
+ <div class="md:hidden">
+ <Avatar size={12} src={`/api/public/runners/${runner(data.pubkey)}`} disabled={true} />
+ </div>
+ <div class="hidden md:block">
+ <Avatar size={20} src={`/api/public/runners/${runner(data.pubkey)}`} disabled={true} />
+ </div>
+ </div>
+ </a>
+
+ <div class="grow" style={`max-width: ${w - 100}px`}>
+ <div class="w-full flex pb-1 text-black">
+ <div>{data.pubkey.substr(0, 6)}</div>
+ <div class="text-secondary">&nbsp;{distance(data.seen)}</div>
+ </div>
+ <div class="break-words">
+ {data.content}
+ </div>
+ </div>
+ </div>
+ </VirtualScroll>
+{/if}