diff options
| author | Fuwn <[email protected]> | 2024-10-09 00:41:20 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-09 00:41:43 -0700 |
| commit | 998b63a35256ac985a5a2714dd1ca451af4dfd8a (patch) | |
| tree | 50796121a9d5ab0330fdc5d7e098bda2860d9726 /src/lib/Home | |
| parent | feat(graphql): add badgeCount field (diff) | |
| download | due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.tar.xz due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.zip | |
chore(prettier): use spaces instead of tabs
Diffstat (limited to 'src/lib/Home')
| -rw-r--r-- | src/lib/Home/HeadTitle.svelte | 20 | ||||
| -rw-r--r-- | src/lib/Home/LastActivity.svelte | 108 | ||||
| -rw-r--r-- | src/lib/Home/Root.svelte | 36 |
3 files changed, 82 insertions, 82 deletions
diff --git a/src/lib/Home/HeadTitle.svelte b/src/lib/Home/HeadTitle.svelte index 2fc6b53e..39a65ccd 100644 --- a/src/lib/Home/HeadTitle.svelte +++ b/src/lib/Home/HeadTitle.svelte @@ -1,18 +1,18 @@ <script lang="ts"> - export let route: string | undefined = undefined; - export let path = '/'; + export let route: string | undefined = undefined; + export let path = '/'; - const title = (route ? `${route} • ` : '') + 'due.moe'; + const title = (route ? `${route} • ` : '') + 'due.moe'; </script> <svelte:head> - <!-- Facebook --> - <meta name="og:url" property="og:url" content={`https://due.moe${path}`} /> - <meta name="og:title" property="og:title" content={title} /> + <!-- Facebook --> + <meta name="og:url" property="og:url" content={`https://due.moe${path}`} /> + <meta name="og:title" property="og:title" content={title} /> - <!-- Twitter --> - <meta name="twitter:url" property="twitter:url" content={`https://due.moe${path}`} /> - <meta name="twitter:title" property="twitter:title" content={title} /> + <!-- Twitter --> + <meta name="twitter:url" property="twitter:url" content={`https://due.moe${path}`} /> + <meta name="twitter:title" property="twitter:title" content={title} /> - <title>{title}</title> + <title>{title}</title> </svelte:head> diff --git a/src/lib/Home/LastActivity.svelte b/src/lib/Home/LastActivity.svelte index 9d4bdf6e..000c7f7b 100644 --- a/src/lib/Home/LastActivity.svelte +++ b/src/lib/Home/LastActivity.svelte @@ -1,59 +1,59 @@ <script lang="ts"> - import userIdentity from '$stores/identity'; - import { onMount } from 'svelte'; - import type { AniListAuthorisation } from '$lib/Data/AniList/identity'; - import { lastActivityDate } from '../Data/AniList/activity'; - import settings from '$stores/settings'; - - export let user: AniListAuthorisation; - - let lastActivityWasToday = true; - - onMount(async () => { - if (user !== undefined && !$settings.displayDisableLastActivityWarning) { - lastActivityWasToday = - (await lastActivityDate($userIdentity, user)).date.toDateString() >= - new Date().toDateString(); - - if (!lastActivityWasToday) { - if ($settings.displayLimitListHeight) { - document.querySelectorAll('.list').forEach((list) => { - (list as HTMLElement).style.maxHeight = `calc((100vh - ${ - document.querySelector('#list-container')?.getBoundingClientRect().top - }px) - 5rem)`; - }); - } - } - } - }); - - const timeLeftToday = () => { - const now = new Date(); - const currentHour = now.getHours(); - const currentMinute = now.getMinutes(); - const hoursLeft = 24 - currentHour; - let minutesLeft = 0; - let timeLeft = ''; - - if (hoursLeft > 0) { - minutesLeft = hoursLeft * 60 - currentMinute; - } else { - minutesLeft = 24 * 60 - (currentHour * 60 + currentMinute); - } - - if (minutesLeft > 60) { - timeLeft = `${Math.round(minutesLeft / 60)} hours`; - } else { - timeLeft = `${minutesLeft} minutes`; - } - - return timeLeft; - }; + import userIdentity from '$stores/identity'; + import { onMount } from 'svelte'; + import type { AniListAuthorisation } from '$lib/Data/AniList/identity'; + import { lastActivityDate } from '../Data/AniList/activity'; + import settings from '$stores/settings'; + + export let user: AniListAuthorisation; + + let lastActivityWasToday = true; + + onMount(async () => { + if (user !== undefined && !$settings.displayDisableLastActivityWarning) { + lastActivityWasToday = + (await lastActivityDate($userIdentity, user)).date.toDateString() >= + new Date().toDateString(); + + if (!lastActivityWasToday) { + if ($settings.displayLimitListHeight) { + document.querySelectorAll('.list').forEach((list) => { + (list as HTMLElement).style.maxHeight = `calc((100vh - ${ + document.querySelector('#list-container')?.getBoundingClientRect().top + }px) - 5rem)`; + }); + } + } + } + }); + + const timeLeftToday = () => { + const now = new Date(); + const currentHour = now.getHours(); + const currentMinute = now.getMinutes(); + const hoursLeft = 24 - currentHour; + let minutesLeft = 0; + let timeLeft = ''; + + if (hoursLeft > 0) { + minutesLeft = hoursLeft * 60 - currentMinute; + } else { + minutesLeft = 24 * 60 - (currentHour * 60 + currentMinute); + } + + if (minutesLeft > 60) { + timeLeft = `${Math.round(minutesLeft / 60)} hours`; + } else { + timeLeft = `${minutesLeft} minutes`; + } + + return timeLeft; + }; </script> {#if !lastActivityWasToday} - <blockquote> - You don't have any new activity statuses from the past day! Create one within {timeLeftToday()} - to keep your streak! - </blockquote> + <blockquote> + You don't have any new activity statuses from the past day! Create one within {timeLeftToday()} + to keep your streak! + </blockquote> {/if} diff --git a/src/lib/Home/Root.svelte b/src/lib/Home/Root.svelte index d65a9832..bc1bdea9 100644 --- a/src/lib/Home/Root.svelte +++ b/src/lib/Home/Root.svelte @@ -1,26 +1,26 @@ <script lang="ts"> - import settings from '$stores/settings'; - import { fly } from 'svelte/transition'; + import settings from '$stores/settings'; + import { fly } from 'svelte/transition'; - export let data: any; - export let way: number; + export let data: any; + export let way: number; - const animationDelay = 100; + const animationDelay = 100; </script> {#if $settings.displayDisableAnimations} - <slot /> + <slot /> {:else} - {#key data.url} - <div - in:fly={{ - x: way, - duration: animationDelay, - delay: animationDelay - }} - out:fly={{ x: -way, duration: animationDelay }} - > - <slot /> - </div> - {/key} + {#key data.url} + <div + in:fly={{ + x: way, + duration: animationDelay, + delay: animationDelay + }} + out:fly={{ x: -way, duration: animationDelay }} + > + <slot /> + </div> + {/key} {/if} |