File tree Expand file tree Collapse file tree 3 files changed +24
-11
lines changed
packages/gitbook/src/components/DocumentView Expand file tree Collapse file tree 3 files changed +24
-11
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ export function HashLinkButton(props: {
2929 'h-[1em]' ,
3030 'border-0' ,
3131 'opacity-0' ,
32+ 'site-background' ,
33+ 'rounded' ,
3234 'group-hover/hash:opacity-[0]' ,
3335 'group-focus/hash:opacity-[0]' ,
3436 'md:group-hover/hash:opacity-[1]' ,
Original file line number Diff line number Diff line change @@ -163,26 +163,34 @@ export function DynamicTabs(props: {
163163 'straight-corners:rounded-xs' ,
164164 'ring-1 ring-tint-subtle ring-inset' ,
165165 'flex flex-col' ,
166- 'overflow-hidden' ,
167166 className
168167 ) }
169168 >
170169 < TabItemList tabs = { tabs } activeTabId = { active ?. id ?? null } onSelect = { selectTab } />
171170 { tabs . map ( ( tab ) => (
172- < div
173- key = { tab . id }
174- role = "tabpanel"
175- id = { tab . id }
176- aria-labelledby = { getTabButtonId ( tab . id ) }
177- className = { tcls ( 'p-4' , tab . id !== active ?. id ? 'hidden' : null ) }
178- >
179- { tab . body }
180- </ div >
171+ < TabPanel key = { tab . id } tab = { tab } isActive = { tab . id === active ?. id } />
181172 ) ) }
182173 </ div >
183174 ) ;
184175}
185176
177+ const TabPanel = memo ( function TabPanel ( props : {
178+ tab : TabsItem ;
179+ isActive : boolean ;
180+ } ) {
181+ const { tab, isActive } = props ;
182+ return (
183+ < div
184+ role = "tabpanel"
185+ id = { tab . id }
186+ aria-labelledby = { getTabButtonId ( tab . id ) }
187+ className = { tcls ( 'p-4' , isActive ? null : 'hidden' ) }
188+ >
189+ { tab . body }
190+ </ div >
191+ ) ;
192+ } ) ;
193+
186194const TabItemList = memo ( function TabItemList ( props : {
187195 tabs : TabsItem [ ] ;
188196 activeTabId : string | null ;
@@ -204,6 +212,9 @@ const TabItemList = memo(function TabItemList(props: {
204212 role = "tablist"
205213 className = { tcls (
206214 'group/tabs' ,
215+ 'overflow-hidden' ,
216+ 'rounded-t-lg' ,
217+ 'straight-corners:rounded-t-xs' ,
207218 'inline-flex' ,
208219 'self-stretch' ,
209220 'after:flex-1' ,
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ export function Tabs(props: BlockProps<DocumentBlockTabs>) {
4040 // When printing, we display the tab, one after the other
4141 if ( context . mode === 'print' ) {
4242 return tabs . map ( ( tab ) => {
43- < DynamicTabs key = { tab . id } id = { id } tabs = { [ tab ] } className = { tcls ( style ) } /> ;
43+ return < DynamicTabs key = { tab . id } id = { id } tabs = { [ tab ] } className = { tcls ( style ) } /> ;
4444 } ) ;
4545 }
4646
You can’t perform that action at this time.
0 commit comments