2020-12-29 02:05:28 -07:00
|
|
|
import { useRef } from 'react';
|
|
|
|
|
import { Flex, ScaleFade } from '@chakra-ui/react';
|
2021-01-02 16:53:13 -07:00
|
|
|
import { AnimatedDiv } from '~/components';
|
2021-04-10 11:17:58 -07:00
|
|
|
import { useBreakpointValue } from '~/context';
|
2021-09-21 08:20:44 -07:00
|
|
|
import { useBooleanValue, useFormState } from '~/hooks';
|
2020-12-29 02:05:28 -07:00
|
|
|
import { Title } from './title';
|
2020-11-29 01:25:48 -07:00
|
|
|
|
2020-12-29 02:05:28 -07:00
|
|
|
import type { THeader } from './types';
|
2020-11-29 01:25:48 -07:00
|
|
|
|
2021-12-17 21:08:45 -07:00
|
|
|
export const Header = (props: THeader): JSX.Element => {
|
2020-11-29 01:25:48 -07:00
|
|
|
const { resetForm, ...rest } = props;
|
2020-12-29 02:05:28 -07:00
|
|
|
|
2021-09-21 08:20:44 -07:00
|
|
|
const status = useFormState(s => s.status);
|
2020-11-29 01:25:48 -07:00
|
|
|
|
2020-12-29 02:05:28 -07:00
|
|
|
const titleRef = useRef({} as HTMLDivElement);
|
2020-11-29 01:25:48 -07:00
|
|
|
|
2020-12-29 02:05:28 -07:00
|
|
|
const titleWidth = useBooleanValue(
|
2021-09-21 08:20:44 -07:00
|
|
|
status === 'results',
|
2020-12-29 02:05:28 -07:00
|
|
|
{ base: '75%', lg: '50%' },
|
|
|
|
|
{ base: '75%', lg: '75%' },
|
2020-11-29 01:25:48 -07:00
|
|
|
);
|
2020-12-11 09:55:21 -07:00
|
|
|
|
2020-12-29 02:05:28 -07:00
|
|
|
const justify = useBreakpointValue({ base: 'flex-start', lg: 'center' });
|
2020-11-29 01:25:48 -07:00
|
|
|
|
|
|
|
|
return (
|
2021-04-10 11:17:58 -07:00
|
|
|
<Flex px={4} pt={6} minH={16} zIndex={4} as="header" width="full" flex="0 1 auto" {...rest}>
|
2020-12-29 15:58:36 -07:00
|
|
|
<ScaleFade in initialScale={0.5} style={{ width: '100%' }}>
|
2021-01-02 16:53:13 -07:00
|
|
|
<AnimatedDiv
|
|
|
|
|
layout
|
2020-12-29 15:58:36 -07:00
|
|
|
height="100%"
|
2021-01-02 16:53:13 -07:00
|
|
|
display="flex"
|
2020-12-29 15:58:36 -07:00
|
|
|
ref={titleRef}
|
|
|
|
|
maxW={titleWidth}
|
|
|
|
|
// This is here for the logo
|
|
|
|
|
justifyContent={justify}
|
2021-09-21 08:20:44 -07:00
|
|
|
mx={{ base: status === 'results' ? 'auto' : 0, lg: 'auto' }}
|
2021-01-03 23:51:09 -07:00
|
|
|
>
|
2020-12-29 15:58:36 -07:00
|
|
|
<Title />
|
2021-01-02 16:53:13 -07:00
|
|
|
</AnimatedDiv>
|
2020-12-29 15:58:36 -07:00
|
|
|
</ScaleFade>
|
|
|
|
|
</Flex>
|
2020-11-29 01:25:48 -07:00
|
|
|
);
|
|
|
|
|
};
|