This commit is contained in:
parent
d84843a46d
commit
bbcedbd99c
@ -8,6 +8,11 @@ export const Hour = 60 * 60;
|
|||||||
*/
|
*/
|
||||||
export const Day = Hour * 24;
|
export const Day = Hour * 24;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Day this project started
|
||||||
|
*/
|
||||||
|
export const Birthday = new Date(2022, 11, 17);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add-on api for snort features
|
* Add-on api for snort features
|
||||||
*/
|
*/
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
import useLogin from "../../Hooks/useLogin";
|
import useLogin from "../../Hooks/useLogin";
|
||||||
import { getCurrentSubscription } from "../../Subscription";
|
import { getCurrentSubscription } from "../../Subscription";
|
||||||
import { isChristmas, isHalloween, isStPatricksDay } from "../../SnortUtils";
|
import { isBirthday, isChristmas, isHalloween, isStPatricksDay } from "../../SnortUtils";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { mapPlanName } from "../subscribe";
|
import { mapPlanName } from "../subscribe";
|
||||||
import Icon from "@/Icons/Icon";
|
import Icon from "@/Icons/Icon";
|
||||||
|
import { unixNowMs } from "@snort/shared";
|
||||||
|
import { Birthday, Day } from "@/Const";
|
||||||
export function LogoHeader({ showText = false }) {
|
export function LogoHeader({ showText = false }) {
|
||||||
const { subscriptions } = useLogin();
|
const { subscriptions } = useLogin();
|
||||||
const currentSubscription = getCurrentSubscription(subscriptions);
|
const currentSubscription = getCurrentSubscription(subscriptions);
|
||||||
|
|
||||||
const extra = () => {
|
const extra = () => {
|
||||||
|
if (isBirthday()) {
|
||||||
|
const age = (unixNowMs() - Birthday.getTime()) / (Day * 365_000);
|
||||||
|
return <span className="text-xs">{age.toFixed(0)}st 🎂</span>;
|
||||||
|
}
|
||||||
if (isHalloween()) return "🎃";
|
if (isHalloween()) return "🎃";
|
||||||
if (isStPatricksDay()) return "🍀";
|
if (isStPatricksDay()) return "🍀";
|
||||||
if (isChristmas()) return "🎄";
|
if (isChristmas()) return "🎄";
|
||||||
@ -29,8 +35,8 @@ export function LogoHeader({ showText = false }) {
|
|||||||
)}
|
)}
|
||||||
{showText && (
|
{showText && (
|
||||||
<div className="md:hidden xl:inline ml-2">
|
<div className="md:hidden xl:inline ml-2">
|
||||||
{extra()}
|
|
||||||
{CONFIG.appName}
|
{CONFIG.appName}
|
||||||
|
{extra()}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</h1>
|
</h1>
|
||||||
|
@ -19,7 +19,7 @@ import {
|
|||||||
UserMetadata,
|
UserMetadata,
|
||||||
} from "@snort/system";
|
} from "@snort/system";
|
||||||
import { isHex, isOffline } from "@snort/shared";
|
import { isHex, isOffline } from "@snort/shared";
|
||||||
import { Day } from "@/Const";
|
import { Birthday, Day } from "@/Const";
|
||||||
import AnimalName from "@/Element/User/AnimalName";
|
import AnimalName from "@/Element/User/AnimalName";
|
||||||
|
|
||||||
export const sha256 = (str: string | Uint8Array): u256 => {
|
export const sha256 = (str: string | Uint8Array): u256 => {
|
||||||
@ -472,26 +472,30 @@ export function isFormElement(target: HTMLElement): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ThisYear = new Date().getFullYear();
|
const ThisYear = new Date().getFullYear();
|
||||||
const SeasonalEventsWindow = 7; // n days before
|
const IsTheSeason = (target: Date, window: number) => {
|
||||||
const IsTheSeason = (target: Date) => {
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const days = (target.getTime() - now.getTime()) / (Day * 1000);
|
const days = (target.getTime() - now.getTime()) / (Day * 1000);
|
||||||
return days > 0 && days <= SeasonalEventsWindow;
|
return (days >= 0 && days <= window) || (now.getDate() === target.getDate() && now.getMonth() === target.getMonth());
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isHalloween = () => {
|
export const isHalloween = () => {
|
||||||
const event = new Date(ThisYear, 9, 31);
|
const event = new Date(ThisYear, 9, 31);
|
||||||
return IsTheSeason(event);
|
return IsTheSeason(event, 7);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isStPatricksDay = () => {
|
export const isStPatricksDay = () => {
|
||||||
const event = new Date(ThisYear, 2, 17);
|
const event = new Date(ThisYear, 2, 17);
|
||||||
return IsTheSeason(event);
|
return IsTheSeason(event, 7);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isChristmas = () => {
|
export const isChristmas = () => {
|
||||||
const event = new Date(ThisYear, 11, 25);
|
const event = new Date(ThisYear, 11, 25);
|
||||||
return IsTheSeason(event);
|
return IsTheSeason(event, 30);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const isBirthday = () => {
|
||||||
|
const event = new Date(ThisYear, Birthday.getMonth(), Birthday.getDate());
|
||||||
|
return IsTheSeason(event, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getDisplayName(user: UserMetadata | undefined, pubkey: HexKey): string {
|
export function getDisplayName(user: UserMetadata | undefined, pubkey: HexKey): string {
|
||||||
|
Loading…
Reference in New Issue
Block a user