Files
rf4-spotter/apps/web/src/components/ActivityTimeline.astro
T

12 lines
941 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
const { buckets } = Astro.props as { buckets: { start: string; end: string; count: number }[] };
const max = Math.max(1, ...buckets.map(bucket => bucket.count));
const meterLevel = (count: number) => Math.round((count / max * 100) / 5) * 5;
---
<section class="activity-timeline" aria-labelledby="timeline-title">
<header><div><span class="overline">Последние 72 часа</span><h2 id="timeline-title">Леска активности</h2></div><p>Все одобренные записи · по времени поступления · шаг 12 часов</p></header>
<div class="timeline-chart">
{buckets.map((bucket, index) => <div class="timeline-slot"><span aria-hidden="true" class:list={["timeline-line", `meter-level-${meterLevel(bucket.count)}`]}>{bucket.count > 0 && <i></i>}</span><strong>{bucket.count}</strong><small>{`${(6-index)*12}${(5-index)*12} ч назад`}</small></div>)}
</div>
</section>