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

47 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-03-03 18:19:01 +05:30
/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* 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/.
*/
2022-03-03 18:19:01 +05:30
import React, { useContext } from 'react';
import { LibraryOptions } from '@/typings';
2022-03-03 18:19:01 +05:30
type ContextType = {
options: LibraryOptions;
setOptions: React.Dispatch<React.SetStateAction<LibraryOptions>>;
};
export enum GridLayout {
Compact = 0,
Comfortable = 1,
List = 2,
}
export const DefaultLibraryOptions: LibraryOptions = {
showContinueReadingButton: false,
showDownloadBadge: false,
showUnreadBadge: false,
gridLayout: GridLayout.Compact,
SourcegridLayout: GridLayout.Compact,
downloaded: undefined,
sortDesc: undefined,
sorts: undefined,
unread: undefined,
2024-03-28 20:00:46 +01:00
tracker: {},
showTabSize: false,
2022-03-03 18:19:01 +05:30
};
2023-10-28 00:32:02 +02:00
export const LibraryOptionsContext = React.createContext<ContextType>({
options: DefaultLibraryOptions,
2022-03-03 18:19:01 +05:30
setOptions: () => {},
});
export function useLibraryOptionsContext() {
return useContext(LibraryOptionsContext);
}