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 index 680b55865..b921749ed 100644 --- a/src/components/Settings/AdvancedSettings.tsx +++ b/src/components/Settings/AdvancedSettings.tsx @@ -3,7 +3,7 @@ import { useForm } from '@mantine/form'; import { useConfig } from '../../tools/state'; export default function TitleChanger() { - const { config, loadConfig, setConfig, getConfigs } = useConfig(); + const { config, setConfig } = useConfig(); const form = useForm({ initialValues: { @@ -26,13 +26,19 @@ export default function TitleChanger() { }; return ( -
saveChanges(values))}> - - - - - - - + +
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 234292df6..ea6e9b4a9 100644 --- a/src/components/Settings/SettingsMenu.tsx +++ b/src/components/Settings/SettingsMenu.tsx @@ -1,135 +1,15 @@ -import { - ActionIcon, - Group, - Title, - Text, - Tooltip, - SegmentedControl, - TextInput, - Drawer, - Anchor, - Tabs -} 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 - - - - + + + diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx index 6b1faca07..1cfb218a5 100644 --- a/src/components/layout/Header.tsx +++ b/src/components/layout/Header.tsx @@ -17,12 +17,7 @@ import SearchBar from '../modules/search/SearchModule'; import { AddItemShelfButton } from '../AppShelf/AddAppShelfItem'; import { SettingsMenuButton } from '../Settings/SettingsMenu'; import { ModuleWrapper } from '../modules/moduleWrapper'; -import { - CalendarModule, - TotalDownloadsModule, - WeatherModule, - DateModule, -} from '../modules'; +import { CalendarModule, TotalDownloadsModule, WeatherModule, DateModule } from '../modules'; const HEADER_HEIGHT = 60;