1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

61 lines
1.6 KiB
TypeScript
Raw Normal View History

2020-12-29 02:05:28 -07:00
import { useRef } from 'react';
import { Flex, ScaleFade } from '@chakra-ui/react';
import { ColorModeToggle } from '~/components';
import { useColorValue, useBreakpointValue } from '~/context';
import { useBooleanValue, useLGState } from '~/hooks';
2020-12-29 02:05:28 -07:00
import { HeaderProvider } from './context';
import { Title } from './title';
2020-12-29 02:05:28 -07:00
import type { THeader } from './types';
export const Header = (props: THeader) => {
const { resetForm, ...rest } = props;
2020-12-29 02:05:28 -07:00
const bg = useColorValue('white', 'black');
const { isSubmitting } = useLGState();
2020-12-29 02:05:28 -07:00
const titleRef = useRef({} as HTMLDivElement);
2020-12-29 02:05:28 -07:00
const titleWidth = useBooleanValue(
isSubmitting.value,
2020-12-29 02:05:28 -07:00
{ base: '75%', lg: '50%' },
{ base: '75%', lg: '75%' },
);
2020-12-29 02:05:28 -07:00
const justify = useBreakpointValue({ base: 'flex-start', lg: 'center' });
return (
2020-12-29 02:05:28 -07:00
<HeaderProvider value={{ showSubtitle: !isSubmitting.value, titleRef }}>
<Flex
2020-12-29 02:05:28 -07:00
px={4}
pt={6}
2020-12-29 02:05:28 -07:00
bg={bg}
minH={16}
zIndex={4}
as="header"
width="full"
flex="0 1 auto"
color="gray.500"
{...rest}>
<ScaleFade in initialScale={0.5} style={{ width: '100%' }}>
<Flex
d="flex"
key="title"
height="100%"
ref={titleRef}
mx={{ base: 0, lg: 'auto' }}
maxW={titleWidth}
// This is here for the logo
justifyContent={justify}>
<Title />
</Flex>
</ScaleFade>
{/* <Flex pos="absolute" right={0} top={0} m={4}>
<ColorModeToggle />
</Flex> */}
</Flex>
2020-12-29 02:05:28 -07:00
</HeaderProvider>
);
};