@@ -14,18 +14,18 @@ import type {
14
14
} from "@/lib/types"
15
15
16
16
import BentoBox from "@/components/BentoBox"
17
+ import BentoCard from "@/components/BentoBox/BentoCard"
18
+ import Title from "@/components/BentoBox/Title"
17
19
import SvgButtonLink from "@/components/Buttons/SvgButtonLink"
18
20
import CodeModal from "@/components/CodeModal"
19
21
import HomeHero from "@/components/Hero/HomeHero"
20
- import { useHome } from "@/components/Homepage/useHome"
21
22
import AngleBrackets from "@/components/icons/angle-brackets.svg"
22
23
import Calendar from "@/components/icons/calendar.svg"
23
24
import CalendarAdd from "@/components/icons/calendar-add.svg"
24
25
import { TwImage } from "@/components/Image"
25
26
import MainArticle from "@/components/MainArticle"
26
27
import PageMetadata from "@/components/PageMetadata"
27
- import PostsSwiper from "@/components/PostsSwiper"
28
- import SwiperCards from "@/components/SwiperCards"
28
+ import Swiper from "@/components/Swiper"
29
29
import { TranslatathonBanner } from "@/components/Translatathon/TranslatathonBanner"
30
30
import { ButtonLink } from "@/components/ui/buttons/Button"
31
31
import {
@@ -52,6 +52,7 @@ import { existsNamespace } from "@/lib/utils/existsNamespace"
52
52
import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
53
53
import { polishRSSList } from "@/lib/utils/rss"
54
54
import { runOnlyOnce } from "@/lib/utils/runOnlyOnce"
55
+ import { breakpointAsNumber } from "@/lib/utils/screen"
55
56
import { getLocaleTimestamp } from "@/lib/utils/time"
56
57
import { getRequiredNamespacesForPage } from "@/lib/utils/translations"
57
58
@@ -64,6 +65,9 @@ import {
64
65
RSS_DISPLAY_COUNT ,
65
66
} from "@/lib/constants"
66
67
68
+ import "swiper/css/effect-cards"
69
+
70
+ import { useHome } from "@/hooks/useHome"
67
71
import { fetchCommunityEvents } from "@/lib/api/calendarEvents"
68
72
import { fetchEthPrice } from "@/lib/api/fetchEthPrice"
69
73
import { fetchGrowThePie } from "@/lib/api/fetchGrowThePie"
@@ -178,6 +182,7 @@ const HomePage = ({
178
182
popularTopics,
179
183
upcomingEvents,
180
184
joinActions,
185
+ bentoItems,
181
186
} = useHome ( )
182
187
183
188
return (
@@ -221,7 +226,26 @@ const HomePage = ({
221
226
</ div >
222
227
223
228
{ /* Mobile */ }
224
- < SwiperCards className = "lg:hidden" />
229
+ < div className = "-mx-4 w-[100vw] overflow-hidden px-4 sm:-mx-6 sm:px-6 lg:hidden" >
230
+ < Title />
231
+ < Swiper
232
+ options = { { effect : "cards" , createElements : true } }
233
+ className = { cn (
234
+ "[&_.swiper-slide]:overflow-visible [&_.swiper-slide]:rounded-2xl [&_.swiper-slide]:shadow-card-hover" ,
235
+ "[&_.swiper]:mx-auto [&_.swiper]:mt-4 [&_.swiper]:!flex [&_.swiper]:h-fit [&_.swiper]:max-w-128 [&_.swiper]:flex-col [&_.swiper]:items-center"
236
+ ) }
237
+ >
238
+ { bentoItems . map ( ( item ) => (
239
+ < BentoCard
240
+ key = { item . title }
241
+ imgHeight = { 220 }
242
+ { ...item }
243
+ className = { cn ( item . className , "bg-background text-body" ) }
244
+ imgWidth = { undefined } // Intentionally last to override box
245
+ />
246
+ ) ) }
247
+ </ Swiper >
248
+ </ div >
225
249
226
250
{ /* Desktop */ }
227
251
< BentoBox className = "hidden lg:block" />
@@ -452,7 +476,44 @@ const HomePage = ({
452
476
</ h3 >
453
477
< p > { t ( "page-index:page-index-posts-subtitle" ) } </ p >
454
478
455
- < PostsSwiper items = { rssItems } className = "mt-4 md:mt-16" />
479
+ < Swiper
480
+ className = "mt-4 md:mt-16"
481
+ options = { {
482
+ spaceBetween : 32 ,
483
+ breakpoints : {
484
+ [ breakpointAsNumber . sm ] : {
485
+ slidesPerView : 2 ,
486
+ slidesPerGroup : 2 ,
487
+ } ,
488
+ [ breakpointAsNumber . lg ] : {
489
+ slidesPerView : 3 ,
490
+ slidesPerGroup : 3 ,
491
+ } ,
492
+ } ,
493
+ } }
494
+ >
495
+ { rssItems . map ( ( { pubDate, title, source, link, imgSrc } ) => (
496
+ < Card key = { title } href = { link } >
497
+ < CardBanner >
498
+ { /* eslint-disable-next-line @next/next/no-img-element */ }
499
+ < img src = { imgSrc } alt = "" />
500
+ </ CardBanner >
501
+ < CardContent >
502
+ < CardTitle > { title } </ CardTitle >
503
+ { isValidDate ( pubDate ) && (
504
+ < CardSubTitle >
505
+ { new Intl . DateTimeFormat ( locale , {
506
+ month : "long" ,
507
+ day : "numeric" ,
508
+ year : "numeric" ,
509
+ } ) . format ( new Date ( pubDate ) ) }
510
+ </ CardSubTitle >
511
+ ) }
512
+ < CardHighlight > { source } </ CardHighlight >
513
+ </ CardContent >
514
+ </ Card >
515
+ ) ) }
516
+ </ Swiper >
456
517
457
518
< div className = "mt-8 flex flex-col gap-4 rounded-2xl border p-8" >
458
519
< p className = "text-lg" > { t ( "page-index:page-index-posts-action" ) } </ p >
0 commit comments