mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-15 09:46:19 +01:00
📱 Improve header
This commit is contained in:
@@ -1,4 +1,13 @@
|
|||||||
import { Box, Flex, Group, Header, Text, UnstyledButton, useMantineTheme } from '@mantine/core';
|
import {
|
||||||
|
Box,
|
||||||
|
Center,
|
||||||
|
Flex,
|
||||||
|
Group,
|
||||||
|
Header,
|
||||||
|
Text,
|
||||||
|
UnstyledButton,
|
||||||
|
useMantineTheme,
|
||||||
|
} from '@mantine/core';
|
||||||
import { useMediaQuery } from '@mantine/hooks';
|
import { useMediaQuery } from '@mantine/hooks';
|
||||||
import { IconAlertTriangle } from '@tabler/icons-react';
|
import { IconAlertTriangle } from '@tabler/icons-react';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
@@ -24,7 +33,10 @@ export const MainHeader = ({
|
|||||||
const { breakpoints } = useMantineTheme();
|
const { breakpoints } = useMantineTheme();
|
||||||
const isSmallerThanMd = useMediaQuery(`(max-width: ${breakpoints.sm})`);
|
const isSmallerThanMd = useMediaQuery(`(max-width: ${breakpoints.sm})`);
|
||||||
const experimentalHeaderNoteHeight = isSmallerThanMd ? 50 : 30;
|
const experimentalHeaderNoteHeight = isSmallerThanMd ? 50 : 30;
|
||||||
const headerHeight = showExperimental ? 60 + experimentalHeaderNoteHeight : 60;
|
const headerBaseHeight = isSmallerThanMd ? 60 + 46 : 60;
|
||||||
|
const headerHeight = showExperimental
|
||||||
|
? headerBaseHeight + experimentalHeaderNoteHeight
|
||||||
|
: headerBaseHeight;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Header height={headerHeight} pb="sm" pt={0}>
|
<Header height={headerHeight} pb="sm" pt={0}>
|
||||||
@@ -37,7 +49,7 @@ export const MainHeader = ({
|
|||||||
</UnstyledButton>
|
</UnstyledButton>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Search />
|
{!isSmallerThanMd && <Search />}
|
||||||
|
|
||||||
<Group noWrap style={{ flex: 1 }} position="right">
|
<Group noWrap style={{ flex: 1 }} position="right">
|
||||||
<Group noWrap spacing={8}>
|
<Group noWrap spacing={8}>
|
||||||
@@ -46,6 +58,12 @@ export const MainHeader = ({
|
|||||||
<AvatarMenu />
|
<AvatarMenu />
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
|
{isSmallerThanMd && (
|
||||||
|
<Center mt="xs" px="md">
|
||||||
|
<Search isMobile />
|
||||||
|
</Center>
|
||||||
|
)}
|
||||||
</Header>
|
</Header>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,7 +15,11 @@ import { api } from '~/utils/api';
|
|||||||
|
|
||||||
import { MovieModal } from './MovieModal';
|
import { MovieModal } from './MovieModal';
|
||||||
|
|
||||||
export const Search = () => {
|
type SearchProps = {
|
||||||
|
isMobile?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Search = ({ isMobile }: SearchProps) => {
|
||||||
const [search, setSearch] = useState('');
|
const [search, setSearch] = useState('');
|
||||||
const ref = useRef<HTMLInputElement>(null);
|
const ref = useRef<HTMLInputElement>(null);
|
||||||
useHotkeys([['mod+K', () => ref.current?.focus()]]);
|
useHotkeys([['mod+K', () => ref.current?.focus()]]);
|
||||||
@@ -40,7 +44,7 @@ export const Search = () => {
|
|||||||
<Autocomplete
|
<Autocomplete
|
||||||
ref={ref}
|
ref={ref}
|
||||||
radius="xl"
|
radius="xl"
|
||||||
w={400}
|
w={isMobile ? '100%' : 400}
|
||||||
variant="filled"
|
variant="filled"
|
||||||
placeholder="Search..."
|
placeholder="Search..."
|
||||||
hoverOnSearchChange
|
hoverOnSearchChange
|
||||||
|
|||||||
Reference in New Issue
Block a user