diff --git a/docs/admin-guide.md b/docs/admin-guide.md index a7022a1..f580bcc 100644 --- a/docs/admin-guide.md +++ b/docs/admin-guide.md @@ -42,7 +42,7 @@ Open **Calendar settings**, go to **Texts**, switch to `fr` or `en` and type. A ### Hide the calendar, change the year or the hour -Under **Behaviour**: **Visible** starts unticked, so visitors get a holding page until you tick it and save; you stay able to see everything either way. **Year** and **Opens at hour** (Paris time) decide when each door opens. **After 24 December** chooses between keeping every door open and showing the holding page. +Under **Behaviour**: **Visible** is ticked: the calendar opens to visitors by itself at midnight (Paris time) on 1 December of the **Year**, and a button on the home page links to it from 1 to 24 December. Before 1 December visitors get a holding page whatever the box says. Untick it and save to take the calendar down (visitors get the holding page); tick it again to bring it back. You stay able to see everything either way. **Year** and **Opens at hour** (Paris time) decide when each door opens. **After 24 December** chooses between keeping every door open and showing the holding page. ### Check the preview diff --git a/src/app/(frontend)/_components/CalendarButton.tsx b/src/app/(frontend)/_components/CalendarButton.tsx new file mode 100644 index 0000000..cc77754 --- /dev/null +++ b/src/app/(frontend)/_components/CalendarButton.tsx @@ -0,0 +1,34 @@ +"use client"; + +import Link from "next/link"; +import { useSyncExternalStore } from "react"; +import { useLanguage } from "@/context/LanguageContext"; +import { defaultYear } from "@/lib/calendar/defaults"; +import { getCalendarDay } from "@/lib/calendar/schedule"; + +const subscribe = () => () => {}; + +const isCalendarSeason = () => { + const { today, ended } = getCalendarDay(new Date(), { + year: defaultYear, + opensAtHour: 0, + }); + return today > 0 && !ended; +}; + +/** Shown from 1 to 24 December, Paris time. Checked in the browser so the home page stays static. */ +export default function CalendarButton() { + const { isFrench } = useLanguage(); + const inSeason = useSyncExternalStore(subscribe, isCalendarSeason, () => false); + + if (!inSeason) return null; + + return ( + + {isFrench ? "Le calendrier de l’Avent" : "The advent calendar"} + + ); +} diff --git a/src/app/(frontend)/_components/HomeClient.tsx b/src/app/(frontend)/_components/HomeClient.tsx index c43e85c..3bea2ce 100644 --- a/src/app/(frontend)/_components/HomeClient.tsx +++ b/src/app/(frontend)/_components/HomeClient.tsx @@ -5,6 +5,7 @@ import { useLanguage } from "@/context/LanguageContext"; import { FaVolumeMute, FaVolumeUp, FaPause, FaPlay } from "react-icons/fa"; import dynamic from "next/dynamic"; import Image from "next/image"; +import CalendarButton from "./CalendarButton"; import StaticLogo from "./StaticLogo"; import useHlsVideo, { HLS_SRC, HLS_TYPE } from "./useHlsVideo"; import useIsMounted from "@/utils/useIsMounted"; @@ -116,6 +117,8 @@ export default function HomeClient() { + + {/* Video controls */}