Skip to content

Commit 3d82257

Browse files
committed
Refactor SectionIcon
1 parent 46a2608 commit 3d82257

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

packages/gitbook/src/components/SiteSectionTabs/SectionIcon.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ import { type ClassValue, tcls } from '@/lib/tailwind';
66
/**
77
* Icon shown beside a section in the site section tabs.
88
*/
9-
export function SectionIcon(props: { section: SiteSection; className?: ClassValue }) {
10-
const { section, className } = props;
9+
export function SectionIcon(props: { icon: IconName; isActive: boolean }) {
10+
const { icon, isActive } = props;
1111

12-
return section.icon ? (
13-
<Icon icon={section.icon as IconName} className={tcls('size-[1em]', className)} />
14-
) : null;
12+
return (
13+
<Icon
14+
icon={icon}
15+
className={tcls(
16+
'size-[1em] text-inherit opacity-8',
17+
isActive && 'text-inherit opacity-10',
18+
)}
19+
/>
20+
);
1521
}

packages/gitbook/src/components/SiteSectionTabs/SiteSectionTabs.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import type { SiteSection } from '@gitbook/api';
4+
import type { IconName } from '@gitbook/icons';
45
import React from 'react';
56

67
import { tcls } from '@/lib/tailwind';
@@ -94,13 +95,7 @@ export function SiteSectionTabs(props: {
9495
ref={isActive ? currentTabRef : null}
9596
icon={
9697
icon ? (
97-
<SectionIcon
98-
className={tcls(
99-
'text-inherit opacity-8',
100-
isActive && 'text-inherit opacity-10',
101-
)}
102-
section={section}
103-
/>
98+
<SectionIcon isActive={isActive} icon={icon as IconName} />
10499
) : null
105100
}
106101
/>

0 commit comments

Comments
 (0)