@@ -16,6 +16,7 @@ type Props = {
16
16
bodyParameters : Array < BodyParameter >
17
17
bodyParamExpandCallback ?: KeyboardEventHandler < HTMLButtonElement > | undefined
18
18
clickedBodyParameterName ?: string | undefined
19
+ variant ?: 'rest' | 'webhooks'
19
20
}
20
21
21
22
export function ParameterTable ( {
@@ -27,6 +28,7 @@ export function ParameterTable({
27
28
bodyParameters,
28
29
bodyParamExpandCallback = undefined ,
29
30
clickedBodyParameterName = '' ,
31
+ variant = 'rest' ,
30
32
} : Props ) {
31
33
const { t } = useTranslation ( [ 'parameter_table' , 'products' ] )
32
34
const queryParams = parameters . filter ( ( param ) => param . in === 'query' )
@@ -40,28 +42,21 @@ export function ParameterTable({
40
42
</ h3 >
41
43
) }
42
44
43
- < table
44
- className = { cx ( styles . parameterTable ) }
45
- summary = "Column one has the type of parameter and the other columns show the name, type, and description of the parameters"
46
- >
47
- < thead >
48
- < tr >
49
- < th
50
- id = "header"
51
- scope = "col"
52
- className = { cx ( headers . length === 0 && 'visually-hidden' , 'text-bold pl-0' ) }
53
- >
54
- { t ( 'headers' ) }
55
- </ th >
56
- </ tr >
57
- < tr className = "visually-hidden" >
58
- < th scope = "col" > { `${ t ( 'name' ) } , ${ t ( 'type' ) } , ${ t ( 'description' ) } ` } </ th >
59
- </ tr >
60
- </ thead >
61
-
62
- < tbody >
63
- { headers . length > 0 && (
64
- < >
45
+ { headers . length > 0 && (
46
+ < >
47
+ { /* <h4 id="headers-table-heading">{t('headers')}</h4> */ }
48
+ < table
49
+ className = { cx ( styles . parameterTable ) }
50
+ summary = "Column one describes the parameter. The first line includes the name, type, and whether the parameter is required. The second line is a description of the parameter."
51
+ aria-labelledby = "headers-table-heading"
52
+ >
53
+ < caption className = "mt-3 mb-3 h5 float-left" > { t ( 'headers' ) } </ caption >
54
+ < thead className = "visually-hidden" >
55
+ < tr >
56
+ < th scope = "col" > { `${ t ( 'name' ) } , ${ t ( 'type' ) } , ${ t ( 'description' ) } ` } </ th >
57
+ </ tr >
58
+ </ thead >
59
+ < tbody >
65
60
{ headers . map ( ( header , index ) => (
66
61
< ParameterRow
67
62
rowParams = { header }
@@ -70,19 +65,26 @@ export function ParameterTable({
70
65
key = { `${ index } -${ header . name } ` }
71
66
/>
72
67
) ) }
73
- </ >
74
- ) }
68
+ </ tbody >
69
+ </ table >
70
+ </ >
71
+ ) }
75
72
76
- { pathParams . length > 0 && (
77
- < >
78
- < tr className = "border-top-0" >
79
- < th className = "text-bold pl-0 border-top-0" scope = "colgroup" >
80
- { t ( 'path' ) }
81
- </ th >
82
- </ tr >
83
- < tr className = "visually-hidden" >
84
- < th scope = "colgroup" > { `${ t ( 'name' ) } , ${ t ( 'type' ) } , ${ t ( 'description' ) } ` } </ th >
73
+ { pathParams . length > 0 && (
74
+ < >
75
+ { /* <h4 id="path-table-heading">{t('path')}</h4> */ }
76
+ < table
77
+ className = { cx ( styles . parameterTable ) }
78
+ summary = "Column one describes the parameter. The first line includes the name, type, and whether the parameter is required. The second line is a description of the parameter."
79
+ aria-labelledby = "path-table-heading"
80
+ >
81
+ < caption className = "mt-3 mb-3 h5 float-left" > { t ( 'path' ) } </ caption >
82
+ < thead className = "visually-hidden" >
83
+ < tr >
84
+ < th scope = "col" > { `${ t ( 'name' ) } , ${ t ( 'type' ) } , ${ t ( 'description' ) } ` } </ th >
85
85
</ tr >
86
+ </ thead >
87
+ < tbody >
86
88
{ pathParams . map ( ( param , index ) => (
87
89
< ParameterRow
88
90
rowParams = { {
@@ -97,20 +99,26 @@ export function ParameterTable({
97
99
key = { `${ index } -${ param } ` }
98
100
/>
99
101
) ) }
100
- </ >
101
- ) }
102
+ </ tbody >
103
+ </ table >
104
+ </ >
105
+ ) }
102
106
103
- { queryParams . length > 0 && (
104
- < >
105
- < tr className = "border-top-0" >
106
- < th className = "text-bold pl-0" scope = "colgroup" >
107
- { t ( 'query' ) }
108
- </ th >
109
- </ tr >
110
- < tr className = "visually-hidden" >
111
- < th scope = "colgroup" > { `${ t ( 'name' ) } , ${ t ( 'type' ) } , ${ t ( 'description' ) } ` } </ th >
107
+ { queryParams . length > 0 && (
108
+ < >
109
+ { /* <h4 id="query-table-heading">{t('query')}</h4> */ }
110
+ < table
111
+ className = { cx ( styles . parameterTable ) }
112
+ summary = "Column one describes the parameter. The first line includes the name, type, and whether the parameter is required. The second line is a description of the parameter."
113
+ aria-labelledby = "query-table-heading"
114
+ >
115
+ < caption className = "mt-3 mb-3 h5 float-left" > { t ( 'query' ) } </ caption >
116
+ < thead className = "visually-hidden" >
117
+ < tr >
118
+ < th scope = "col" > { `${ t ( 'name' ) } , ${ t ( 'type' ) } , ${ t ( 'description' ) } ` } </ th >
112
119
</ tr >
113
-
120
+ </ thead >
121
+ < tbody >
114
122
{ queryParams . map ( ( param , index ) => (
115
123
< ParameterRow
116
124
rowParams = { {
@@ -125,22 +133,28 @@ export function ParameterTable({
125
133
key = { `${ index } -${ param } ` }
126
134
/>
127
135
) ) }
128
- </ >
129
- ) }
136
+ </ tbody >
137
+ </ table >
138
+ </ >
139
+ ) }
130
140
131
- { bodyParameters . length > 0 && (
132
- < >
133
- < tr className = "border-top-0" >
134
- { /* webhooks don't have a 'Parameters' table heading text so
135
- we adjust the size of the body params heading in that case */ }
136
- < th scope = "colgroup" className = { cx ( heading ? 'text-bold' : 'h4' , 'pl-0' ) } >
137
- { t ( 'body' ) }
138
- </ th >
139
- </ tr >
140
- < tr className = "visually-hidden" >
141
- < th scope = "colgroup" > { `${ t ( 'name' ) } , ${ t ( 'type' ) } , ${ t ( 'description' ) } ` } </ th >
141
+ { bodyParameters . length > 0 && (
142
+ < >
143
+ { /* <h4 id="body-table-heading">{variant === 'rest' ? t('body') : t('webhook-body')}</h4> */ }
144
+ < table
145
+ className = { cx ( styles . parameterTable ) }
146
+ summary = "Column one describes the parameter. The first line includes the name, type, and whether the parameter is required. The second line is a description of the parameter."
147
+ aria-labelledby = "body-table-heading"
148
+ >
149
+ < caption className = "mt-3 mb-3 h5 float-left" >
150
+ { variant === 'rest' ? t ( 'body' ) : t ( 'webhook-body' ) }
151
+ </ caption >
152
+ < thead className = "visually-hidden" >
153
+ < tr >
154
+ < th scope = "col" > { `${ t ( 'name' ) } , ${ t ( 'type' ) } , ${ t ( 'description' ) } ` } </ th >
142
155
</ tr >
143
-
156
+ </ thead >
157
+ < tbody >
144
158
{ bodyParameters . map ( ( param , index ) => (
145
159
< ParameterRow
146
160
bodyParamExpandCallback = { bodyParamExpandCallback }
@@ -150,10 +164,10 @@ export function ParameterTable({
150
164
key = { `${ index } -${ param } ` }
151
165
/>
152
166
) ) }
153
- </ >
154
- ) }
155
- </ tbody >
156
- </ table >
167
+ </ tbody >
168
+ </ table >
169
+ </ >
170
+ ) }
157
171
</ >
158
172
)
159
173
}
0 commit comments