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

44 lines
1.2 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 { AnimatedDiv } from '~/components';
import { useBreakpointValue } from '~/context';
import { useBooleanValue, useFormState } from '~/hooks';
2020-12-29 02:05:28 -07:00
import { Title } from './title';
2020-12-29 02:05:28 -07:00
import type { THeader } from './types';
2021-12-17 21:08:45 -07:00
export const Header = (props: THeader): JSX.Element => {
const { resetForm, ...rest } = props;
2020-12-29 02:05:28 -07:00
const status = useFormState(s => s.status);
2020-12-29 02:05:28 -07:00
const titleRef = useRef({} as HTMLDivElement);
2020-12-29 02:05:28 -07:00
const titleWidth = useBooleanValue(
status === 'results',
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 (
<Flex px={4} pt={6} minH={16} zIndex={4} as="header" width="full" flex="0 1 auto" {...rest}>
<ScaleFade in initialScale={0.5} style={{ width: '100%' }}>
<AnimatedDiv
layout
height="100%"
display="flex"
ref={titleRef}
maxW={titleWidth}
// This is here for the logo
justifyContent={justify}
mx={{ base: status === 'results' ? 'auto' : 0, lg: 'auto' }}
2021-01-03 23:51:09 -07:00
>
<Title />
</AnimatedDiv>
</ScaleFade>
</Flex>
);
};