From 43336c04b4c646699ca004acdda6638bb7b3d241 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 24 Dec 2023 03:05:43 -0800 Subject: refactor(tools): activity history to module --- src/lib/Tools/ActivityHistory.svelte | 117 ------------------------------ src/lib/Tools/ActivityHistory/Grid.svelte | 87 ++++++++++++++++++++++ src/lib/Tools/ActivityHistory/Tool.svelte | 117 ++++++++++++++++++++++++++++++ src/lib/Tools/ActivityHistoryGrid.svelte | 87 ---------------------- src/lib/Tools/Wrapped.svelte | 2 +- src/routes/tools/+page.svelte | 2 +- 6 files changed, 206 insertions(+), 206 deletions(-) delete mode 100644 src/lib/Tools/ActivityHistory.svelte create mode 100644 src/lib/Tools/ActivityHistory/Grid.svelte create mode 100644 src/lib/Tools/ActivityHistory/Tool.svelte delete mode 100644 src/lib/Tools/ActivityHistoryGrid.svelte (limited to 'src') diff --git a/src/lib/Tools/ActivityHistory.svelte b/src/lib/Tools/ActivityHistory.svelte deleted file mode 100644 index 811241fa..00000000 --- a/src/lib/Tools/ActivityHistory.svelte +++ /dev/null @@ -1,117 +0,0 @@ - - -{#if user === undefined} - Please log in to view this page. -{:else} - {#await activityHistoryData} - Loading activity history ... 33% - {:then activities} - {#if activities === undefined} - Loading activities ... 66% - {:else} - {@const filledActivities = fillMissingDays(activities)} - - - -

- -

- - {#if generated} -

- {/if} - -

Generate grid image

- -
- - Days in risk of developing an activity history hole. (days with one activity) - - -
    - {#each filledActivities as activity} - {#if activity.amount === 0} -
  • - {new Date( - activity.date * 1000 + new Date().getTimezoneOffset() * 60 * 1000 - ).toDateString()} -
  • - {/if} - {/each} -
-
- {/if} - {/await} -{/if} diff --git a/src/lib/Tools/ActivityHistory/Grid.svelte b/src/lib/Tools/ActivityHistory/Grid.svelte new file mode 100644 index 00000000..a53c1c90 --- /dev/null +++ b/src/lib/Tools/ActivityHistory/Grid.svelte @@ -0,0 +1,87 @@ + + +{#if user === undefined} + Please log in to view this page. +{:else if activityHistoryData === undefined} + Loading activity history ... 50% +{:else} + {@const filledActivities = fillMissingDays(activityHistoryData)} + {@const highestActivity = Math.max(...filledActivities.map((activity) => activity.amount))} + +
+ {#each filledActivities as activity} +
(baseHue = Math.floor(Math.random() * 360))} + on:keydown={() => { + return; + }} + role="button" + tabindex="0" + title={`Date: ${new Date(activity.date * 1000).toLocaleDateString()}\nAmount: ${ + activity.amount + }`} + /> + {/each} +
+{/if} + + diff --git a/src/lib/Tools/ActivityHistory/Tool.svelte b/src/lib/Tools/ActivityHistory/Tool.svelte new file mode 100644 index 00000000..f60774ee --- /dev/null +++ b/src/lib/Tools/ActivityHistory/Tool.svelte @@ -0,0 +1,117 @@ + + +{#if user === undefined} + Please log in to view this page. +{:else} + {#await activityHistoryData} + Loading activity history ... 33% + {:then activities} + {#if activities === undefined} + Loading activities ... 66% + {:else} + {@const filledActivities = fillMissingDays(activities)} + + + +

+ +

+ + {#if generated} +

+ {/if} + +

Generate grid image

+ +
+ + Days in risk of developing an activity history hole. (days with one activity) + + +
    + {#each filledActivities as activity} + {#if activity.amount === 0} +
  • + {new Date( + activity.date * 1000 + new Date().getTimezoneOffset() * 60 * 1000 + ).toDateString()} +
  • + {/if} + {/each} +
+
+ {/if} + {/await} +{/if} diff --git a/src/lib/Tools/ActivityHistoryGrid.svelte b/src/lib/Tools/ActivityHistoryGrid.svelte deleted file mode 100644 index 5cc48d30..00000000 --- a/src/lib/Tools/ActivityHistoryGrid.svelte +++ /dev/null @@ -1,87 +0,0 @@ - - -{#if user === undefined} - Please log in to view this page. -{:else if activityHistoryData === undefined} - Loading activity history ... 50% -{:else} - {@const filledActivities = fillMissingDays(activityHistoryData)} - {@const highestActivity = Math.max(...filledActivities.map((activity) => activity.amount))} - -
- {#each filledActivities as activity} -
(baseHue = Math.floor(Math.random() * 360))} - on:keydown={() => { - return; - }} - role="button" - tabindex="0" - title={`Date: ${new Date(activity.date * 1000).toLocaleDateString()}\nAmount: ${ - activity.amount - }`} - /> - {/each} -
-{/if} - - diff --git a/src/lib/Tools/Wrapped.svelte b/src/lib/Tools/Wrapped.svelte index 24d598f7..28749d26 100644 --- a/src/lib/Tools/Wrapped.svelte +++ b/src/lib/Tools/Wrapped.svelte @@ -22,7 +22,7 @@ import { nbsp } from '../Utility/html'; import { env } from '$env/dynamic/public'; import { estimatedDayReading } from '$lib/Media/Manga/time'; - import ActivityHistoryGrid from './ActivityHistoryGrid.svelte'; + import ActivityHistoryGrid from './ActivityHistory/Grid.svelte'; import SettingHint from '$lib/Settings/SettingHint.svelte'; import { database } from '$lib/Database/activities'; diff --git a/src/routes/tools/+page.svelte b/src/routes/tools/+page.svelte index ad9df7e6..47d18491 100644 --- a/src/routes/tools/+page.svelte +++ b/src/routes/tools/+page.svelte @@ -1,5 +1,5 @@