diff --git a/src/components/modules/date/DateModule.tsx b/src/components/modules/date/DateModule.tsx
index ba653f862..7b31f859e 100644
--- a/src/components/modules/date/DateModule.tsx
+++ b/src/components/modules/date/DateModule.tsx
@@ -2,6 +2,7 @@ import { Group, Text, Title } from '@mantine/core';
import dayjs from 'dayjs';
import { useEffect, useState } from 'react';
import { Clock } from 'tabler-icons-react';
+import { useConfig } from '../../../tools/state';
import { IModule } from '../modules';
export const DateModule: IModule = {
@@ -9,33 +10,39 @@ export const DateModule: IModule = {
description: 'Show the current time and date in a card',
icon: Clock,
component: DateComponent,
+ options: {
+ full: {
+ name: 'Display full time (24-hour)',
+ value: true,
+ },
+ },
};
export default function DateComponent(props: any) {
const [date, setDate] = useState(new Date());
+ const { config } = useConfig();
const hours = date.getHours();
const minutes = date.getMinutes();
-
+ const fullSetting = config.settings[`${DateModule.title}.full`];
// Change date on minute change
// Note: Using 10 000ms instead of 1000ms to chill a little :)
useEffect(() => {
setInterval(() => {
setDate(new Date());
- }, 10000);
+ }, 1000 * 60);
}, []);
+ const timeString = `${hours < 10 ? `0${hours}` : hours}:${
+ minutes < 10 ? `0${minutes}` : minutes
+ }`;
+ const halfTimeString = `${hours < 10 ? `${hours % 12}` : hours % 12}:${
+ minutes < 10 ? `0${minutes}` : minutes
+ } ${hours < 12 ? 'AM' : 'PM'}`;
+ const finalTimeString = fullSetting ? timeString : halfTimeString;
return (
-
- {hours < 10 ? `0${hours}` : hours}:{minutes < 10 ? `0${minutes}` : minutes}
-
-
- {
- // Use dayjs to format the date
- // https://day.js.org/en/getting-started/installation/
- dayjs(date).format('dddd, MMMM D')
- }
-
+ {finalTimeString}
+ {dayjs(date).format('dddd, MMMM D')}
);
}
diff --git a/src/components/modules/moduleWrapper.tsx b/src/components/modules/moduleWrapper.tsx
index 55b421a5e..d081f013d 100644
--- a/src/components/modules/moduleWrapper.tsx
+++ b/src/components/modules/moduleWrapper.tsx
@@ -1,19 +1,82 @@
-import { Card, useMantineTheme } from '@mantine/core';
+import { Card, Menu, Switch, 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 { config, setConfig } = useConfig();
const enabledModules = config.settings.enabledModules ?? [];
// Remove 'Module' from enabled modules titles
const isShown = enabledModules.includes(module.title);
const theme = useMantineTheme();
+ const items: JSX.Element[] = [];
+ if (module.options) {
+ const keys = Object.keys(module.options);
+ const values = Object.values(module.options);
+ // Get the value and the name of the option
+ const types = values.map((v) => typeof v.value);
+ // Loop over all the types with a for each loop
+ types.forEach((type, index) => {
+ const optionName = `${module.title}.${keys[index]}`;
+ // TODO: Add support for other types
+ if (type === 'boolean') {
+ items.push(
+ {
+ setConfig({
+ ...config,
+ settings: {
+ ...config.settings,
+ enabledModules: [...config.settings.enabledModules],
+ [optionName]: e.currentTarget.checked,
+ },
+ });
+ }}
+ label={values[index].name}
+ />
+ );
+ }
+ });
+ }
+ // Sussy baka
if (!isShown) {
return null;
}
return (
+ {module.options && (
+
+ )}
);
diff --git a/src/components/modules/modules.tsx b/src/components/modules/modules.tsx
index 60ce7d55d..c3c3ef1dd 100644
--- a/src/components/modules/modules.tsx
+++ b/src/components/modules/modules.tsx
@@ -7,5 +7,14 @@ export interface IModule {
description: string;
icon: React.ReactNode;
component: React.ComponentType;
- props?: any;
+ options?: Option;
+}
+
+interface Option {
+ [x: string]: OptionValues;
+}
+
+interface OptionValues {
+ name: string;
+ value: boolean;
}