Skip to content

Commit 7ebc67a

Browse files
authored
Merge pull request #298 from SkyCryptWebsite/dev
2 parents 964839f + 9e38b44 commit 7ebc67a

8 files changed

Lines changed: 126 additions & 4 deletions

File tree

.changeset/pre.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"mode": "pre",
3+
"tag": "beta",
4+
"initialVersions": {
5+
"skycrypt-frontend": "3.3.2"
6+
},
7+
"changesets": [
8+
"warm-cooks-reply"
9+
]
10+
}

.changeset/warm-cooks-reply.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"skycrypt-frontend": patch
3+
---
4+
5+
feat: add internal preferences context and survey notice component

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 3.3.3-beta.0
4+
5+
### Patch Changes
6+
7+
- feat: add internal preferences context and survey notice component ([`b2e30ca`](https://github.com/SkyCryptWebsite/SkyCrypt-Frontend/commit/b2e30ca5fab61fb2eb6c7cba602b61d3476821e2))
8+
39
## 3.3.2
410

511
### Patch Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "skycrypt-frontend",
3-
"version": "3.3.2",
3+
"version": "3.3.3-beta.0",
44
"private": true,
55
"type": "module",
66
"repository": {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { PersistedState } from "runed";
2+
import { createContext } from "svelte";
3+
4+
interface InternalPreferencesData {
5+
skycryptSurvey: {
6+
dismissedAt: Date | null;
7+
confirmedAt: Date | null;
8+
surveyVersion: number;
9+
surveyName: string;
10+
};
11+
}
12+
13+
export class InternalPreferencesContext {
14+
#data = new PersistedState<InternalPreferencesData>("skycryptInternalPreferences", {
15+
skycryptSurvey: {
16+
dismissedAt: null,
17+
confirmedAt: null,
18+
surveyVersion: 0,
19+
surveyName: ""
20+
}
21+
});
22+
23+
get skycryptSurvey() {
24+
return this.#data.current.skycryptSurvey;
25+
}
26+
27+
set skycryptSurvey(value: InternalPreferencesData["skycryptSurvey"]) {
28+
this.#data.current = { ...this.#data.current, skycryptSurvey: value };
29+
}
30+
}
31+
32+
const [getInternalPreferences, setInternalPreferences] = createContext<InternalPreferencesContext>();
33+
34+
function initInternalPreferences() {
35+
const preferences = new InternalPreferencesContext();
36+
setInternalPreferences(preferences);
37+
return preferences;
38+
}
39+
40+
export { getInternalPreferences, initInternalPreferences };
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<script lang="ts">
2+
import { getInternalPreferences } from "$ctx/internal-preferences.svelte";
3+
import { Button } from "bits-ui";
4+
import { toast } from "svelte-sonner";
5+
6+
const internalPreferences = getInternalPreferences();
7+
8+
function dissmissFn() {
9+
toast.dismiss("survey-notice");
10+
toast.info("You can find the survey on the home page if you change your mind.", { position: "bottom-center" });
11+
internalPreferences.skycryptSurvey.dismissedAt = new Date();
12+
}
13+
14+
function actionFn() {
15+
window.open("https://forms.gle/wUSHhr8EACviaQVq8", "_blank");
16+
toast.dismiss("survey-notice");
17+
toast.success("Thank you for taking the time to fill out our survey!", { position: "bottom-center" });
18+
internalPreferences.skycryptSurvey.confirmedAt = new Date();
19+
}
20+
21+
$effect(() => {
22+
if (!internalPreferences.skycryptSurvey.surveyName) internalPreferences.skycryptSurvey.surveyName = "general-survey-2026-03-18";
23+
if (!internalPreferences.skycryptSurvey.surveyVersion) internalPreferences.skycryptSurvey.surveyVersion = new Date("2026-03-18").getTime();
24+
});
25+
</script>
26+
27+
<div class="p-4 text-text">
28+
<h2 class="text-lg font-bold">SkyCrypt Survey</h2>
29+
<p class="mt-2 text-sm">Please take a moment to fill out our survey and let us know what you think.</p>
30+
31+
<p class="mt-2 text-sm">Your feedback is actually really helpful in improving the site.</p>
32+
<Button.Root onclick={actionFn} class="mt-4 inline-flex items-center rounded bg-skillbar px-4 py-2 text-sm font-medium text-text text-shadow-sm hover:bg-hover">Take the Survey</Button.Root>
33+
34+
<Button.Root onclick={dissmissFn} class="mt-4 inline-flex items-center rounded px-4 py-2 text-sm font-medium text-text text-shadow-sm hover:bg-text/30">Dismiss</Button.Root>
35+
</div>

src/routes/+layout.svelte

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { beforeNavigate, replaceState } from "$app/navigation";
44
import { page, updated } from "$app/state";
55
import { initDisabledPacks, initFavorites, initInternalState, initPreferences, initRecentSearches, initTheme, initWikiOrder, PacksContext, setHoverContext, setMobileContext, setPacksContext } from "$ctx";
6+
import { initInternalPreferences } from "$ctx/internal-preferences.svelte";
67
import Header from "$lib/components/header/Header.svelte";
78
import { CommandPalette, PerformanceMode } from "$lib/components/misc";
89
import ThemeEditor from "$lib/components/theme-editor/ThemeEditor.svelte";
@@ -11,9 +12,11 @@
1112
import { getPacks } from "$lib/shared/api/skycrypt-api.remote";
1213
import { parseThemeFromURL } from "$lib/shared/themes/sharing";
1314
import { cn } from "$lib/shared/utils";
15+
import SurveyNotice from "$src/lib/components/notices/SurveyNotice.svelte";
1416
import Wifi from "@lucide/svelte/icons/wifi";
1517
import WifiOff from "@lucide/svelte/icons/wifi-off";
1618
import { Tooltip } from "bits-ui";
19+
import { differenceInHours } from "date-fns";
1720
import { onMount, type Snippet } from "svelte";
1821
import SvelteSeo from "svelte-seo";
1922
import { toast, Toaster, type ToasterProps } from "svelte-sonner";
@@ -30,6 +33,7 @@
3033
let commandLoading = $state(false);
3134
const { ign } = $derived(page.params);
3235
const preferences = initPreferences();
36+
const internalPreferences = initInternalPreferences();
3337
const themeContext = initTheme();
3438
const internalState = initInternalState();
3539
const position = writable<ToasterProps["position"]>("bottom-right");
@@ -163,6 +167,28 @@
163167
164168
if (packsData) packs.packs = packsData;
165169
});
170+
171+
// TODO: Remove after the survey is done
172+
$effect(() => {
173+
const surveyPrefs = internalPreferences?.skycryptSurvey;
174+
if (!surveyPrefs) return;
175+
176+
const dismissedAt = surveyPrefs.dismissedAt ? new Date(surveyPrefs.dismissedAt) : null;
177+
const confirmedAt = surveyPrefs.confirmedAt ? new Date(surveyPrefs.confirmedAt) : null;
178+
const now = new Date();
179+
180+
const isDismissedExpired = dismissedAt == null || differenceInHours(now, dismissedAt) > 12;
181+
const isConfirmedExpired = confirmedAt == null || differenceInHours(now, confirmedAt) > 12;
182+
183+
if (isDismissedExpired && isConfirmedExpired) {
184+
toast.custom(SurveyNotice, {
185+
id: "survey-notice",
186+
important: true,
187+
duration: Number.POSITIVE_INFINITY,
188+
position: "bottom-center"
189+
});
190+
}
191+
});
166192
</script>
167193

168194
<svelte:document onkeydown={handleKeydown} />

src/routes/+page.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@
6565
}
6666
},
6767
{
68-
href: "https://forms.gle/2Jfbs9tjm76Rihfe8",
68+
href: "https://forms.gle/wUSHhr8EACviaQVq8",
6969
text: {
70-
title: "Skyblock Texture Pack Survey",
71-
description: "Updating SkyCrypt to prioritize most used texture packs"
70+
title: "Skyblock General Survey",
71+
description: "Let us know what you think about the site and what features you'd like to see in the future"
7272
},
7373
img: {
7474
src: "/img/icons/google-forms.svg",

0 commit comments

Comments
 (0)