style: format homepage files
All checks were successful
Deploy to Frontend Servers / deploy (push) Successful in 34s

This commit is contained in:
TerryM
2026-05-31 02:56:34 +08:00
parent 39c593c454
commit 6b3211f26f
2 changed files with 156 additions and 147 deletions

View File

@@ -176,7 +176,10 @@ function PopularRankRow({
className="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-[#191921] text-white outline-none transition hover:bg-[#22232D] focus-visible:ring-2 focus-visible:ring-ark-gold/70 disabled:cursor-wait" className="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-[#191921] text-white outline-none transition hover:bg-[#22232D] focus-visible:ring-2 focus-visible:ring-ark-gold/70 disabled:cursor-wait"
> >
{isDownloading ? ( {isDownloading ? (
<LoaderCircle className="h-5 w-5 animate-spin" strokeWidth={2.3} /> <LoaderCircle
className="h-5 w-5 animate-spin"
strokeWidth={2.3}
/>
) : ( ) : (
<DownloadCloudIcon className="h-6 w-6" /> <DownloadCloudIcon className="h-6 w-6" />
)} )}

View File

@@ -224,7 +224,9 @@ export function Home() {
const lefts = children const lefts = children
.map((c) => c.getBoundingClientRect().left - rowLeft) .map((c) => c.getBoundingClientRect().left - rowLeft)
.filter((left) => left < padLeft - epsilon); .filter((left) => left < padLeft - epsilon);
delta = lefts.length ? lefts[lefts.length - 1] - padLeft : -row.scrollLeft; delta = lefts.length
? lefts[lefts.length - 1] - padLeft
: -row.scrollLeft;
} }
const maxScroll = Math.max(0, row.scrollWidth - row.clientWidth); const maxScroll = Math.max(0, row.scrollWidth - row.clientWidth);
const target = Math.max(0, Math.min(maxScroll, row.scrollLeft + delta)); const target = Math.max(0, Math.min(maxScroll, row.scrollLeft + delta));
@@ -273,96 +275,96 @@ export function Home() {
<Reveal delay={0}> <Reveal delay={0}>
<section id="categories" className="scroll-mt-16 md:scroll-mt-24"> <section id="categories" className="scroll-mt-16 md:scroll-mt-24">
<div className="mx-auto max-w-full md:max-w-[820px] lg:max-w-[1080px] xl:max-w-[1180px]"> <div className="mx-auto max-w-full md:max-w-[820px] lg:max-w-[1080px] xl:max-w-[1180px]">
<div className="px-4 md:px-0"> <div className="px-4 md:px-0">
<SectionHeader <SectionHeader
title={t("categorySection")} title={t("categorySection")}
viewAllTo="/categories" viewAllTo="/categories"
viewAllLabel={t("viewAll")} viewAllLabel={t("viewAll")}
/> />
</div>
<div className="mt-2.5 md:hidden">
<div
ref={categoryRowRef}
className="flex snap-x snap-mandatory items-start overflow-x-auto overflow-y-hidden scroll-smooth [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
style={{ height: `${mobileCategoryHeight}px` }}
aria-label={t("categorySection")}
>
{categoryPages.map((page, pageIndex) => (
<div
key={`category-page-${pageIndex}`}
className="grid w-full shrink-0 snap-start grid-cols-3 gap-2 px-4"
>
{page.map((c) => (
<Link
key={c.id}
to={`/category/${encodeURIComponent(c.slug)}`}
className="flex h-[88px] min-w-0 flex-col items-center justify-center gap-2 rounded-xl border border-[#27292E] bg-[#1D1E23] px-4 py-3 text-center outline-none transition hover:border-ark-gold/55 hover:bg-[#252630] focus-visible:ring-2 focus-visible:ring-ark-gold/80 focus-visible:ring-offset-2 focus-visible:ring-offset-ark-bg"
>
<CategoryIcon
iconKey={c.iconKey}
categorySlug={c.slug}
className="h-9 w-9 shrink-0 text-ark-gold"
/>
<div className="w-full truncate text-[13px] font-medium leading-[19.5px] text-white">
{cleanCategoryDisplayName(c.name)}
</div>
</Link>
))}
</div>
))}
</div> </div>
{categoryPages.length > 1 ? ( <div className="mt-2.5 md:hidden">
<div <div
className="flex h-[30px] items-center justify-center gap-1.5" ref={categoryRowRef}
aria-label="Category pagination" className="flex snap-x snap-mandatory items-start overflow-x-auto overflow-y-hidden scroll-smooth [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
style={{ height: `${mobileCategoryHeight}px` }}
aria-label={t("categorySection")}
> >
{categoryPages.map((_, index) => ( {categoryPages.map((page, pageIndex) => (
<button <div
key={`category-dot-${index}`} key={`category-page-${pageIndex}`}
type="button" className="grid w-full shrink-0 snap-start grid-cols-3 gap-2 px-4"
aria-label={`Go to category page ${index + 1}`} >
aria-current={activeCategoryPage === index} {page.map((c) => (
onClick={() => { <Link
const row = categoryRowRef.current; key={c.id}
if (!row) return; to={`/category/${encodeURIComponent(c.slug)}`}
row.scrollTo({ className="flex h-[88px] min-w-0 flex-col items-center justify-center gap-2 rounded-xl border border-[#27292E] bg-[#1D1E23] px-4 py-3 text-center outline-none transition hover:border-ark-gold/55 hover:bg-[#252630] focus-visible:ring-2 focus-visible:ring-ark-gold/80 focus-visible:ring-offset-2 focus-visible:ring-offset-ark-bg"
left: row.clientWidth * index, >
behavior: "smooth", <CategoryIcon
}); iconKey={c.iconKey}
setActiveCategoryPage(index); categorySlug={c.slug}
}} className="h-9 w-9 shrink-0 text-ark-gold"
className={`h-1.5 rounded-full transition-all ${ />
activeCategoryPage === index <div className="w-full truncate text-[13px] font-medium leading-[19.5px] text-white">
? "w-6 bg-ark-gold" {cleanCategoryDisplayName(c.name)}
: "w-1.5 bg-[#7C7C7C]" </div>
}`} </Link>
/> ))}
</div>
))} ))}
</div> </div>
) : null}
</div>
<div className="mt-7 hidden grid-cols-3 gap-3 min-[440px]:gap-3.5 md:grid md:grid-cols-5 md:gap-3 lg:grid-cols-6 xl:grid-cols-7 xl:gap-4"> {categoryPages.length > 1 ? (
{figmaOrderedCategories.map((c, index) => ( <div
<Reveal key={c.id} delay={Math.min(index, 8) * 0.05}> className="flex h-[30px] items-center justify-center gap-1.5"
<Link aria-label="Category pagination"
to={`/category/${encodeURIComponent(c.slug)}`}
className="flex h-[88px] min-w-0 flex-col items-center justify-center gap-2 rounded-xl border border-[#27292E] bg-[#1D1E23] px-4 py-3 text-center outline-none transition hover:border-ark-gold/55 hover:bg-[#252630] focus-visible:ring-2 focus-visible:ring-ark-gold/80 focus-visible:ring-offset-2 focus-visible:ring-offset-ark-bg"
> >
<CategoryIcon {categoryPages.map((_, index) => (
iconKey={c.iconKey} <button
categorySlug={c.slug} key={`category-dot-${index}`}
className="h-9 w-9 shrink-0 text-ark-gold" type="button"
/> aria-label={`Go to category page ${index + 1}`}
<div className="w-full text-center text-[13px] font-medium leading-[19.5px] text-white line-clamp-2"> aria-current={activeCategoryPage === index}
{cleanCategoryDisplayName(c.name)} onClick={() => {
</div> const row = categoryRowRef.current;
</Link> if (!row) return;
</Reveal> row.scrollTo({
))} left: row.clientWidth * index,
</div> behavior: "smooth",
});
setActiveCategoryPage(index);
}}
className={`h-1.5 rounded-full transition-all ${
activeCategoryPage === index
? "w-6 bg-ark-gold"
: "w-1.5 bg-[#7C7C7C]"
}`}
/>
))}
</div>
) : null}
</div>
<div className="mt-7 hidden grid-cols-3 gap-3 min-[440px]:gap-3.5 md:grid md:grid-cols-5 md:gap-3 lg:grid-cols-6 xl:grid-cols-7 xl:gap-4">
{figmaOrderedCategories.map((c, index) => (
<Reveal key={c.id} delay={Math.min(index, 8) * 0.05}>
<Link
to={`/category/${encodeURIComponent(c.slug)}`}
className="flex h-[88px] min-w-0 flex-col items-center justify-center gap-2 rounded-xl border border-[#27292E] bg-[#1D1E23] px-4 py-3 text-center outline-none transition hover:border-ark-gold/55 hover:bg-[#252630] focus-visible:ring-2 focus-visible:ring-ark-gold/80 focus-visible:ring-offset-2 focus-visible:ring-offset-ark-bg"
>
<CategoryIcon
iconKey={c.iconKey}
categorySlug={c.slug}
className="h-9 w-9 shrink-0 text-ark-gold"
/>
<div className="w-full text-center text-[13px] font-medium leading-[19.5px] text-white line-clamp-2">
{cleanCategoryDisplayName(c.name)}
</div>
</Link>
</Reveal>
))}
</div>
</div> </div>
</section> </section>
</Reveal> </Reveal>
@@ -378,71 +380,75 @@ export function Home() {
/> />
</div> </div>
<div className="relative"> <div className="relative">
<div <div
ref={recRowRef} ref={recRowRef}
className="mt-2.5 flex gap-3 overflow-x-auto overflow-y-hidden px-4 pb-0 pr-4 scroll-smooth [-ms-overflow-style:none] [scrollbar-width:none] md:mt-7 md:gap-4 md:px-0 md:pr-0 md:pb-5 [&::-webkit-scrollbar]:hidden" className="mt-2.5 flex gap-3 overflow-x-auto overflow-y-hidden px-4 pb-0 pr-4 scroll-smooth [-ms-overflow-style:none] [scrollbar-width:none] md:mt-7 md:gap-4 md:px-0 md:pr-0 md:pb-5 [&::-webkit-scrollbar]:hidden"
> >
{rec.map((r, index) => ( {rec.map((r, index) => (
<div key={r.id}> <div key={r.id}>
<Reveal delay={Math.min(index, 8) * 0.05}> <Reveal delay={Math.min(index, 8) * 0.05}>
<RecommendedCard r={r} visualIndex={index} useFigmaDesign /> <RecommendedCard
</Reveal> r={r}
</div> visualIndex={index}
))} useFigmaDesign
</div> />
<div </Reveal>
className="flex h-[30px] items-center justify-center gap-1.5" </div>
aria-label="Recommended pagination" ))}
> </div>
{Array.from({ length: recommendedDotCount }).map((_, index) => ( <div
className="flex h-[30px] items-center justify-center gap-1.5"
aria-label="Recommended pagination"
>
{Array.from({ length: recommendedDotCount }).map((_, index) => (
<button
key={`recommended-dot-${index}`}
type="button"
aria-label={`Go to recommendation page ${index + 1}`}
aria-current={activeRecommendedDot === index}
onClick={() => {
const row = recRowRef.current;
if (!row) return;
const maxScroll = Math.max(
0,
row.scrollWidth - row.clientWidth,
);
row.scrollTo({
left:
recommendedDotCount === 1
? 0
: (maxScroll * index) / (recommendedDotCount - 1),
behavior: "smooth",
});
}}
className={`h-1.5 rounded-full transition-all ${
activeRecommendedDot === index
? "w-6 bg-ark-gold"
: "w-1.5 bg-[#7C7C7C]"
}`}
/>
))}
</div>
{canScrollRec && !recAtStart ? (
<button <button
key={`recommended-dot-${index}`}
type="button" type="button"
aria-label={`Go to recommendation page ${index + 1}`} onClick={() => scrollRec(-1)}
aria-current={activeRecommendedDot === index} className="absolute left-0 top-[45%] hidden h-9 w-9 -translate-y-1/2 items-center justify-center rounded-lg border border-ark-line bg-[#292a31]/95 text-neutral-200 shadow-lg backdrop-blur transition hover:border-ark-gold hover:text-ark-gold md:flex"
onClick={() => { aria-label="Previous recommendations"
const row = recRowRef.current; >
if (!row) return; <ChevronLeft className="h-5 w-5" />
const maxScroll = Math.max( </button>
0, ) : null}
row.scrollWidth - row.clientWidth, {canScrollRec && !recAtEnd ? (
); <button
row.scrollTo({ type="button"
left: onClick={() => scrollRec(1)}
recommendedDotCount === 1 className="absolute right-0 top-[45%] hidden h-9 w-9 -translate-y-1/2 items-center justify-center rounded-lg border border-ark-line bg-[#292a31]/95 text-neutral-200 shadow-lg backdrop-blur transition hover:border-ark-gold hover:text-ark-gold md:flex"
? 0 aria-label="Next recommendations"
: (maxScroll * index) / (recommendedDotCount - 1), >
behavior: "smooth", <ChevronRight className="h-5 w-5" />
}); </button>
}} ) : null}
className={`h-1.5 rounded-full transition-all ${
activeRecommendedDot === index
? "w-6 bg-ark-gold"
: "w-1.5 bg-[#7C7C7C]"
}`}
/>
))}
</div>
{canScrollRec && !recAtStart ? (
<button
type="button"
onClick={() => scrollRec(-1)}
className="absolute left-0 top-[45%] hidden h-9 w-9 -translate-y-1/2 items-center justify-center rounded-lg border border-ark-line bg-[#292a31]/95 text-neutral-200 shadow-lg backdrop-blur transition hover:border-ark-gold hover:text-ark-gold md:flex"
aria-label="Previous recommendations"
>
<ChevronLeft className="h-5 w-5" />
</button>
) : null}
{canScrollRec && !recAtEnd ? (
<button
type="button"
onClick={() => scrollRec(1)}
className="absolute right-0 top-[45%] hidden h-9 w-9 -translate-y-1/2 items-center justify-center rounded-lg border border-ark-line bg-[#292a31]/95 text-neutral-200 shadow-lg backdrop-blur transition hover:border-ark-gold hover:text-ark-gold md:flex"
aria-label="Next recommendations"
>
<ChevronRight className="h-5 w-5" />
</button>
) : null}
</div> </div>
</div> </div>
</section> </section>