From 17cca75505c279039465a1979494d6f34b44e669 Mon Sep 17 00:00:00 2001 From: Made Baruna Date: Sat, 20 Mar 2021 04:12:10 +0800 Subject: [PATCH] More timeline styling --- src/routes/timeline/_item.svelte | 36 +++++++++++++++++++++++++------- src/routes/timeline/index.svelte | 2 ++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/routes/timeline/_item.svelte b/src/routes/timeline/_item.svelte index bb897ba5..00a7eabf 100644 --- a/src/routes/timeline/_item.svelte +++ b/src/routes/timeline/_item.svelte @@ -23,6 +23,8 @@ $: attachedNext = next !== null && next.start.diff(event.end, 'hour') < 1; $: attachedPrev = prev !== null && event.start.diff(prev.end, 'hour') < 1; $: prevEnded = prev !== null && now.isAfter(prev.end); + $: shouldShowHourStart = diffStart <= 86400000 || event.duration > 8 || !prevNearby; + $: shouldShowHourEnd = diffEnd <= 86400000 || event.duration > 8 || !prevNearby;
{#if started && !ended && !event.startOnly && !attachedNext} -
+
- {`${diffEnd > 86400000 ? `${Math.trunc(dayjs.duration(diffEnd).asDays())}d` : ''} ${dayjs.duration(diffEnd).format('HH:mm:ss')}`} + {diffEnd > 86400000 + ? `${Math.trunc(dayjs.duration(diffEnd).asDays())}d ${ + shouldShowHourEnd ? dayjs.duration(diffEnd).format('HH:mm:ss') : '' + }` + : dayjs.duration(diffEnd).format('HH:mm:ss')}
- - {:else if (prevNearby && !attachedPrev ? prevEnded : true) && !started && !ended} -
+ + {:else if (prevNearby && !attachedPrev ? prevEnded : true) && !started && !ended} +
- {`${diffStart > 86400000 ? `${Math.trunc(dayjs.duration(diffStart).asDays())}d` : ''} ${dayjs.duration(diffStart).format('HH:mm:ss')}`} + {diffStart > 86400000 + ? `${Math.trunc(dayjs.duration(diffStart).asDays())}d ${ + shouldShowHourStart ? dayjs.duration(diffStart).format('HH:mm:ss') : '' + }` + : dayjs.duration(diffStart).format('HH:mm:ss')}
{/if} diff --git a/src/routes/timeline/index.svelte b/src/routes/timeline/index.svelte index 5f72e5db..d1e5b4a3 100644 --- a/src/routes/timeline/index.svelte +++ b/src/routes/timeline/index.svelte @@ -150,6 +150,8 @@ loading = false; await tick(); + if (timelineContainer === undefined) return; + if (timelineContainer.offsetWidth < 500) { dayWidth = 40; await tick();