feat(theme): add halloween special theme

This commit is contained in:
Tommaso Casaburi
2026-05-29 17:45:18 +07:00
parent e082c7b428
commit 0469f61a45
14 changed files with 301 additions and 35 deletions
@@ -104,7 +104,7 @@ describe('persisted extra stores', () => {
expect(useModQueueStore.getState().getAlertThresholdSeconds()).toBe(900);
});
it('blocks special theme enablement outside christmas and clears persisted enabled state on rehydrate', async () => {
it('blocks special theme enablement outside active special dates and clears persisted enabled state on rehydrate', async () => {
localStorage.setItem(
'Special-theme-storage',
JSON.stringify({
@@ -121,12 +121,20 @@ describe('persisted extra stores', () => {
expect(useSpecialThemeStore.getState().isEnabled).toBeNull();
});
it('allows opting into the special theme during christmas', async () => {
it('allows opting into the special theme during christmas and halloween', async () => {
const useSpecialThemeStore = await loadSpecialThemeStore('2024-12-24T00:00:00Z');
expect(useSpecialThemeStore.getState().isEnabled).toBeNull();
useSpecialThemeStore.getState().setIsEnabled(true);
expect(useSpecialThemeStore.getState().isEnabled).toBe(true);
localStorage.clear();
const useHalloweenSpecialThemeStore = await loadSpecialThemeStore('2024-10-31T00:00:00Z');
expect(useHalloweenSpecialThemeStore.getState().isEnabled).toBeNull();
useHalloweenSpecialThemeStore.getState().setIsEnabled(true);
expect(useHalloweenSpecialThemeStore.getState().isEnabled).toBe(true);
});
});
+3 -3
View File
@@ -1,6 +1,6 @@
import { create } from 'zustand';
import { persist } from 'zustand/middleware';
import { isChristmas } from '../lib/utils/time-utils';
import { getActiveSpecialTheme } from '../lib/utils/time-utils';
interface SpecialThemeStore {
isEnabled: boolean | null;
@@ -12,7 +12,7 @@ const useSpecialThemeStore = create(
(set) => ({
isEnabled: null,
setIsEnabled: (value: boolean) => {
if (value && !isChristmas()) {
if (value && !getActiveSpecialTheme()) {
return;
}
set({ isEnabled: value });
@@ -22,7 +22,7 @@ const useSpecialThemeStore = create(
name: 'Special-theme-storage',
onRehydrateStorage: () => {
return (state) => {
if (state && !isChristmas()) {
if (state && !getActiveSpecialTheme()) {
state.isEnabled = null;
}
};