~james/core

core/web/src/lib/components/comment/reveal.ts -rw-r--r-- 517 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 16 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { prefersReducedMotion } from "svelte/motion";
import type { CommentView } from "#lib/components/comment/comments.ts";
import { revealItem } from "#lib/motion/reveal.ts";
import { RAIL_DURATION, railEasing } from "#lib/motion/spring.ts";

const FRESH = 60_000;

export const revealComment = (node: HTMLElement, comment: CommentView) =>
	revealItem(node, {
		duration:
			Date.now() - Date.parse(comment.createdAt) < FRESH && !prefersReducedMotion.current
				? RAIL_DURATION
				: 0,
		easing: railEasing
	});