Add option for custom CSS to Customization Settings

This commit is contained in:
Florian Fritz
2022-08-24 00:38:10 +02:00
parent a2556de7d0
commit 9af2f20bfa
3 changed files with 13 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
import { TextInput, Button, Stack } from '@mantine/core'; import { TextInput, Button, Stack, Textarea } from '@mantine/core';
import { useForm } from '@mantine/form'; import { useForm } from '@mantine/form';
import { useTranslation } from 'next-i18next'; import { useTranslation } from 'next-i18next';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
@@ -25,6 +25,7 @@ export default function TitleChanger() {
logo?: string; logo?: string;
favicon?: string; favicon?: string;
background?: string; background?: string;
customCSS?: string;
}) => { }) => {
setConfig({ setConfig({
...config, ...config,
@@ -34,6 +35,7 @@ export default function TitleChanger() {
logo: values.logo, logo: values.logo,
favicon: values.favicon, favicon: values.favicon,
background: values.background, background: values.background,
customCSS: values.customCSS,
}, },
}); });
}; };
@@ -62,6 +64,12 @@ export default function TitleChanger() {
placeholder={t('background.placeholder')} placeholder={t('background.placeholder')}
{...form.getInputProps('background')} {...form.getInputProps('background')}
/> />
<Textarea
minRows={5}
label="Custom CSS"
placeholder="Your CSS will be executed last"
{...form.getInputProps('customCSS')}
/>
<Button type="submit">{t('buttons.submit')}</Button> <Button type="submit">{t('buttons.submit')}</Button>
</Stack> </Stack>
</form> </form>

View File

@@ -34,6 +34,9 @@ export default function Layout({ children, style }: any) {
> >
{children} {children}
</main> </main>
<style>
{cx(config.settings.customCSS)}
</style>
</AppShell> </AppShell>
); );
} }

View File

@@ -10,6 +10,7 @@ export interface Settings {
secondaryColor?: MantineTheme['primaryColor']; secondaryColor?: MantineTheme['primaryColor'];
primaryShade?: MantineTheme['primaryShade']; primaryShade?: MantineTheme['primaryShade'];
background?: string; background?: string;
customCSS?: string,
appOpacity?: number; appOpacity?: number;
widgetPosition?: string; widgetPosition?: string;
appCardWidth?: number; appCardWidth?: number;