@@ -7,15 +7,21 @@ import { tcls } from '@/lib/tailwind';
7
7
8
8
import { Button , Link } from '../primitives' ;
9
9
10
- export function SiteSectionTabs ( props : { sections : SiteSection [ ] ; section : SiteSection ; } ) {
10
+ export function SiteSectionTabs ( props : { sections : SiteSection [ ] ; section : SiteSection } ) {
11
11
const { sections, section : currentSection } = props ;
12
12
13
- const tabs = sections . map ( ( section ) => ( { id : section . id , label : section . title , path : section . urls . published ?? '' } ) ) ;
13
+ const tabs = sections . map ( ( section ) => ( {
14
+ id : section . id ,
15
+ label : section . title ,
16
+ path : section . urls . published ?? '' ,
17
+ } ) ) ;
14
18
15
19
const currentTabRef = React . useRef < HTMLAnchorElement > ( null ) ;
16
20
const navRef = React . useRef < HTMLDivElement > ( null ) ;
17
21
18
- const [ currentIndex , setCurrentIndex ] = React . useState ( sections . findIndex ( section => section . id === currentSection ?. id ) || 0 ) ;
22
+ const [ currentIndex , setCurrentIndex ] = React . useState (
23
+ sections . findIndex ( ( section ) => section . id === currentSection ?. id ) || 0 ,
24
+ ) ;
19
25
const [ tabDimensions , setTabDimensions ] = React . useState < {
20
26
left : number ;
21
27
width : number ;
@@ -34,7 +40,7 @@ export function SiteSectionTabs(props: { sections: SiteSection[]; section: SiteS
34
40
if ( currentTabRef . current && navRef . current ) {
35
41
const rect = currentTabRef . current . getBoundingClientRect ( ) ;
36
42
const navRect = navRef . current . getBoundingClientRect ( ) ;
37
- setTabDimensions ( { left : rect . left - navRect . left , width : rect . width } ) ;
43
+ setTabDimensions ( { left : rect . left - navRect . left , width : rect . width } ) ;
38
44
}
39
45
}
40
46
window . addEventListener ( 'resize' , onResize ) ;
@@ -43,7 +49,7 @@ export function SiteSectionTabs(props: { sections: SiteSection[]; section: SiteS
43
49
44
50
const scale = ( tabDimensions ?. width ?? 0 ) * 0.01 ;
45
51
const startPos = `${ tabDimensions ?. left ?? 0 } px` ;
46
-
52
+
47
53
const hasMoreSections = false ; /** TODO: determine whether we need to show the more button */
48
54
49
55
return tabs . length > 0 ? (
@@ -57,7 +63,7 @@ export function SiteSectionTabs(props: { sections: SiteSection[]; section: SiteS
57
63
} as React . CSSProperties
58
64
}
59
65
>
60
- < div
66
+ < div
61
67
className = { tcls (
62
68
'relative flex gap-2' ,
63
69
/* add a pseudo element for active tab indicator */
@@ -78,7 +84,7 @@ export function SiteSectionTabs(props: { sections: SiteSection[]; section: SiteS
78
84
/>
79
85
) ) }
80
86
</ div >
81
- { hasMoreSections ? < MoreSectionsButton /> : null }
87
+ { hasMoreSections ? < MoreSectionsButton /> : null }
82
88
</ nav >
83
89
) : null ;
84
90
}
@@ -95,7 +101,13 @@ const Tab = React.forwardRef<
95
101
! active && 'hover:bg-dark/1 dark:hover:bg-light/2 transition-colors' ,
96
102
) }
97
103
>
98
- < Link ref = { ref } onClick = { onClick } className = { tcls ( 'inline-flex w-full truncate' ) } role = "tab" href = { href } >
104
+ < Link
105
+ ref = { ref }
106
+ onClick = { onClick }
107
+ className = { tcls ( 'inline-flex w-full truncate' ) }
108
+ role = "tab"
109
+ href = { href }
110
+ >
99
111
{ label }
100
112
</ Link >
101
113
</ div >
0 commit comments