Files
Homarr/src/components/Settings/AdvancedSettings.tsx

85 lines
2.5 KiB
TypeScript
Raw Normal View History

import { TextInput, Button, Stack, Textarea } from '@mantine/core';
import { useForm } from '@mantine/form';
2022-08-22 09:50:54 +02:00
import { useTranslation } from 'next-i18next';
2022-06-07 00:07:56 +00:00
import { useConfig } from '../../tools/state';
import { ColorSelector } from './ColorSelector';
import { OpacitySelector } from './OpacitySelector';
import { AppCardWidthSelector } from './AppCardWidthSelector';
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-08-22 09:50:54 +02:00
const { t } = useTranslation('settings/customization/page-appearance');
2022-06-07 00:07:56 +00:00
const form = useForm({
initialValues: {
title: config.settings.title,
logo: config.settings.logo,
favicon: config.settings.favicon,
background: config.settings.background,
customCSS: config.settings.customCSS,
},
});
const saveChanges = (values: {
title?: string;
logo?: string;
favicon?: string;
background?: string;
customCSS?: string;
}) => {
2022-06-07 00:07:56 +00:00
setConfig({
...config,
settings: {
...config.settings,
title: values.title,
logo: values.logo,
favicon: values.favicon,
background: values.background,
customCSS: values.customCSS,
},
2022-06-07 00:07:56 +00:00
});
};
2022-06-07 00:07:56 +00:00
return (
2022-08-02 02:21:04 +02:00
<Stack mb="md" mr="sm" mt="xs">
2022-06-07 08:21:03 +02:00
<form onSubmit={form.onSubmit((values) => saveChanges(values))}>
<Stack>
2022-06-07 08:21:03 +02:00
<TextInput
2022-08-22 09:50:54 +02:00
label={t('pageTitle.label')}
2022-11-02 16:56:50 +09:00
placeholder={'Homarr 🦞'}
2022-08-18 21:46:46 +02:00
{...form.getInputProps('title')}
/>
<TextInput
2022-08-22 09:50:54 +02:00
label={t('logo.label')}
2022-11-02 16:56:50 +09:00
placeholder={'/imgs/logo.png}
2022-08-18 21:46:46 +02:00
{...form.getInputProps('logo')}
/>
<TextInput
2022-08-22 09:50:54 +02:00
label={t('favicon.label')}
2022-11-02 16:56:50 +09:00
placeholder={'/imgs/favicon/favicon.png'}
2022-06-07 08:21:03 +02:00
{...form.getInputProps('favicon')}
/>
<TextInput
2022-08-22 09:50:54 +02:00
label={t('background.label')}
2022-11-02 16:56:50 +09:00
placeholder={'/img/background.png'}
{...form.getInputProps('background')}
/>
<Textarea
minRows={5}
label={t('customCSS.label')}
placeholder={t('customCSS.placeholder')}
{...form.getInputProps('customCSS')}
/>
2022-08-22 09:50:54 +02:00
<Button type="submit">{t('buttons.submit')}</Button>
</Stack>
2022-06-07 08:21:03 +02:00
</form>
<ColorSelector type="primary" />
<ColorSelector type="secondary" />
<ShadeSelector />
<OpacitySelector />
<AppCardWidthSelector />
</Stack>
2022-06-07 00:07:56 +00:00
);
}