mirror of
https://github.com/Steffo99/festa.git
synced 2024-12-22 14:44:21 +00:00
Move useStatePostcard
to components/postcard/storage
This commit is contained in:
parent
6829c7911a
commit
579ec8b5a1
2 changed files with 17 additions and 16 deletions
|
@ -40,19 +40,3 @@ export type PostcardContextContents = {
|
|||
* Context containing data about the website's current postcard, the blurred background image.
|
||||
*/
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
|
17
components/postcard/storage.ts
Normal file
17
components/postcard/storage.ts
Normal 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,
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue