Files
Homarr/components/Settings/SettingsMenu.tsx
Aj - Thomas c95df0a07b Use Config provider everywhere in app
We can now load as much data as we want in the services and settings values. This solves the issue of using multiple localStorages boxes
2022-05-02 15:09:39 +02:00

84 lines
2.2 KiB
TypeScript

import { ActionIcon, Group, Modal, Switch, Title, Text, Tooltip, TextInput } from '@mantine/core';
import { showNotification } from '@mantine/notifications';
import { motion } from 'framer-motion';
import { CSSProperties, useEffect, useState } from 'react';
import { Mail, Settings as SettingsIcon, X } from 'tabler-icons-react';
import { useConfig } from '../../tools/state';
import SaveConfigComponent from '../Config/SaveConfig';
function SettingsMenu(props: any) {
const { config, setConfig } = useConfig();
return (
<Group direction="column" grow>
<TextInput
label="Search bar querry url"
defaultValue={config.settings.searchUrl}
onChange={(e) =>
setConfig({
...config,
settings: {
...config.settings,
searchUrl: e.target.value,
},
})
}
/>
<Group direction="column">
<Switch
onChange={(e) =>
setConfig({
...config,
settings: {
...config.settings,
searchBar: e.currentTarget.checked,
},
})
}
checked={config.settings.searchBar}
label="Enable search bar"
/>
</Group>
<SaveConfigComponent />
<Text
style={{
alignSelf: 'center',
fontSize: '0.75rem',
textAlign: 'center',
color: '#a0aec0',
}}
>
tip: You can upload your config file by dragging and dropping it into the page
</Text>
</Group>
);
}
export function SettingsMenuButton(props: any) {
const [opened, setOpened] = useState(false);
return (
<>
<Modal
size="md"
title={<Title order={3}>Settings</Title>}
opened={props.opened || opened}
onClose={() => setOpened(false)}
>
<SettingsMenu />
</Modal>
<ActionIcon
variant="default"
radius="xl"
size="xl"
color="blue"
style={props.style}
onClick={() => setOpened(true)}
>
<Tooltip label="Settings">
<SettingsIcon />
</Tooltip>
</ActionIcon>
</>
);
}