diff options
Diffstat (limited to 'src/state/shell/logged-out.tsx')
-rw-r--r-- | src/state/shell/logged-out.tsx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/state/shell/logged-out.tsx b/src/state/shell/logged-out.tsx new file mode 100644 index 000000000..19eaee76b --- /dev/null +++ b/src/state/shell/logged-out.tsx @@ -0,0 +1,37 @@ +import React from 'react' + +type StateContext = { + showLoggedOut: boolean +} + +const StateContext = React.createContext<StateContext>({ + showLoggedOut: false, +}) +const ControlsContext = React.createContext<{ + setShowLoggedOut: (show: boolean) => void +}>({ + setShowLoggedOut: () => {}, +}) + +export function Provider({children}: React.PropsWithChildren<{}>) { + const [showLoggedOut, setShowLoggedOut] = React.useState(false) + + const state = React.useMemo(() => ({showLoggedOut}), [showLoggedOut]) + const controls = React.useMemo(() => ({setShowLoggedOut}), [setShowLoggedOut]) + + return ( + <StateContext.Provider value={state}> + <ControlsContext.Provider value={controls}> + {children} + </ControlsContext.Provider> + </StateContext.Provider> + ) +} + +export function useLoggedOutView() { + return React.useContext(StateContext) +} + +export function useLoggedOutViewControls() { + return React.useContext(ControlsContext) +} |