From 3c597158c8b1f30b726564468b99ed2db57ae4ab Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 17 Jul 2022 02:58:53 +0200 Subject: [PATCH] Move useStatePostcard to components/postcard/base --- components/postcard/base.ts | 14 ++++++++++++++ components/postcard/storage.ts | 17 ----------------- 2 files changed, 14 insertions(+), 17 deletions(-) delete mode 100644 components/postcard/storage.ts diff --git a/components/postcard/base.ts b/components/postcard/base.ts index 70bd414..2f844fd 100644 --- a/components/postcard/base.ts +++ b/components/postcard/base.ts @@ -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() +/** + * Hook holding as state the {@link PostcardContextContents}. + */ +export function useStatePostcard(defaultPostcard: PostcardSource) { + const [src, setSrc] = useState(defaultPostcard); + const [visibility, setVisibility] = useState(PostcardVisibility.BACKGROUND); + return { + src, + setSrc, + visibility, + setVisibility, + }; +} diff --git a/components/postcard/storage.ts b/components/postcard/storage.ts deleted file mode 100644 index c1e792e..0000000 --- a/components/postcard/storage.ts +++ /dev/null @@ -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(defaultPostcard); - const [visibility, setVisibility] = useState(PostcardVisibility.BACKGROUND); - - return { - src, - setSrc, - visibility, - setVisibility, - }; -}