Added a background image input

Added an input in the advanced options for a background image. Also removed an unused import from my previous commit and changed the margin on the header bar to padding instead.
This commit is contained in:
Aimsucks
2022-06-07 17:36:05 +00:00
parent 901798055b
commit 423f8110b9
7 changed files with 33 additions and 3 deletions

View File

@@ -10,10 +10,16 @@ export default function TitleChanger() {
title: config.settings.title,
logo: config.settings.logo,
favicon: config.settings.favicon,
background: config.settings.background,
},
});
const saveChanges = (values: { title?: string; logo?: string; favicon?: string }) => {
const saveChanges = (values: {
title?: string;
logo?: string;
favicon?: string;
background?: string;
}) => {
setConfig({
...config,
settings: {
@@ -21,6 +27,7 @@ export default function TitleChanger() {
title: values.title,
logo: values.logo,
favicon: values.favicon,
background: values.background,
},
});
};
@@ -36,6 +43,7 @@ export default function TitleChanger() {
placeholder="/favicon.svg"
{...form.getInputProps('favicon')}
/>
<TextInput label="Background" placeholder="" {...form.getInputProps('background')} />
<Button type="submit" color={config.settings.primary_color || 'red'}>
Save
</Button>

View File

@@ -5,7 +5,6 @@ import {
SegmentedControl,
TextInput,
Anchor,
ColorPicker,
useMantineTheme,
} from '@mantine/core';
import { useState } from 'react';

View File

@@ -28,6 +28,7 @@ export default function Aside(props: any) {
className={cx(classes.hide)}
style={{
border: 'none',
background: 'none',
}}
width={{
base: 'auto',

View File

@@ -0,0 +1,19 @@
import { Global } from '@mantine/core';
import { useConfig } from '../../tools/state';
export function Background() {
const { config } = useConfig();
return (
<Global
styles={{
body: {
backgroundImage: `url('${config.settings.background}')` || '',
backgroundPosition: 'center',
backgroundSize: 'cover',
backgroundRepeat: 'no-repeat',
},
}}
/>
);
}

View File

@@ -41,7 +41,7 @@ export function Header(props: any) {
return (
<Head height="auto">
<Group m="xs" position="apart">
<Group p="xs" position="apart">
<Box className={classes.hide}>
<Logo style={{ fontSize: 22 }} />
</Box>

View File

@@ -3,6 +3,7 @@ import { Header } from './Header';
import { Footer } from './Footer';
import Aside from './Aside';
import { HeaderConfig } from './HeaderConfig';
import { Background } from './Background';
const useStyles = createStyles((theme) => ({
main: {},
@@ -13,6 +14,7 @@ export default function Layout({ children, style }: any) {
return (
<AppShell aside={<Aside />} header={<Header />} footer={<Footer links={[]} />}>
<HeaderConfig />
<Background />
<main
className={cx(classes.main)}
style={{

View File

@@ -7,6 +7,7 @@ export interface Settings {
favicon?: string;
primary_color?: string;
secondary_color?: string;
background?: string;
}
export interface Config {