diff --git a/components/postcard/Postcard.tsx b/components/postcard/Postcard.tsx index 4ca2d5c..ff02d03 100644 --- a/components/postcard/Postcard.tsx +++ b/components/postcard/Postcard.tsx @@ -8,7 +8,7 @@ type PostcardProps = { } export function Postcard({src}: PostcardProps) { - const [, setPostcard] = useDefinedContext(PostcardContext) + const {setPostcard} = useDefinedContext(PostcardContext) useEffect( () => { diff --git a/components/postcard/PostcardContext.tsx b/components/postcard/PostcardContext.tsx index 2f894eb..bbfa68f 100644 --- a/components/postcard/PostcardContext.tsx +++ b/components/postcard/PostcardContext.tsx @@ -1,7 +1,15 @@ -import { createStateContext } from "../../utils/stateContext"; +import { createDefinedContext } from "../../utils/definedContext"; + + +export type PostcardContextValue = { + postcard: string, + setPostcard: React.Dispatch>, + visible: boolean, + setVisible: React.Dispatch>, +} /** * Context containing data about the website's current postcard, the blurred background image. */ -export const PostcardContext = createStateContext() +export const PostcardContext = createDefinedContext() diff --git a/components/postcard/PostcardRenderer.tsx b/components/postcard/PostcardRenderer.tsx index 50e66dc..2dc04f2 100644 --- a/components/postcard/PostcardRenderer.tsx +++ b/components/postcard/PostcardRenderer.tsx @@ -1,14 +1,20 @@ import { PostcardContext } from "./PostcardContext" import { useDefinedContext } from "../../utils/definedContext"; +import classNames from "classnames"; export function PostcardRenderer() { - const [postcard,] = useDefinedContext(PostcardContext) + const {postcard, visible} = useDefinedContext(PostcardContext) return <>
} \ No newline at end of file diff --git a/components/tools/ToolToggleVisible.tsx b/components/tools/ToolToggleVisible.tsx new file mode 100644 index 0000000..70c33b3 --- /dev/null +++ b/components/tools/ToolToggleVisible.tsx @@ -0,0 +1,20 @@ +import { faEye, faEyeSlash } from "@fortawesome/free-solid-svg-icons" +import { useTranslation } from "next-i18next" +import { useDefinedContext } from "../../utils/definedContext" +import { FestaIcon } from "../extensions/FestaIcon" +import { PostcardContext } from "../postcard/PostcardContext" + +export function ToolToggleVisible() { + const {t} = useTranslation() + const {visible, setVisible} = useDefinedContext(PostcardContext) + + return ( + + ) +} \ No newline at end of file diff --git a/pages/_app.tsx b/pages/_app.tsx index af49cce..95a6515 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -18,6 +18,7 @@ import { ErrorBoundary } from '../components/errors/ErrorBoundary' const App = ({ Component, pageProps }: AppProps): JSX.Element => { const {t} = useTranslation() const [postcard, setPostcard] = useState(defaultPostcard.src) + const [postcardVisible, setPostcardVisible] = useState(false) const [login, setLogin] = useState(null) useStoredLogin(setLogin) @@ -34,7 +35,7 @@ const App = ({ Component, pageProps }: AppProps): JSX.Element => { return <> - + diff --git a/pages/events/[slug].tsx b/pages/events/[slug].tsx index 31c22a2..dd71f76 100644 --- a/pages/events/[slug].tsx +++ b/pages/events/[slug].tsx @@ -16,6 +16,7 @@ import { EditablePostcard } from "../../components/editable/EditablePostcard"; import { ViewEvent } from "../../components/view/ViewEvent"; import { EditableDateTime } from "../../components/editable/EditableDateTime"; import { FormDateRange } from "../../components/FormDateRange"; +import { ToolToggleVisible } from "../../components/tools/ToolToggleVisible"; export async function getServerSideProps(context: NextPageContext) { @@ -77,6 +78,7 @@ export default function PageEventDetail({event}: PageEventDetailProps) { +