mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 15:35:55 +01:00
Merge branch 'gridstack' of https://github.com/manuel-rw/homarr into gridstack
This commit is contained in:
@@ -1,60 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import {
|
|
||||||
createStyles,
|
|
||||||
Switch,
|
|
||||||
Group,
|
|
||||||
useMantineColorScheme,
|
|
||||||
Kbd,
|
|
||||||
useMantineTheme,
|
|
||||||
} from '@mantine/core';
|
|
||||||
import { IconMoonStars, IconSun } from '@tabler/icons';
|
|
||||||
import { useTranslation } from 'next-i18next';
|
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
|
||||||
root: {
|
|
||||||
position: 'relative',
|
|
||||||
'& *': {
|
|
||||||
cursor: 'pointer',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
icon: {
|
|
||||||
pointerEvents: 'none',
|
|
||||||
position: 'absolute',
|
|
||||||
zIndex: 1,
|
|
||||||
top: 3,
|
|
||||||
},
|
|
||||||
|
|
||||||
iconLight: {
|
|
||||||
left: 4,
|
|
||||||
color: theme.white,
|
|
||||||
},
|
|
||||||
|
|
||||||
iconDark: {
|
|
||||||
right: 4,
|
|
||||||
color: theme.colors.gray[6],
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
export function ColorSchemeSwitch() {
|
|
||||||
const { colorScheme, toggleColorScheme } = useMantineColorScheme();
|
|
||||||
const { t } = useTranslation('settings/general/theme-selector');
|
|
||||||
const theme = useMantineTheme();
|
|
||||||
return (
|
|
||||||
<Group>
|
|
||||||
<Switch
|
|
||||||
checked={colorScheme === 'dark'}
|
|
||||||
onChange={() => toggleColorScheme()}
|
|
||||||
size="md"
|
|
||||||
onLabel={<IconSun color={theme.white} size={20} stroke={1.5} />}
|
|
||||||
offLabel={<IconMoonStars color={theme.colors.gray[6]} size={20} stroke={1.5} />}
|
|
||||||
/>
|
|
||||||
{t('label', {
|
|
||||||
theme: colorScheme === 'dark' ? 'light' : 'dark',
|
|
||||||
})}
|
|
||||||
<Group spacing={2}>
|
|
||||||
<Kbd>Ctrl</Kbd>+<Kbd>J</Kbd>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,7 @@ export default function ConfigChanger() {
|
|||||||
const onConfigChange = (value: string) => {
|
const onConfigChange = (value: string) => {
|
||||||
// TODO: check what should happen here with @manuel-rw
|
// TODO: check what should happen here with @manuel-rw
|
||||||
// Wheter it should check for the current url and then load the new config only on index
|
// Wheter it should check for the current url and then load the new config only on index
|
||||||
// Or it should always load the selected config and open index or ?
|
// Or it should always load the selected config and open index or ? --> change url to page
|
||||||
setActiveConfig(value);
|
setActiveConfig(value);
|
||||||
/*
|
/*
|
||||||
loadConfig(e ?? 'default');
|
loadConfig(e ?? 'default');
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ interface MetaTitleChangerProps {
|
|||||||
defaultValue: string | undefined;
|
defaultValue: string | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: change to pageTitle
|
||||||
export const MetaTitleChanger = ({ defaultValue }: MetaTitleChangerProps) => {
|
export const MetaTitleChanger = ({ defaultValue }: MetaTitleChangerProps) => {
|
||||||
const { t } = useTranslation('settings/customization/page-appearance');
|
const { t } = useTranslation('settings/customization/page-appearance');
|
||||||
const updateConfig = useConfigStore((x) => x.updateConfig);
|
const updateConfig = useConfigStore((x) => x.updateConfig);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ interface PageTitleChangerProps {
|
|||||||
defaultValue: string | undefined;
|
defaultValue: string | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: change to dashboard title
|
||||||
export const PageTitleChanger = ({ defaultValue }: PageTitleChangerProps) => {
|
export const PageTitleChanger = ({ defaultValue }: PageTitleChangerProps) => {
|
||||||
const { t } = useTranslation('settings/customization/page-appearance');
|
const { t } = useTranslation('settings/customization/page-appearance');
|
||||||
const updateConfig = useConfigStore((x) => x.updateConfig);
|
const updateConfig = useConfigStore((x) => x.updateConfig);
|
||||||
|
|||||||
@@ -31,37 +31,25 @@ function SettingsMenu() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SettingsMenuButton(props: any) {
|
interface SettingsDrawerProps {
|
||||||
useHotkeys([['ctrl+L', () => setOpened(!opened)]]);
|
opened: boolean;
|
||||||
|
closeDrawer: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function SettingsDrawer({ opened, closeDrawer }: SettingsDrawerProps) {
|
||||||
const { t } = useTranslation('settings/common');
|
const { t } = useTranslation('settings/common');
|
||||||
|
|
||||||
const [opened, setOpened] = useState(false);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
|
||||||
<Drawer
|
<Drawer
|
||||||
size="xl"
|
size="xl"
|
||||||
padding="lg"
|
padding="lg"
|
||||||
position="right"
|
position="right"
|
||||||
title={<Title order={5}>{t('title')}</Title>}
|
title={<Title order={5}>{t('title')}</Title>}
|
||||||
opened={props.opened || opened}
|
opened={opened}
|
||||||
onClose={() => setOpened(false)}
|
onClose={closeDrawer}
|
||||||
>
|
>
|
||||||
<SettingsMenu />
|
<SettingsMenu />
|
||||||
<Credits />
|
<Credits />
|
||||||
</Drawer>
|
</Drawer>
|
||||||
<Tooltip label={t('tooltip')}>
|
|
||||||
<ActionIcon
|
|
||||||
variant="default"
|
|
||||||
radius="md"
|
|
||||||
size="xl"
|
|
||||||
color="blue"
|
|
||||||
style={props.style}
|
|
||||||
onClick={() => setOpened(true)}
|
|
||||||
>
|
|
||||||
<IconSettings />
|
|
||||||
</ActionIcon>
|
|
||||||
</Tooltip>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -4,9 +4,9 @@ import { AddItemShelfButton } from '../../AppShelf/AddAppShelfItem';
|
|||||||
|
|
||||||
import DockerMenuButton from '../../../modules/docker/DockerModule';
|
import DockerMenuButton from '../../../modules/docker/DockerModule';
|
||||||
import { Search } from './Search';
|
import { Search } from './Search';
|
||||||
import { SettingsMenuButton } from '../../Settings/SettingsMenu';
|
|
||||||
import { Logo } from '../Logo';
|
import { Logo } from '../Logo';
|
||||||
import { useCardStyles } from '../useCardStyles';
|
import { useCardStyles } from '../useCardStyles';
|
||||||
|
import { SettingsMenu } from './SettingsMenu';
|
||||||
|
|
||||||
export const HeaderHeight = 64;
|
export const HeaderHeight = 64;
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ export function Header(props: any) {
|
|||||||
<Group position="right" noWrap>
|
<Group position="right" noWrap>
|
||||||
<Search />
|
<Search />
|
||||||
<DockerMenuButton />
|
<DockerMenuButton />
|
||||||
<SettingsMenuButton />
|
<SettingsMenu />
|
||||||
<AddItemShelfButton />
|
<AddItemShelfButton />
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
34
src/components/layout/header/SettingsMenu.tsx
Normal file
34
src/components/layout/header/SettingsMenu.tsx
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { ActionIcon, Menu, Tooltip } from '@mantine/core';
|
||||||
|
import { useDisclosure } from '@mantine/hooks';
|
||||||
|
import { IconInfoCircle, IconMenu2, IconSettings } from '@tabler/icons';
|
||||||
|
import { SettingsDrawer } from '../../Settings/SettingsDrawer';
|
||||||
|
import { ColorSchemeSwitch } from './SettingsMenu/ColorSchemeSwitch';
|
||||||
|
|
||||||
|
export const SettingsMenu = () => {
|
||||||
|
const [drawerOpened, drawer] = useDisclosure(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip label="Open Menu">
|
||||||
|
<Menu width={250}>
|
||||||
|
<Menu.Target>
|
||||||
|
<ActionIcon variant="default" radius="md" size="xl" color="blue">
|
||||||
|
<IconMenu2 />
|
||||||
|
</ActionIcon>
|
||||||
|
</Menu.Target>
|
||||||
|
<Menu.Dropdown>
|
||||||
|
<ColorSchemeSwitch />
|
||||||
|
<Menu.Divider />
|
||||||
|
<Menu.Item icon={<IconSettings strokeWidth={1.2} size={18} />} onClick={drawer.open}>
|
||||||
|
Homarr Settings
|
||||||
|
</Menu.Item>
|
||||||
|
<Menu.Item icon={<IconInfoCircle strokeWidth={1.2} size={18} />} onClick={() => {}}>
|
||||||
|
About
|
||||||
|
</Menu.Item>
|
||||||
|
</Menu.Dropdown>
|
||||||
|
</Menu>
|
||||||
|
</Tooltip>
|
||||||
|
<SettingsDrawer opened={drawerOpened} closeDrawer={drawer.close} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { Menu, useMantineColorScheme, useMantineTheme } from '@mantine/core';
|
||||||
|
import { IconMoonStars, IconSun } from '@tabler/icons';
|
||||||
|
import { useTranslation } from 'next-i18next';
|
||||||
|
|
||||||
|
export const ColorSchemeSwitch = () => {
|
||||||
|
const { colorScheme, toggleColorScheme } = useMantineColorScheme();
|
||||||
|
const { t } = useTranslation('settings/general/theme-selector');
|
||||||
|
|
||||||
|
const Icon = colorScheme === 'dark' ? IconSun : IconMoonStars;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Menu.Item
|
||||||
|
closeMenuOnClick={false}
|
||||||
|
icon={<Icon strokeWidth={1.2} size={18} />}
|
||||||
|
onClick={() => toggleColorScheme()}
|
||||||
|
>
|
||||||
|
{t('label', {
|
||||||
|
theme: colorScheme === 'dark' ? 'light' : 'dark',
|
||||||
|
})}
|
||||||
|
</Menu.Item>
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user