1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-12-22 14:44:21 +00:00

Create PageDebugPostcard

This commit is contained in:
Steffo 2022-07-21 00:13:46 +02:00
parent dc69504e08
commit 0308755aee
Signed by: steffo
GPG key ID: 6965406171929D01
3 changed files with 73 additions and 4 deletions

View file

@ -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 (
<Tool
aria-label={t("toggleVisibleShow")}
onClick={() => setVisibility(PostcardVisibility.FOREGROUND)}
onClick={() => changeVisibility(PostcardVisibility.FOREGROUND)}
>
<FestaIcon icon={faEye} />
</Tool>
@ -27,7 +27,7 @@ export function ToolToggleVisibility() {
return (
<Tool
aria-label={t("toggleVisibleHide")}
onClick={() => setVisibility(PostcardVisibility.BACKGROUND)}
onClick={() => changeVisibility(PostcardVisibility.BACKGROUND)}
>
<FestaIcon icon={faEyeSlash} />
</Tool>

67
pages/debug/postcard.tsx Normal file
View file

@ -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<PostcardSource | StaticImageData>(debugPostcard)
return <>
<Postcard
src={postcard}
/>
<ToolBar
vertical="vadapt"
horizontal="right"
>
<ToolToggleVisibility />
</ToolBar>
<ViewNotice
notice={<>
<p>
{t("debugPostcardText")}
</p>
<button onClick={() => {
setPostcard(possiblePostcards[~~(Math.random() * possiblePostcards.length)])
}}>
{t("debugPostcardButton")}
</button>
</>}
/>
</>
}
export default PageDebugPostcard

View file

@ -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."
}