Skip to content

Commit

Permalink
refactor: show snowfall in December and January
Browse files Browse the repository at this point in the history
  • Loading branch information
brandstetterm committed Jan 8, 2025
1 parent 51073ef commit 7fc86af
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/components/SettingsDialog/Appearance/Appearance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const Appearance = () => {
const activeMenuItem: MenuItemConfig = useOutletContext();
const currentMonth = new Date().getMonth();

// Snowfall is enabled only in December and January
const isDecemberOrJanuary = currentMonth === 11 || currentMonth === 0;

return (
<div className={classNames("settings-dialog__container", getColorClassName(activeMenuItem?.color))}>
<header className="settings-dialog__header">
Expand All @@ -25,7 +28,7 @@ export const Appearance = () => {
<div className="appearance-container">
<ThemeSettings />
{/** Since snowfall is only enabled in December, we only show the snowfall settings in December too */}
{currentMonth === 11 && <SnowfallSettings />}
{isDecemberOrJanuary && <SnowfallSettings />}
<NotificationSettings />
<BoardReactionsSettings />
<SkinToneSelector />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,24 @@ exports[`Appearance should render all Settings correctly 1`] = `
</label>
</form>
</div>
<section>
<button
aria-checked="false"
aria-label="Show snowfall"
class="settings-option-button"
role="switch"
type="button"
>
<span
class="settings-option-button__label"
>
Show snowfall
</span>
<div
class="toggle"
/>
</button>
</section>
<section>
<button
aria-checked="true"
Expand Down
16 changes: 10 additions & 6 deletions src/components/SnowfallWrapper/SnowfallWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ export const SnowfallWrapper = () => {
const currentMonth = new Date().getMonth();

useEffect(() => {
// Festive greetings are displayed only once, when the month changes to December
if (currentMonth === 11 && snowfallNotificationEnabled) {
Toast.info({title: t("Snowfall.toastTitle"), message: t("Snowfall.toastMessage")});
}
dispatch(setSnowfallNotification(false));
}, [currentMonth, dispatch, snowfallNotificationEnabled, t]);

return (
<>
{/** Snowfall is only enabled in December */}
{snowfallEnabled && currentMonth === 11 && <Snowfall color="#99bcff" />}
</>
);
// Snowfall is enabled only in December and January
const isDecemberOrJanuary = currentMonth === 11 || currentMonth === 0;

// If snowfall is disabled or it's not December or January, return null
if (!snowfallEnabled || !isDecemberOrJanuary) {
return null;
}

return <Snowfall color="#99bcff" />;
};

0 comments on commit 7fc86af

Please sign in to comment.