forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTable.tsx
More file actions
112 lines (106 loc) · 3.6 KB
/
Table.tsx
File metadata and controls
112 lines (106 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { useRouter } from 'next/router'
import { Link } from 'components/Link'
import { Notice } from './Notice'
import { useTranslation } from 'src/languages/components/useTranslation'
import { FieldT } from './types'
type Props = {
fields: FieldT[]
}
export function Table({ fields }: Props) {
const { locale } = useRouter()
const { t } = useTranslation('products')
const tableName = t('graphql.reference.name')
const tableDescription = t('graphql.reference.description')
return (
<table className="fields width-full table-fixed">
<thead>
<tr>
<th>{tableName}</th>
<th>{tableDescription}</th>
</tr>
</thead>
<tbody>
{fields.map((field) => (
<tr key={field.name}>
<td>
<p>
<code>{field.name}</code> (
<code>
<Link
href={field.href}
locale={locale}
aria-label={[field.name, field.type, 'type definition'].join(' ')}
>
{field.type}
</Link>
</code>
)
</p>
</td>
<td>
{field.description ? (
<span
dangerouslySetInnerHTML={{
__html: field.description,
}}
/>
) : (
'N/A'
)}
{field.defaultValue !== undefined && (
<p>
The default value is <code>{field.defaultValue.toString()}</code>.
</p>
)}
{field.preview && <Notice item={field} variant="preview" />}
{field.isDeprecated && <Notice item={field} variant="deprecation" />}
{field.arguments && (
<div className="border rounded-1 mt-3 mb-3 p-3 color-bg-subtle f5">
<p
className="pt-0 mt-0 h5"
dangerouslySetInnerHTML={{
__html: t('graphql.reference.arguments').replace(
'{{ GraphQLItemTitle }}',
field.name,
),
}}
/>
{field.arguments.map((argument, index) => (
<ul
key={`${index}-${argument.type.name}-${argument.type.href}`}
className="list-style-none pl-0"
>
<li className="border-top mt-2">
<p className="mt-2">
<code>{argument.name}</code> (
<code>
<Link href={argument.type.href} locale={locale}>
{argument.type.name}
</Link>
</code>
)
</p>
{
<span
dangerouslySetInnerHTML={{
__html: argument.description,
}}
/>
}
{argument.defaultValue !== undefined && (
<p>
The default value is <code>{argument.defaultValue.toString()}</code>.
</p>
)}
</li>
</ul>
))}
</div>
)}
</td>
</tr>
))}
</tbody>
</table>
)
}