-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathHomePageComponent.tsx
More file actions
110 lines (99 loc) · 3.34 KB
/
HomePageComponent.tsx
File metadata and controls
110 lines (99 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
'use client';
import { faEllipsis } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
InterSectionAdSlot,
SongCardAdSlot,
} from '../../shared/components/client/ads/AdSlots';
import {
Carousel,
CarouselContent,
CarouselDots,
CarouselItem,
CarouselNext,
CarouselPrevious,
} from '../../shared/components/client/Carousel';
import { WelcomeBanner } from '../WelcomeBanner';
import { CategoryButtonGroup } from './client/CategoryButton';
import { useFeaturedSongsProvider } from './client/context/FeaturedSongs.context';
import { useRecentSongsStore } from './client/context/RecentSongs.context';
import LoadMoreButton from './client/LoadMoreButton';
import { TimespanButtonGroup } from './client/TimespanButton';
import SongCard from './SongCard';
import SongCardGroup from './SongCardGroup';
export const HomePageComponent = () => {
const { featuredSongsPage, timespan } = useFeaturedSongsProvider();
const recentItems = useRecentSongsStore((state) => state.recentItems);
const increasePageRecent = useRecentSongsStore(
(state) => state.increasePageRecent,
);
const hasMore = useRecentSongsStore((state) => state.hasMore);
return (
<>
{/* Welcome banner/Hero */}
<WelcomeBanner />
{/* <EventBanner /> */}
{/* FEATURED SONGS */}
{featuredSongsPage.length > 0 && (
<>
<div className='flex flex-wrap justify-between gap-6 text-nowrap'>
<h2 className='flex-1 text-xl uppercase'>Featured songs</h2>
<TimespanButtonGroup />
</div>
<div className='h-6' />
<Carousel
key={timespan}
opts={{
align: 'start',
loop: false,
duration: 15,
}}
>
<CarouselContent className='-ml-4'>
{featuredSongsPage.map((song, i) => (
<CarouselItem
className='basis-full md:basis-1/2 lg:basis-1/3 min-w-0 shrink-0 grow-0 pl-4'
key={i}
>
<SongCard song={song} />
</CarouselItem>
))}
</CarouselContent>
<CarouselPrevious />
<CarouselNext />
<CarouselDots />
</Carousel>
<hr className='my-8 border-none bg-zinc-700 h-[3px]' />
</>
)}
<InterSectionAdSlot />
{/* RECENT SONGS */}
<div className='flex flex-row flex-wrap justify-between items-center gap-4 mb-2'>
<h2 className='text-xl uppercase z-2'>Recent songs</h2>
<CategoryButtonGroup />
</div>
<div className='h-6' />
<SongCardGroup data-test='recent-songs'>
{recentItems.map((item, i) => {
if (item.type === 'ad') {
return <SongCardAdSlot key={i} />;
}
if (item.type === 'loading') {
return <SongCard key={i} song={null} />;
}
return <SongCard key={i} song={item.data} />;
})}
</SongCardGroup>
<div className='flex flex-col w-full justify-between items-center mt-4'>
{hasMore ? (
<LoadMoreButton onClick={() => increasePageRecent()} />
) : (
<FontAwesomeIcon
icon={faEllipsis}
className='text-2xl text-zinc-500'
/>
)}
</div>
</>
);
};