feat: seasonal features
This commit is contained in:
parent
ab50afe917
commit
c4bbafb9d7
@ -1,5 +1,6 @@
|
||||
.logo {
|
||||
cursor: pointer;
|
||||
text-wrap: nowrap;
|
||||
}
|
||||
|
||||
.logo h1 {
|
||||
|
@ -12,7 +12,7 @@ import useLoginFeed from "Feed/LoginFeed";
|
||||
import { mapPlanName } from "./subscribe";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import Avatar from "Element/User/Avatar";
|
||||
import { isFormElement } from "SnortUtils";
|
||||
import { isHalloween, isFormElement, isStPatricksDay, isChristmas } from "SnortUtils";
|
||||
import { getCurrentSubscription } from "Subscription";
|
||||
import Toaster from "Toaster";
|
||||
import Spinner from "Icons/Spinner";
|
||||
@ -204,9 +204,15 @@ function LogoHeader() {
|
||||
const { subscriptions } = useLogin();
|
||||
const currentSubscription = getCurrentSubscription(subscriptions);
|
||||
|
||||
const extra = () => {
|
||||
if (isHalloween()) return "🎃";
|
||||
if (isStPatricksDay()) return "🍀";
|
||||
if (isChristmas()) return "🎄";
|
||||
}
|
||||
|
||||
return (
|
||||
<Link to="/" className="logo">
|
||||
<h1>{CONFIG.appName}</h1>
|
||||
<h1>{extra()}{CONFIG.appName}</h1>
|
||||
{currentSubscription && (
|
||||
<small className="flex items-center g4">
|
||||
<Icon name="diamond" size={10} />
|
||||
|
@ -15,6 +15,7 @@ import {
|
||||
MetadataCache,
|
||||
NostrLink,
|
||||
} from "@snort/system";
|
||||
import { Day } from "Const";
|
||||
|
||||
export const sha256 = (str: string | Uint8Array): u256 => {
|
||||
return utils.bytesToHex(hash(str));
|
||||
@ -469,7 +470,7 @@ export function kvToObject<T>(o: string, sep?: string) {
|
||||
}
|
||||
|
||||
export function defaultAvatar(input?: string) {
|
||||
return `https://robohash.v0l.io/${input ?? "missing"}.png${IsHalloween() ? "?set=set2" : ""}`;
|
||||
return `https://robohash.v0l.io/${input ?? "missing"}.png${isHalloween() ? "?set=set2" : ""}`;
|
||||
}
|
||||
|
||||
export function isFormElement(target: HTMLElement): boolean {
|
||||
@ -480,7 +481,25 @@ export function isFormElement(target: HTMLElement): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
export const IsHalloween = () => {
|
||||
const ThisYear = new Date().getFullYear();
|
||||
const SeasonalEventsWindow = 7; // n days before
|
||||
const IsTheSeason = (target: Date) => {
|
||||
const now = new Date();
|
||||
return now.getMonth() === 9 && now.getDate() >= 17;
|
||||
const days = (target.getTime() - now.getTime()) / (Day * 1000);
|
||||
return days > 0 && days <= SeasonalEventsWindow;
|
||||
};
|
||||
|
||||
export const isHalloween = () => {
|
||||
const event = new Date(ThisYear, 9, 31);
|
||||
return IsTheSeason(event);
|
||||
};
|
||||
|
||||
export const isStPatricksDay = () => {
|
||||
const event = new Date(ThisYear, 2, 17);
|
||||
return IsTheSeason(event);
|
||||
};
|
||||
|
||||
export const isChristmas = () => {
|
||||
const event = new Date(ThisYear, 11, 25);
|
||||
return IsTheSeason(event);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user