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

Move useStatePostcard to components/postcard/storage

This commit is contained in:
Steffo 2022-07-17 03:33:55 +02:00
parent 6829c7911a
commit 579ec8b5a1
Signed by: steffo
GPG key ID: 6965406171929D01
2 changed files with 17 additions and 16 deletions

View file

@ -40,19 +40,3 @@ export type PostcardContextContents = {
* Context containing data about the website's current postcard, the blurred background image. * Context containing data about the website's current postcard, the blurred background image.
*/ */
export const PostcardContext = createDefinedContext<PostcardContextContents>() export const PostcardContext = createDefinedContext<PostcardContextContents>()
/**
* Hook holding as state the {@link PostcardContextContents}.
*/
export function useStatePostcard(defaultPostcard: PostcardSource) {
const [src, setSrc] = useState<PostcardSource>(defaultPostcard);
const [visibility, setVisibility] = useState<PostcardVisibility>(PostcardVisibility.BACKGROUND);
return {
src,
setSrc,
visibility,
setVisibility,
};
}

View file

@ -0,0 +1,17 @@
import { useState } from "react";
import { PostcardSource, PostcardVisibility } from "./base";
/**
* Hook holding as state the {@link PostcardContextContents}.
*/
export function useStatePostcard(defaultPostcard: PostcardSource) {
const [src, setSrc] = useState<PostcardSource>(defaultPostcard);
const [visibility, setVisibility] = useState<PostcardVisibility>(PostcardVisibility.BACKGROUND);
return {
src,
setSrc,
visibility,
setVisibility,
};
}