2022-06-07 00:07:56 +00:00
|
|
|
import { TextInput, Group, Button } from '@mantine/core';
|
2022-06-07 01:35:50 +00:00
|
|
|
import { useForm } from '@mantine/form';
|
2022-06-07 00:07:56 +00:00
|
|
|
import { useConfig } from '../../tools/state';
|
2022-06-11 19:44:11 +02:00
|
|
|
import { ColorSelector } from './ColorSelector';
|
|
|
|
|
import { OpacitySelector } from './OpacitySelector';
|
2022-06-14 17:45:22 +00:00
|
|
|
import { AppCardWidthSelector } from './AppCardWidthSelector';
|
2022-06-11 19:44:11 +02:00
|
|
|
import { ShadeSelector } from './ShadeSelector';
|
2022-06-07 00:07:56 +00:00
|
|
|
|
|
|
|
|
export default function TitleChanger() {
|
2022-06-07 08:21:03 +02:00
|
|
|
const { config, setConfig } = useConfig();
|
2022-06-07 00:07:56 +00:00
|
|
|
|
2022-06-07 01:35:50 +00:00
|
|
|
const form = useForm({
|
|
|
|
|
initialValues: {
|
|
|
|
|
title: config.settings.title,
|
|
|
|
|
logo: config.settings.logo,
|
|
|
|
|
favicon: config.settings.favicon,
|
2022-06-07 17:36:05 +00:00
|
|
|
background: config.settings.background,
|
2022-06-07 01:35:50 +00:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2022-06-07 17:36:05 +00:00
|
|
|
const saveChanges = (values: {
|
|
|
|
|
title?: string;
|
|
|
|
|
logo?: string;
|
|
|
|
|
favicon?: string;
|
|
|
|
|
background?: string;
|
|
|
|
|
}) => {
|
2022-06-07 00:07:56 +00:00
|
|
|
setConfig({
|
|
|
|
|
...config,
|
2022-06-07 01:35:50 +00:00
|
|
|
settings: {
|
|
|
|
|
...config.settings,
|
|
|
|
|
title: values.title,
|
|
|
|
|
logo: values.logo,
|
|
|
|
|
favicon: values.favicon,
|
2022-06-07 17:36:05 +00:00
|
|
|
background: values.background,
|
2022-06-07 01:35:50 +00:00
|
|
|
},
|
2022-06-07 00:07:56 +00:00
|
|
|
});
|
2022-06-07 01:35:50 +00:00
|
|
|
};
|
2022-06-07 00:07:56 +00:00
|
|
|
|
|
|
|
|
return (
|
2022-06-07 08:21:03 +02:00
|
|
|
<Group direction="column" grow>
|
|
|
|
|
<form onSubmit={form.onSubmit((values) => saveChanges(values))}>
|
|
|
|
|
<Group grow direction="column">
|
2022-06-07 12:12:23 +02:00
|
|
|
<TextInput label="Page title" placeholder="Homarr 🦞" {...form.getInputProps('title')} />
|
2022-06-07 08:21:03 +02:00
|
|
|
<TextInput label="Logo" placeholder="/img/logo.png" {...form.getInputProps('logo')} />
|
|
|
|
|
<TextInput
|
|
|
|
|
label="Favicon"
|
|
|
|
|
placeholder="/favicon.svg"
|
|
|
|
|
{...form.getInputProps('favicon')}
|
|
|
|
|
/>
|
2022-06-08 20:20:24 +00:00
|
|
|
<TextInput
|
|
|
|
|
label="Background"
|
|
|
|
|
placeholder="/img/background.png"
|
|
|
|
|
{...form.getInputProps('background')}
|
|
|
|
|
/>
|
2022-06-08 14:58:32 +00:00
|
|
|
<Button type="submit">Save</Button>
|
2022-06-07 08:21:03 +02:00
|
|
|
</Group>
|
|
|
|
|
</form>
|
2022-06-11 19:44:11 +02:00
|
|
|
<ColorSelector type="primary" />
|
|
|
|
|
<ColorSelector type="secondary" />
|
|
|
|
|
<ShadeSelector />
|
|
|
|
|
<OpacitySelector />
|
2022-06-14 17:45:22 +00:00
|
|
|
<AppCardWidthSelector />
|
2022-06-07 08:21:03 +02:00
|
|
|
</Group>
|
2022-06-07 00:07:56 +00:00
|
|
|
);
|
|
|
|
|
}
|