Files
suwayomi-material-you-webui/src/components/context/NavbarContext.tsx

60 lines
1.7 KiB
TypeScript
Raw Normal View History

/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
2021-01-26 23:32:12 +03:30
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
2021-01-26 23:32:12 +03:30
import React, { useContext } from 'react';
import { INavbarOverride } from '@/typings';
2021-01-22 17:00:33 +03:30
type ContextType = {
history: string[];
2021-10-30 16:10:34 +03:30
// AppBar title
title: string | React.ReactNode;
setTitle: (title: ContextType['title'], browserTitle?: string) => void;
2021-10-30 16:10:34 +03:30
2024-07-11 17:22:52 +02:00
appBarHeight: number;
setAppBarHeight: React.Dispatch<React.SetStateAction<number>>;
2021-10-30 16:10:34 +03:30
// AppBar action buttons
action: any;
setAction: React.Dispatch<React.SetStateAction<any>>;
2021-10-30 16:10:34 +03:30
// Allow default navbar to be overrided
override: INavbarOverride;
setOverride: React.Dispatch<React.SetStateAction<INavbarOverride>>;
2024-07-11 17:22:52 +02:00
// NavBar
isCollapsed: boolean;
setIsCollapsed: React.Dispatch<React.SetStateAction<boolean>>;
navBarWidth: number;
setNavBarWidth: React.Dispatch<React.SetStateAction<number>>;
bottomBarHeight: number;
setBottomBarHeight: React.Dispatch<React.SetStateAction<number>>;
2021-01-22 17:00:33 +03:30
};
2023-10-28 00:32:02 +02:00
export const NavBarContext = React.createContext<ContextType>({
history: [],
title: 'Suwayomi',
setTitle: (): void => {},
2024-07-11 17:22:52 +02:00
appBarHeight: 0,
setAppBarHeight: (): void => {},
2021-03-08 21:04:42 +03:30
action: <div />,
setAction: (): void => {},
2021-03-18 21:46:24 +03:30
override: { status: false, value: <div /> },
setOverride: (): void => {},
2024-07-11 17:22:52 +02:00
isCollapsed: false,
setIsCollapsed: (): void => {},
navBarWidth: 0,
setNavBarWidth: (): void => {},
bottomBarHeight: 0,
setBottomBarHeight: (): void => {},
2021-01-22 17:00:33 +03:30
});
export const useNavBarContext = () => useContext(NavBarContext);