Implement new header on home page

This commit is contained in:
jeffvli 2023-01-02 18:20:45 -08:00
parent d93e6a612e
commit 26e6f479b7

View file

@ -1,17 +1,17 @@
import { useCallback, useMemo } from 'react'; import { useCallback, useMemo, useRef } from 'react';
import { Box, Stack } from '@mantine/core'; import { Box, Stack } from '@mantine/core';
import { useSetState } from '@mantine/hooks'; import { useSetState } from '@mantine/hooks';
import { AlbumListSort, ServerType, SortOrder } from '/@/renderer/api/types'; import { AlbumListSort, ServerType, SortOrder } from '/@/renderer/api/types';
import { TextTitle, PageHeader, FeatureCarousel, GridCarousel } from '/@/renderer/components'; import { TextTitle, FeatureCarousel, GridCarousel, NativeScrollArea } from '/@/renderer/components';
import { useAlbumList } from '/@/renderer/features/albums'; import { useAlbumList } from '/@/renderer/features/albums';
import { useRecentlyPlayed } from '/@/renderer/features/home/queries/recently-played-query'; import { useRecentlyPlayed } from '/@/renderer/features/home/queries/recently-played-query';
import { AnimatedPage } from '/@/renderer/features/shared'; import { AnimatedPage, LibraryHeaderBar } from '/@/renderer/features/shared';
import { useContainerQuery } from '/@/renderer/hooks'; import { useContainerQuery } from '/@/renderer/hooks';
import { AppRoute } from '/@/renderer/router/routes'; import { AppRoute } from '/@/renderer/router/routes';
import { useCurrentServer } from '/@/renderer/store'; import { useCurrentServer } from '/@/renderer/store';
const HomeRoute = () => { const HomeRoute = () => {
// const rootElement = document.querySelector(':root') as HTMLElement; const scrollAreaRef = useRef<HTMLDivElement>(null);
const server = useCurrentServer(); const server = useCurrentServer();
const cq = useContainerQuery(); const cq = useContainerQuery();
const itemsPerPage = cq.isXl ? 9 : cq.isLg ? 7 : cq.isMd ? 5 : cq.isSm ? 4 : 3; const itemsPerPage = cq.isXl ? 9 : cq.isLg ? 7 : cq.isMd ? 5 : cq.isSm ? 4 : 3;
@ -111,16 +111,6 @@ const HomeRoute = () => {
[pagination, setPagination], [pagination, setPagination],
); );
// const handleScroll = (position: { x: number; y: number }) => {
// if (position.y <= 15) {
// return rootElement?.style?.setProperty('--header-opacity', '0');
// }
// return rootElement?.style?.setProperty('--header-opacity', '1');
// };
// const throttledScroll = throttle(handleScroll, 200);
const carousels = [ const carousels = [
{ {
data: random?.data?.items, data: random?.data?.items,
@ -202,22 +192,22 @@ const HomeRoute = () => {
return ( return (
<AnimatedPage> <AnimatedPage>
<Box sx={{ display: 'flex', flexDirection: 'column', height: '100%' }}> <NativeScrollArea
<PageHeader ref={scrollAreaRef}
isHidden pageHeaderProps={{
backgroundColor="var(--sidebar-bg)" backgroundColor: 'var(--titlebar-bg)',
/> children: (
<Box <LibraryHeaderBar>
mb="1rem" <LibraryHeaderBar.Title>Home</LibraryHeaderBar.Title>
mt="-1.5rem" </LibraryHeaderBar>
px="1rem" ),
sx={{ offset: ['0px', '200px'],
height: '100%',
overflow: 'auto',
}} }}
> >
<Box <Box
ref={cq.ref} ref={cq.ref}
pt="3rem"
px="2rem"
sx={{ sx={{
height: '100%', height: '100%',
maxWidth: '1920px', maxWidth: '1920px',
@ -268,8 +258,7 @@ const HomeRoute = () => {
))} ))}
</Stack> </Stack>
</Box> </Box>
</Box> </NativeScrollArea>
</Box>
</AnimatedPage> </AnimatedPage>
); );
}; };