1
1
import React from 'react' ;
2
- import { GithubOutlined } from '@ant-design/icons' ;
2
+ import { EditOutlined , GithubOutlined } from '@ant-design/icons' ;
3
3
import { Descriptions , theme , Tooltip , Typography , type GetProp } from 'antd' ;
4
4
import { createStyles , css } from 'antd-style' ;
5
5
import kebabCase from 'lodash/kebabCase' ;
@@ -13,15 +13,21 @@ const locales = {
13
13
copy : '复制' ,
14
14
copied : '已复制' ,
15
15
source : '源码' ,
16
+ docs : '文档' ,
17
+ edit : '编辑此页' ,
16
18
} ,
17
19
en : {
18
20
import : 'Import' ,
19
21
copy : 'Copy' ,
20
22
copied : 'Copied' ,
21
23
source : 'Source' ,
24
+ docs : 'Docs' ,
25
+ edit : 'Edit this page' ,
22
26
} ,
23
27
} ;
24
28
29
+ const branchUrl = 'https://github.com/ant-design/ant-design/edit/master/' ;
30
+
25
31
const useStyle = createStyles ( ( { token } ) => ( {
26
32
code : css `
27
33
cursor : pointer;
@@ -32,9 +38,16 @@ const useStyle = createStyles(({ token }) => ({
32
38
border-radius : 4px ;
33
39
padding-inline : ${ token . paddingXS } px;
34
40
transition : all ${ token . motionDurationSlow } !important ;
41
+ font-family : ${ token . codeFamily } ;
42
+ color : ${ token . colorTextSecondary } !important ;
43
+
35
44
& : hover {
36
45
background : ${ token . controlItemBgHover } ;
37
46
}
47
+
48
+ a& : hover {
49
+ text-decoration : underline !important ;
50
+ }
38
51
` ,
39
52
import : css `
40
53
color : ${ token . magenta8 } ;
@@ -56,10 +69,11 @@ const useStyle = createStyles(({ token }) => ({
56
69
export interface ComponentMetaProps {
57
70
component : string ;
58
71
source : string | true ;
72
+ filename ?: string ;
59
73
}
60
74
61
75
const ComponentMeta : React . FC < ComponentMetaProps > = ( props ) => {
62
- const { component, source } = props ;
76
+ const { component, source, filename } = props ;
63
77
const { token } = theme . useToken ( ) ;
64
78
const [ locale ] = useLocale ( locales ) ;
65
79
@@ -118,7 +132,7 @@ const ComponentMeta: React.FC<ComponentMetaProps> = (props) => {
118
132
colon = { false }
119
133
column = { 1 }
120
134
style = { { marginTop : token . margin } }
121
- labelStyle = { { paddingInlineEnd : token . padding } }
135
+ labelStyle = { { paddingInlineEnd : token . padding , width : 54 } }
122
136
items = {
123
137
[
124
138
{
@@ -143,7 +157,21 @@ const ComponentMeta: React.FC<ComponentMetaProps> = (props) => {
143
157
label : locale . source ,
144
158
children : (
145
159
< Typography . Link className = { styles . code } href = { filledSource } target = "_blank" >
146
- < GithubOutlined /> { abbrSource }
160
+ < GithubOutlined style = { { marginInlineEnd : 4 } } />
161
+ < span > { abbrSource } </ span >
162
+ </ Typography . Link >
163
+ ) ,
164
+ } ,
165
+ filename && {
166
+ label : locale . docs ,
167
+ children : (
168
+ < Typography . Link
169
+ className = { styles . code }
170
+ href = { `${ branchUrl } ${ filename } ` }
171
+ target = "_blank"
172
+ >
173
+ < EditOutlined style = { { marginInlineEnd : 4 } } />
174
+ < span > { locale . edit } </ span >
147
175
</ Typography . Link >
148
176
) ,
149
177
} ,
0 commit comments