@@ -4,6 +4,18 @@ import './index.less';
4
4
5
5
type IContentTabs = ReturnType < typeof useRouteMeta > [ 'tabs' ] ;
6
6
7
+ const TabsAction : FC < { tabs : IContentTabs } > = ( { tabs } ) => {
8
+ const tabActions = tabs
9
+ ?. map ( ( tab ) => tab . components . Action )
10
+ . filter ( ( tab ) => tab ) ;
11
+
12
+ return Boolean ( tabActions ?. length ) ? (
13
+ < div className = "dumi-default-content-tabs-actions" >
14
+ { React . createElement ( tabActions ! [ 0 ] ) }
15
+ </ div >
16
+ ) : null ;
17
+ } ;
18
+
7
19
export interface IContentTabsProps {
8
20
tabs : IContentTabs ;
9
21
tabKey : string | null ;
@@ -17,24 +29,27 @@ const ContentTabs: FC<IContentTabsProps> = ({
17
29
} ) => {
18
30
const intl = useIntl ( ) ;
19
31
20
- // TODO: tab.Extra & tab.Action render
21
-
22
32
return Boolean ( tabs ?. length ) ? (
23
33
< ul className = "dumi-default-content-tabs" >
24
- < li onClick = { ( ) => onChange ( ) } data-active = { ! key || undefined } >
25
- < button type = "button" >
26
- { intl . formatMessage ( { id : 'content.tabs.default' } ) }
27
- </ button >
28
- </ li >
29
- { tabs ! . map ( ( tab ) => (
30
- < li
31
- key = { tab . key }
32
- onClick = { ( ) => onChange ( tab ) }
33
- data-active = { key === tab . key || undefined }
34
- >
35
- < button type = "button" > { tab . meta . frontmatter . title } </ button >
34
+ < div className = "dumi-default-content-tabs-nav" >
35
+ < li onClick = { ( ) => onChange ( ) } data-active = { ! key || undefined } >
36
+ < button type = "button" >
37
+ { intl . formatMessage ( { id : 'content.tabs.default' } ) }
38
+ </ button >
36
39
</ li >
37
- ) ) }
40
+ { tabs ! . map ( ( tab ) => (
41
+ < li
42
+ key = { tab . key }
43
+ onClick = { ( ) => onChange ( tab ) }
44
+ data-active = { key === tab . key || undefined }
45
+ >
46
+ < button type = "button" > { tab . meta . frontmatter . title } </ button >
47
+ { tab . meta . frontmatter . extra }
48
+ { tab . components . Extra && React . createElement ( tab . components . Extra ) }
49
+ </ li >
50
+ ) ) }
51
+ </ div >
52
+ < TabsAction tabs = { tabs } />
38
53
</ ul >
39
54
) : null ;
40
55
} ;
0 commit comments