Files
Homarr/components/modules/moduleWrapper.tsx

30 lines
842 B
TypeScript
Raw Normal View History

import { Card, useMantineTheme } from '@mantine/core';
import { useConfig } from '../../tools/state';
2022-05-10 18:57:04 +02:00
import { IModule } from './modules';
export default function ModuleWrapper(props: any) {
const { module }: { module: IModule } = props;
const { config } = useConfig();
const enabledModules = config.settings.enabledModules ?? [];
// Remove 'Module' from enabled modules titles
const isShown = enabledModules.includes(module.title);
2022-05-10 18:57:04 +02:00
const theme = useMantineTheme();
if (!isShown) {
return null;
}
2022-05-10 18:57:04 +02:00
return (
<Card
hidden={!isShown}
2022-05-10 18:57:04 +02:00
mx="sm"
radius="lg"
shadow="sm"
style={{
// Make background color of the card depend on the theme
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : 'white',
2022-05-10 18:57:04 +02:00
}}
>
<module.component />
2022-05-10 18:57:04 +02:00
</Card>
);
}