Skip to content

Commit dd6d075

Browse files
authored
Fix Hero Table of Contents component overflowing on mobiles with 6 items (#2271)
## Description I just noticed a nasty overflow, this PR fixes it. <img width="436" height="510" alt="image" src="https://github.com/user-attachments/assets/936ab6ba-835a-48b4-9437-27a0366b5344" />
1 parent 43ef944 commit dd6d075

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/components/toc-hero/toc-hero-contents.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ export function TocHeroContents({
2424
What will you find here?
2525
</h2>
2626
<ul
27-
className="grid grid-flow-row-dense grid-rows-2 gap-px border-t border-inherit bg-neu-300 dark:bg-neu-100"
28-
style={{
29-
gridTemplateColumns: `repeat(${sections.length / 2}, 1fr)`,
30-
}}
27+
className={clsx(
28+
"grid grid-flow-row-dense grid-rows-2 gap-px border-t border-inherit bg-neu-300 dark:bg-neu-100",
29+
sections.length > 3
30+
? "grid-cols-2 lg:grid-cols-[repeat(3,1fr)]"
31+
: "grid-cols-1",
32+
)}
3133
>
3234
{sections.map((section, i) => {
3335
const { name, href } =
@@ -41,10 +43,10 @@ export function TocHeroContents({
4143
return (
4244
<li key={i}>
4345
<a
44-
className="flex items-center gap-2 whitespace-nowrap bg-neu-0 p-3 hover:bg-neu-50 lg:py-5"
46+
className="flex h-full items-center gap-2 bg-neu-0 p-2 text-left hover:bg-neu-50 max-sm:text-sm sm:gap-2 sm:p-3 lg:py-5"
4547
href={href}
4648
>
47-
<ChevronRight className="size-4 translate-x-[0.5px]" />
49+
<ChevronRight className="size-4 shrink-0 translate-x-[0.5px]" />
4850
{name}
4951
</a>
5052
</li>

0 commit comments

Comments
 (0)