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

Move useStatePostcard to components/postcard/base

This commit is contained in:
Steffo 2022-07-17 02:58:53 +02:00
parent e6e667a1d3
commit 3c597158c8
Signed by: steffo
GPG key ID: 6965406171929D01
2 changed files with 14 additions and 17 deletions

View file

@ -1,4 +1,5 @@
import { ImageProps } from "next/image"
import { useState } from "react";
import { createDefinedContext } from "../../utils/definedContext";
@ -41,4 +42,17 @@ export type 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

@ -1,17 +0,0 @@
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,
};
}