aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-04-01 17:33:05 -0700
committerFuwn <[email protected]>2024-04-01 17:33:05 -0700
commitf4d25ee1275d4783933ec173a5bc60b99181d855 (patch)
treeb1e9bc225cef7b12dc70c1de91e5e189e9060787 /src/lib
parentfeat(sequelspy): show days instead of weeks for long (diff)
downloaddue.moe-f4d25ee1275d4783933ec173a5bc60b99181d855.tar.xz
due.moe-f4d25ee1275d4783933ec173a5bc60b99181d855.zip
feat(layout): announcement feature
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Announcement.svelte33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/lib/Announcement.svelte b/src/lib/Announcement.svelte
new file mode 100644
index 00000000..13e5622a
--- /dev/null
+++ b/src/lib/Announcement.svelte
@@ -0,0 +1,33 @@
+<script lang="ts">
+ import Popup from './Popup.svelte';
+ import announcementHash from '$stores/announcementHash';
+ import { env } from '$env/dynamic/public';
+
+ const announcement = env.PUBLIC_ANNOUNCEMENT;
+ const dismissButton = env.PUBLIC_ANNOUNCEMENT_DISMISS;
+
+ const hash = (s: string) =>
+ s
+ .split('')
+ .reduce((previous, current) => ((previous << 5) - previous + current.charCodeAt(0)) | 0, 0);
+
+ const dismiss = () => {
+ if (announcement) announcementHash.set(hash(announcement));
+ };
+</script>
+
+{#if announcement && $announcementHash !== hash(announcement) && $announcementHash !== 0}
+ <Popup fullscreen onLeave={dismiss}>
+ {announcement}
+
+ <p />
+
+ <button on:click={dismiss} class="dismiss">{dismissButton || 'Dismiss'}</button>
+ </Popup>
+{/if}
+
+<style>
+ .dismiss {
+ float: right;
+ }
+</style>