diff --git a/src/components/Config/SaveConfig.tsx b/src/components/Config/SaveConfig.tsx index 2348bd608..d18b38ae2 100644 --- a/src/components/Config/SaveConfig.tsx +++ b/src/components/Config/SaveConfig.tsx @@ -27,7 +27,7 @@ export default function SaveConfigComponent(props: any) { } } return ( - + - - diff --git a/src/components/Settings/AdvancedSettings.tsx b/src/components/Settings/AdvancedSettings.tsx new file mode 100644 index 000000000..7b678f10f --- /dev/null +++ b/src/components/Settings/AdvancedSettings.tsx @@ -0,0 +1,44 @@ +import { TextInput, Group, Button } from '@mantine/core'; +import { useForm } from '@mantine/form'; +import { useConfig } from '../../tools/state'; + +export default function TitleChanger() { + const { config, setConfig } = useConfig(); + + const form = useForm({ + initialValues: { + title: config.settings.title, + logo: config.settings.logo, + favicon: config.settings.favicon, + }, + }); + + const saveChanges = (values: { title?: string; logo?: string; favicon?: string }) => { + setConfig({ + ...config, + settings: { + ...config.settings, + title: values.title, + logo: values.logo, + favicon: values.favicon, + }, + }); + }; + + return ( + +
saveChanges(values))}> + + + + + + +
+
+ ); +} diff --git a/src/components/Settings/CommonSettings.tsx b/src/components/Settings/CommonSettings.tsx new file mode 100644 index 000000000..3f244c0b6 --- /dev/null +++ b/src/components/Settings/CommonSettings.tsx @@ -0,0 +1,124 @@ +import { + ActionIcon, + Group, + Text, + SegmentedControl, + TextInput, + Anchor, +} from '@mantine/core'; +import { useState } from 'react'; +import { IconBrandGithub as BrandGithub } from '@tabler/icons'; +import { CURRENT_VERSION } from '../../../data/constants'; +import { useConfig } from '../../tools/state'; +import { ColorSchemeSwitch } from '../ColorSchemeToggle/ColorSchemeSwitch'; +import ConfigChanger from '../Config/ConfigChanger'; +import SaveConfigComponent from '../Config/SaveConfig'; +import ModuleEnabler from './ModuleEnabler'; + +export default function CommonSettings(args: any) { + const { config, setConfig } = useConfig(); + + const matches = [ + { label: 'Google', value: 'https://google.com/search?q=' }, + { label: 'DuckDuckGo', value: 'https://duckduckgo.com/?q=' }, + { label: 'Bing', value: 'https://bing.com/search?q=' }, + { label: 'Custom', value: 'Custom' }, + ]; + + const [customSearchUrl, setCustomSearchUrl] = useState(config.settings.searchUrl); + const [searchUrl, setSearchUrl] = useState( + matches.find((match) => match.value === config.settings.searchUrl)?.value ?? 'Custom' + ); + + return ( + + + Search engine + { + setSearchUrl(e); + setConfig({ + ...config, + settings: { + ...config.settings, + searchUrl: e, + }, + }); + } + } + data={matches} + /> + {searchUrl === 'Custom' && ( + { + setCustomSearchUrl(event.currentTarget.value); + setConfig({ + ...config, + settings: { + ...config.settings, + searchUrl: event.currentTarget.value, + }, + }); + }} + /> + )} + + + + + + + Tip: You can upload your config file by dragging and dropping it onto the page! + + + + component="a" href="https://github.com/ajnart/homarr" size="lg"> + + + + {CURRENT_VERSION} + + + + Made with ❤️ by @ + + ajnart + + + + + ); +} diff --git a/src/components/Settings/SettingsMenu.tsx b/src/components/Settings/SettingsMenu.tsx index 956db2ec7..ea6e9b4a9 100644 --- a/src/components/Settings/SettingsMenu.tsx +++ b/src/components/Settings/SettingsMenu.tsx @@ -1,131 +1,20 @@ -import { - ActionIcon, - Group, - Title, - Text, - Tooltip, - SegmentedControl, - TextInput, - Drawer, - Anchor, -} from '@mantine/core'; -import { useColorScheme, useHotkeys } from '@mantine/hooks'; +import { ActionIcon, Title, Tooltip, Drawer, Tabs } from '@mantine/core'; +import { useHotkeys } from '@mantine/hooks'; import { useState } from 'react'; -import { IconBrandGithub as BrandGithub, IconSettings } from '@tabler/icons'; -import { CURRENT_VERSION } from '../../../data/constants'; -import { useConfig } from '../../tools/state'; -import { ColorSchemeSwitch } from '../ColorSchemeToggle/ColorSchemeSwitch'; -import ConfigChanger from '../Config/ConfigChanger'; -import SaveConfigComponent from '../Config/SaveConfig'; -import ModuleEnabler from './ModuleEnabler'; +import { IconSettings } from '@tabler/icons'; +import AdvancedSettings from './AdvancedSettings'; +import CommonSettings from './CommonSettings'; function SettingsMenu(props: any) { - const { config, setConfig } = useConfig(); - const colorScheme = useColorScheme(); - const { current, latest } = props; - - const matches = [ - { label: 'Google', value: 'https://google.com/search?q=' }, - { label: 'DuckDuckGo', value: 'https://duckduckgo.com/?q=' }, - { label: 'Bing', value: 'https://bing.com/search?q=' }, - { label: 'Custom', value: 'Custom' }, - ]; - - const [customSearchUrl, setCustomSearchUrl] = useState(config.settings.searchUrl); - const [searchUrl, setSearchUrl] = useState( - matches.find((match) => match.value === config.settings.searchUrl)?.value ?? 'Custom' - ); - return ( - - - Search engine - { - setSearchUrl(e); - setConfig({ - ...config, - settings: { - ...config.settings, - searchUrl: e, - }, - }); - } - } - data={matches} - /> - {searchUrl === 'Custom' && ( - { - setCustomSearchUrl(event.currentTarget.value); - setConfig({ - ...config, - settings: { - ...config.settings, - searchUrl: event.currentTarget.value, - }, - }); - }} - /> - )} - - - - - - - Tip: You can upload your config file by dragging and dropping it onto the page! - - - - component="a" href="https://github.com/ajnart/homarr" size="lg"> - - - - {CURRENT_VERSION} - - - - Made with ❤️ by @ - - ajnart - - - - + + + + + + + + ); } @@ -136,7 +25,7 @@ export function SettingsMenuButton(props: any) { return ( <> Settings} diff --git a/src/components/layout/HeaderConfig.tsx b/src/components/layout/HeaderConfig.tsx new file mode 100644 index 000000000..ed5a7804f --- /dev/null +++ b/src/components/layout/HeaderConfig.tsx @@ -0,0 +1,14 @@ +import React from 'react'; +import Head from 'next/head'; +import { useConfig } from '../../tools/state'; + +export function HeaderConfig(props: any) { + const { config } = useConfig(); + + return ( + + {config.settings.title || 'Homarr 🦞'} + + + ); +} diff --git a/src/components/layout/Layout.tsx b/src/components/layout/Layout.tsx index ac2c3c742..d9ccbccb7 100644 --- a/src/components/layout/Layout.tsx +++ b/src/components/layout/Layout.tsx @@ -2,6 +2,7 @@ import { AppShell, createStyles } from '@mantine/core'; import { Header } from './Header'; import { Footer } from './Footer'; import Aside from './Aside'; +import { HeaderConfig } from './HeaderConfig'; const useStyles = createStyles((theme) => ({ main: {}, @@ -11,6 +12,7 @@ export default function Layout({ children, style }: any) { const { classes, cx } = useStyles(); return ( } header={
} footer={