🔀 Merge pull request #364 from wieli99/master

 Add option for custom CSS to Customization Settings
This commit is contained in:
Thomas Camlong
2022-08-31 15:56:07 +02:00
committed by GitHub
5 changed files with 24 additions and 3 deletions

View File

@@ -15,7 +15,11 @@
"label": "Hintergrund", "label": "Hintergrund",
"placeholder": "/img/background.png" "placeholder": "/img/background.png"
}, },
"customCSS": {
"label": "Benutzerdefiniertes CSS",
"placeholder": "Benutzerdefiniertes CSS wird als letztes ausgeführt"
},
"buttons": { "buttons": {
"submit": "Absenden" "submit": "Absenden"
} }
} }

View File

@@ -15,7 +15,11 @@
"label": "Background", "label": "Background",
"placeholder": "/img/background.png" "placeholder": "/img/background.png"
}, },
"customCSS": {
"label": "Custom CSS",
"placeholder": "Custom CSS will be executed last"
},
"buttons": { "buttons": {
"submit": "Submit" "submit": "Submit"
} }
} }

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';
@@ -17,6 +17,7 @@ export default function TitleChanger() {
logo: config.settings.logo, logo: config.settings.logo,
favicon: config.settings.favicon, favicon: config.settings.favicon,
background: config.settings.background, background: config.settings.background,
customCSS: config.settings.customCSS,
}, },
}); });
@@ -25,6 +26,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 +36,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 +65,12 @@ export default function TitleChanger() {
placeholder={t('background.placeholder')} placeholder={t('background.placeholder')}
{...form.getInputProps('background')} {...form.getInputProps('background')}
/> />
<Textarea
minRows={5}
label={t('customCSS.label')}
placeholder={t('customCSS.placeholder')}
{...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;