style: apply prettier formatting to fix format:check

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
TerryM
2026-05-29 12:49:22 +08:00
parent bcd7395e77
commit f73131dc03
6 changed files with 274 additions and 276 deletions

View File

@@ -271,267 +271,271 @@ export function Home() {
</section>
<Reveal delay={0}>
<section id="categories" className="scroll-mt-16 md:scroll-mt-24">
<div className="px-4 md:px-0">
<SectionHeader
title={t("categorySection")}
viewAllTo="/categories"
viewAllLabel={t("viewAll")}
/>
</div>
<div className="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>
))}
<section id="categories" className="scroll-mt-16 md:scroll-mt-24">
<div className="px-4 md:px-0">
<SectionHeader
title={t("categorySection")}
viewAllTo="/categories"
viewAllLabel={t("viewAll")}
/>
</div>
{categoryPages.length > 1 ? (
<div className="md:hidden">
<div
className="flex h-[30px] items-center justify-center gap-1.5"
aria-label="Category pagination"
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((_, index) => (
{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>
{categoryPages.length > 1 ? (
<div
className="flex h-[30px] items-center justify-center gap-1.5"
aria-label="Category pagination"
>
{categoryPages.map((_, index) => (
<button
key={`category-dot-${index}`}
type="button"
aria-label={`Go to category page ${index + 1}`}
aria-current={activeCategoryPage === index}
onClick={() => {
const row = categoryRowRef.current;
if (!row) return;
row.scrollTo({
left: row.clientWidth * index,
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>
</section>
</Reveal>
<Reveal>
<section id="official" className="scroll-mt-16 md:scroll-mt-24">
<div className="px-4 md:px-0">
<SectionHeader
title={t("officialSection")}
viewAllTo="/official-recommendations"
viewAllLabel={t("viewAll")}
/>
</div>
<div className="relative">
<div
ref={recRowRef}
className="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) => (
<div key={r.id}>
<Reveal delay={Math.min(index, 8) * 0.05}>
<RecommendedCard r={r} visualIndex={index} useFigmaDesign />
</Reveal>
</div>
))}
</div>
<div
className="flex h-[30px] items-center justify-center gap-1.5 md:hidden"
aria-label="Recommended pagination"
>
{Array.from({ length: recommendedDotCount }).map((_, index) => (
<button
key={`category-dot-${index}`}
key={`recommended-dot-${index}`}
type="button"
aria-label={`Go to category page ${index + 1}`}
aria-current={activeCategoryPage === index}
aria-label={`Go to recommendation page ${index + 1}`}
aria-current={activeRecommendedDot === index}
onClick={() => {
const row = categoryRowRef.current;
const row = recRowRef.current;
if (!row) return;
const maxScroll = Math.max(
0,
row.scrollWidth - row.clientWidth,
);
row.scrollTo({
left: row.clientWidth * index,
left:
recommendedDotCount === 1
? 0
: (maxScroll * index) / (recommendedDotCount - 1),
behavior: "smooth",
});
setActiveCategoryPage(index);
}}
className={`h-1.5 rounded-full transition-all ${
activeCategoryPage === index
activeRecommendedDot === 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>
</section>
{canScrollRec ? (
<>
<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>
<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>
</section>
</Reveal>
<Reveal>
<section id="official" className="scroll-mt-16 md:scroll-mt-24">
<div className="px-4 md:px-0">
<SectionHeader
title={t("officialSection")}
viewAllTo="/official-recommendations"
viewAllLabel={t("viewAll")}
/>
</div>
<div className="relative">
<div
ref={recRowRef}
className="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) => (
<div key={r.id}>
<Reveal delay={Math.min(index, 8) * 0.05}>
<RecommendedCard r={r} visualIndex={index} useFigmaDesign />
</Reveal>
</div>
))}
</div>
<div
className="flex h-[30px] items-center justify-center gap-1.5 md:hidden"
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 ? (
<>
<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>
<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>
</section>
</Reveal>
<Reveal>
<section id="latest" className="scroll-mt-16 md:scroll-mt-24">
<div className="px-4 md:px-0">
<SectionHeader
title={t("latestSection")}
viewAllTo="/browse"
viewAllLabel={t("viewAll")}
/>
</div>
<div className="flex flex-col gap-3 md:hidden">
{latestPosts.slice(0, 5).map((post) => (
<MessageBubble key={post.id} post={post} />
))}
</div>
<div className="relative hidden md:block">
<div
ref={latestRowRef}
className="mt-7 flex gap-4 overflow-x-auto overflow-y-hidden pb-5 scroll-smooth [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
>
{latest.map((r) => (
<div key={r.id} className="w-[340px] shrink-0 xl:w-[352px]">
<LatestUpdateRow r={r} iconKey={iconKeyForResource(r)} />
</div>
))}
{Array.from({ length: latestPlaceholderCount }).map((_, index) => (
<div
key={`latest-coming-soon-${index}`}
className="w-[340px] shrink-0 xl:w-[352px]"
>
<ComingSoonLatestUpdateRow index={latest.length + index} />
</div>
))}
</div>
{canScrollLatest ? (
<>
<button
type="button"
onClick={() => scrollLatest(-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 latest updates"
>
<ChevronLeft className="h-5 w-5" />
</button>
<button
type="button"
onClick={() => scrollLatest(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 latest updates"
>
<ChevronRight className="h-5 w-5" />
</button>
</>
) : null}
</div>
</section>
</Reveal>
{hasPopular ? (
<Reveal>
<section id="popular" className="scroll-mt-16 md:scroll-mt-24">
<section id="latest" className="scroll-mt-16 md:scroll-mt-24">
<div className="px-4 md:px-0">
<SectionHeader
title={t("popularSection")}
viewAllTo="/browse?sort=popular"
title={t("latestSection")}
viewAllTo="/browse"
viewAllLabel={t("viewAll")}
/>
</div>
<div className="flex flex-col gap-3 md:hidden">
{popularPosts.slice(0, 5).map((post) => (
{latestPosts.slice(0, 5).map((post) => (
<MessageBubble key={post.id} post={post} />
))}
</div>
<div className="mt-7 hidden grid-cols-1 gap-3 min-[576px]:grid-cols-2 md:grid md:grid-cols-2 md:gap-4 lg:grid-cols-3 xl:grid-cols-5">
{popular.map((r) => (
<LatestUpdateRow
key={r.id}
r={r}
iconKey={iconKeyForResource(r)}
/>
))}
{Array.from({ length: popularPlaceholderCount }).map((_, index) => (
<ComingSoonLatestUpdateRow
key={`popular-coming-soon-${index}`}
index={popular.length + index}
/>
))}
<div className="relative hidden md:block">
<div
ref={latestRowRef}
className="mt-7 flex gap-4 overflow-x-auto overflow-y-hidden pb-5 scroll-smooth [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
>
{latest.map((r) => (
<div key={r.id} className="w-[340px] shrink-0 xl:w-[352px]">
<LatestUpdateRow r={r} iconKey={iconKeyForResource(r)} />
</div>
))}
{Array.from({ length: latestPlaceholderCount }).map(
(_, index) => (
<div
key={`latest-coming-soon-${index}`}
className="w-[340px] shrink-0 xl:w-[352px]"
>
<ComingSoonLatestUpdateRow index={latest.length + index} />
</div>
),
)}
</div>
{canScrollLatest ? (
<>
<button
type="button"
onClick={() => scrollLatest(-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 latest updates"
>
<ChevronLeft className="h-5 w-5" />
</button>
<button
type="button"
onClick={() => scrollLatest(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 latest updates"
>
<ChevronRight className="h-5 w-5" />
</button>
</>
) : null}
</div>
</section>
</Reveal>
{hasPopular ? (
<Reveal>
<section id="popular" className="scroll-mt-16 md:scroll-mt-24">
<div className="px-4 md:px-0">
<SectionHeader
title={t("popularSection")}
viewAllTo="/browse?sort=popular"
viewAllLabel={t("viewAll")}
/>
</div>
<div className="flex flex-col gap-3 md:hidden">
{popularPosts.slice(0, 5).map((post) => (
<MessageBubble key={post.id} post={post} />
))}
</div>
<div className="mt-7 hidden grid-cols-1 gap-3 min-[576px]:grid-cols-2 md:grid md:grid-cols-2 md:gap-4 lg:grid-cols-3 xl:grid-cols-5">
{popular.map((r) => (
<LatestUpdateRow
key={r.id}
r={r}
iconKey={iconKeyForResource(r)}
/>
))}
{Array.from({ length: popularPlaceholderCount }).map(
(_, index) => (
<ComingSoonLatestUpdateRow
key={`popular-coming-soon-${index}`}
index={popular.length + index}
/>
),
)}
</div>
</section>
</Reveal>
) : null}
</div>