From 0308755aee6c9feeb440e8df01e6c82c901e1f75 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 21 Jul 2022 00:13:46 +0200 Subject: [PATCH] Create PageDebugPostcard --- .../postcard/toolbar/toolToggleVisibility.tsx | 6 +- pages/debug/postcard.tsx | 67 +++++++++++++++++++ public/locales/it-IT/common.json | 4 +- 3 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 pages/debug/postcard.tsx diff --git a/components/postcard/toolbar/toolToggleVisibility.tsx b/components/postcard/toolbar/toolToggleVisibility.tsx index 955c190..e49bbfb 100644 --- a/components/postcard/toolbar/toolToggleVisibility.tsx +++ b/components/postcard/toolbar/toolToggleVisibility.tsx @@ -11,13 +11,13 @@ import { PostcardContext, PostcardVisibility } from "../base" */ export function ToolToggleVisibility() { const { t } = useTranslation() - const { visibility, setVisibility } = useDefinedContext(PostcardContext) + const { visibility, changeVisibility } = useDefinedContext(PostcardContext) if (visibility === PostcardVisibility.BACKGROUND) { return ( setVisibility(PostcardVisibility.FOREGROUND)} + onClick={() => changeVisibility(PostcardVisibility.FOREGROUND)} > @@ -27,7 +27,7 @@ export function ToolToggleVisibility() { return ( setVisibility(PostcardVisibility.BACKGROUND)} + onClick={() => changeVisibility(PostcardVisibility.BACKGROUND)} > diff --git a/pages/debug/postcard.tsx b/pages/debug/postcard.tsx new file mode 100644 index 0000000..531c3b3 --- /dev/null +++ b/pages/debug/postcard.tsx @@ -0,0 +1,67 @@ +import { NextPage, NextPageContext } from "next"; +import { useTranslation } from "next-i18next"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; +import { StaticImageData } from "next/image"; +import { useState } from "react"; +import { ToolBar } from "../../components/generic/toolbar/bar"; +import { ViewNotice } from "../../components/generic/views/notice"; +import { PostcardSource } from "../../components/postcard/base"; +import { Postcard } from "../../components/postcard/changer"; +import { ToolToggleVisibility } from "../../components/postcard/toolbar/toolToggleVisibility"; +import debugPostcard from "../../public/postcards/markus-spiske-iar-afB0QQw-unsplash.jpg" + + +export async function getStaticProps(context: NextPageContext) { + return { + props: { + ...(await serverSideTranslations(context.locale ?? "it-IT", ["common"])) + } + } +} + + +// All images from https://www.reddit.com/r/hmmm/ +const possiblePostcards: (PostcardSource | StaticImageData)[] = [ + "https://i.imgur.com/tpC5y1N.png", + "https://i.imgur.com/sKdbsC5.jpg", + "https://i.redd.it/nx2usi3gssf21.jpg", + "https://i.redd.it/oy0ve07w6wgz.jpg", + "https://i.redd.it/b3do0thb66581.jpg", + "https://i.redd.it/w5ed0yk2s9l21.png", + "https://i.redd.it/pqnbvrc8och41.jpg", + "https://i.redd.it/x3dqd57hdyx31.jpg", + "https://i.redd.it/zo46srrm7xe21.png", +] + + +const PageDebugPostcard: NextPage = (props) => { + const { t } = useTranslation() + const [postcard, setPostcard] = useState(debugPostcard) + + return <> + + + + + +

+ {t("debugPostcardText")} +

+ + } + /> + +} + + +export default PageDebugPostcard diff --git a/public/locales/it-IT/common.json b/public/locales/it-IT/common.json index 1e22412..1f0e7ca 100644 --- a/public/locales/it-IT/common.json +++ b/public/locales/it-IT/common.json @@ -24,5 +24,7 @@ "eventLoading": "Caricamento dei dettagli dell'evento in corso...", "eventError": "Si è verificato il seguente errore nel recupero dei dettagli dell'evento:", "debugLoading": "Questo è un esempio di caricamento full-page.", - "debugError": "Questo è un esempio di errore full-page." + "debugError": "Questo è un esempio di errore full-page.", + "debugPostcardText": "Questo è un esempio di transizione nello sfondo.", + "debugPostcardButton": "Hmmm." } \ No newline at end of file