From 579ec8b5a1f80c8cfb352f5514ce0e2845af013a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 17 Jul 2022 03:33:55 +0200 Subject: [PATCH] Move `useStatePostcard` to `components/postcard/storage` --- components/postcard/base.ts | 16 ---------------- components/postcard/storage.ts | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 components/postcard/storage.ts diff --git a/components/postcard/base.ts b/components/postcard/base.ts index 2f844fd..35ac24c 100644 --- a/components/postcard/base.ts +++ b/components/postcard/base.ts @@ -40,19 +40,3 @@ export type PostcardContextContents = { * Context containing data about the website's current postcard, the blurred background image. */ 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 new file mode 100644 index 0000000..c1e792e --- /dev/null +++ b/components/postcard/storage.ts @@ -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(defaultPostcard); + const [visibility, setVisibility] = useState(PostcardVisibility.BACKGROUND); + + return { + src, + setSrc, + visibility, + setVisibility, + }; +}