Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ad376772e9 | |||
| 209cd0e208 |
@@ -1,13 +1,16 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { chats } from './chats';
|
import { chats } from './lib/chats';
|
||||||
import { type TransitionConfig } from 'svelte/transition';
|
import { type TransitionConfig } from 'svelte/transition';
|
||||||
import { quadOut as easing } from 'svelte/easing';
|
import { quadOut as easing } from 'svelte/easing';
|
||||||
import CommentRenderer from './components/CommentRenderer.svelte';
|
import CommentRenderer from './components/CommentRenderer.svelte';
|
||||||
|
import { url } from './lib/url';
|
||||||
|
|
||||||
const child = new WeakMap<Node, number>();
|
const child = new WeakMap<Node, number>();
|
||||||
let container: HTMLDivElement;
|
let container: HTMLDivElement;
|
||||||
let queued = false;
|
let queued = false;
|
||||||
|
|
||||||
|
$: top = $url.searchParams.get('layout') === 'top';
|
||||||
|
|
||||||
function queue() {
|
function queue() {
|
||||||
if (queued) return;
|
if (queued) return;
|
||||||
function fn() {
|
function fn() {
|
||||||
@@ -17,7 +20,7 @@
|
|||||||
container.childNodes.forEach((node) => {
|
container.childNodes.forEach((node) => {
|
||||||
n += child.get(node) ?? 0;
|
n += child.get(node) ?? 0;
|
||||||
});
|
});
|
||||||
container.scrollTo({ top: -n });
|
container.scrollTo({ top: top ? n : -n });
|
||||||
}
|
}
|
||||||
requestAnimationFrame(fn);
|
requestAnimationFrame(fn);
|
||||||
}
|
}
|
||||||
@@ -38,7 +41,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="main flex flex-col-reverse h-screen w-screen overflow-hidden px-3 py-2"
|
class="flex h-screen w-screen overflow-hidden px-3 py-2"
|
||||||
|
class:bottom={!top}
|
||||||
|
class:top
|
||||||
bind:this={container}
|
bind:this={container}
|
||||||
>
|
>
|
||||||
{#each [...$chats].reverse() as chat (`${chat.service}/${chat.data.id}`)}
|
{#each [...$chats].reverse() as chat (`${chat.service}/${chat.data.id}`)}
|
||||||
@@ -49,7 +54,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="postcss">
|
<style lang="postcss">
|
||||||
.main {
|
.bottom {
|
||||||
|
@apply flex-col-reverse;
|
||||||
mask-image: linear-gradient(
|
mask-image: linear-gradient(
|
||||||
180deg,
|
180deg,
|
||||||
rgba(0, 0, 0, 0) 0%,
|
rgba(0, 0, 0, 0) 0%,
|
||||||
@@ -58,4 +64,14 @@
|
|||||||
rgba(0, 0, 0, 1) 100%
|
rgba(0, 0, 0, 1) 100%
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
.top {
|
||||||
|
@apply flex-col;
|
||||||
|
mask-image: linear-gradient(
|
||||||
|
0deg,
|
||||||
|
rgba(0, 0, 0, 0) 0%,
|
||||||
|
rgba(0, 0, 0, 0.25) 15%,
|
||||||
|
rgba(0, 0, 0, 1) 30%,
|
||||||
|
rgba(0, 0, 0, 1) 100%
|
||||||
|
);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -21,7 +21,9 @@
|
|||||||
<div class="text-xs font-bold gap-0.5 items-center {authorColor(comment)}">
|
<div class="text-xs font-bold gap-0.5 items-center {authorColor(comment)}">
|
||||||
{author}
|
{author}
|
||||||
{#each comment.data.badges as badge}
|
{#each comment.data.badges as badge}
|
||||||
<img class="h-3 w-3 inline-block mx-0.5" src={badge.url} alt={badge.label} />
|
{#if badge.url}
|
||||||
|
<img class="h-3 w-3 inline-block mx-0.5" src={badge.url} alt={badge.label} />
|
||||||
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
<div class="comment-container">
|
<div class="comment-container">
|
||||||
|
|||||||
3
src/lib/url.ts
Normal file
3
src/lib/url.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { readable } from 'svelte/store';
|
||||||
|
|
||||||
|
export const url = readable(new URL(window.location.href));
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import './app.pcss';
|
import './app.pcss';
|
||||||
import App from './App.svelte';
|
import App from './App.svelte';
|
||||||
import type { Comment } from '@onecomme.com/onesdk/types/Comment';
|
import type { Comment } from '@onecomme.com/onesdk/types/Comment';
|
||||||
import { chats } from './chats';
|
import { chats } from './lib/chats';
|
||||||
|
|
||||||
if (import.meta.env.DEV) {
|
if (import.meta.env.DEV) {
|
||||||
globalThis.OneSDK = (await import('@onecomme.com/onesdk')).default;
|
globalThis.OneSDK = (await import('@onecomme.com/onesdk')).default;
|
||||||
|
|||||||
Reference in New Issue
Block a user