Add a module enabler

Add module enabler in settings.
This loops over all the exported Modules in the components/modules folder and renders them. (Interpreted language magic/ metaclasses)
This commit is contained in:
Aj - Thomas
2022-05-10 20:33:11 +02:00
parent 1245f97e72
commit 2c461a6695
7 changed files with 57 additions and 0 deletions

View File

@@ -1,11 +1,18 @@
import { Card, useMantineTheme } from '@mantine/core';
import { useConfig } from '../../tools/state';
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 enabledModulesTitles = enabledModules.map((module) => module.replace('Module', ''));
const isShown = enabledModulesTitles.includes(module.title);
const theme = useMantineTheme();
return (
<Card
hidden={!isShown}
mx="sm"
radius="lg"
shadow="sm"