Skip to content

Commit 0b15d0d

Browse files
authored
Merge pull request #15968 from github/repo-sync
repo sync
2 parents 574bc6f + 9b39fcb commit 0b15d0d

9 files changed

+207
-162
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Fragment } from 'react'
2+
import type { BodyParameter } from './types'
3+
import { useTranslation } from 'components/hooks/useTranslation'
4+
import { ChildBodyParametersRows } from './ChildBodyParametersRows'
5+
6+
type Props = {
7+
slug: string
8+
bodyParameters: BodyParameter[]
9+
}
10+
11+
export function BodyParameterRows({ slug, bodyParameters }: Props) {
12+
const { t } = useTranslation('products')
13+
14+
return (
15+
<>
16+
{bodyParameters.map((bodyParam) => {
17+
return (
18+
<Fragment key={bodyParam.name + bodyParam.description}>
19+
<tr>
20+
<td>
21+
<code>{bodyParam.name}</code>
22+
</td>
23+
<td>{bodyParam.type}</td>
24+
<td>{bodyParam.in}</td>
25+
<td>
26+
<div dangerouslySetInnerHTML={{ __html: bodyParam.description }} />
27+
{bodyParam.default && (
28+
<p>
29+
{t('rest.reference.default')}: <code>{bodyParam.default}</code>
30+
</p>
31+
)}
32+
</td>
33+
</tr>
34+
{bodyParam.childParamsGroups && bodyParam.childParamsGroups.length > 0 && (
35+
<ChildBodyParametersRows
36+
slug={slug}
37+
childParamsGroups={bodyParam.childParamsGroups}
38+
/>
39+
)}
40+
</Fragment>
41+
)
42+
})}
43+
</>
44+
)
45+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { useTranslation } from 'components/hooks/useTranslation'
2+
import type { ChildParamsGroup } from './types'
3+
4+
type Props = {
5+
slug: string
6+
childParamsGroups: ChildParamsGroup[]
7+
}
8+
9+
export function ChildBodyParametersRows({ slug, childParamsGroups }: Props) {
10+
const { t } = useTranslation('products')
11+
12+
return (
13+
<tr className="border-none">
14+
<td colSpan={4} className="has-nested-table">
15+
{childParamsGroups?.map((childParamGroup) => {
16+
return (
17+
<details key={childParamGroup.id}>
18+
<summary
19+
role="button"
20+
aria-expanded="false"
21+
className="keyboard-focus color-fg-muted"
22+
>
23+
<span className="d-inline-block mb-3" id={`${slug}-${childParamGroup.id}`}>
24+
Properties of the
25+
<code>{childParamGroup.parentName}</code>
26+
{childParamGroup.parentType}
27+
</span>
28+
</summary>
29+
<table
30+
id={`${childParamGroup.parentName}-object`}
31+
className="ml-4 mb-4 mt-2 color-bg-subtle"
32+
>
33+
<thead>
34+
<tr>
35+
<th>
36+
{t('rest.reference.name')} ({t('rest.reference.type')})
37+
</th>
38+
<th>{t('rest.reference.description')}</th>
39+
</tr>
40+
</thead>
41+
<tbody>
42+
{childParamGroup.params.map((childParam) => {
43+
return (
44+
<tr key={`${childParam.name}-${childParam.description}`}>
45+
<td className="color-bg-subtle">
46+
<code>{childParam.name}</code> ({childParam.type})
47+
</td>
48+
<td className="color-bg-subtle">
49+
<div dangerouslySetInnerHTML={{ __html: childParam.description }} />
50+
</td>
51+
</tr>
52+
)
53+
})}
54+
</tbody>
55+
</table>
56+
</details>
57+
)
58+
})}
59+
</td>
60+
</tr>
61+
)
62+
}

components/rest/CodeBlock.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export function CodeBlock({ verb, codeBlock, setHTML = false }: Props) {
1515
dangerouslySetInnerHTML={{ __html: codeBlock }}
1616
/>
1717
) : (
18-
<pre className={cx(styles.methodCodeBlock, 'mb-3 rounded-1 border')}>
18+
<pre className={cx(styles.methodCodeBlock, 'rounded-1 border')}>
1919
<code>
2020
{verb && (
21-
<span className="color-bg-accent-emphasis color-fg-on-emphasis rounded-1 px-2 py-1 text-uppercase">
21+
<span className="color-bg-accent-emphasis color-fg-on-emphasis rounded-1 text-uppercase">
2222
{verb}
2323
</span>
2424
)}{' '}

components/rest/ParameterRows.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Parameter } from './types'
2+
import { useTranslation } from 'components/hooks/useTranslation'
3+
4+
type Props = {
5+
parameters: Parameter[]
6+
}
7+
8+
export function ParameterRows({ parameters }: Props) {
9+
const { t } = useTranslation('products')
10+
11+
return (
12+
<>
13+
{parameters.map((param) => (
14+
<tr key={`${param.name}-${param.descriptionHTML}`}>
15+
<td>
16+
<code>{param.name}</code>
17+
</td>
18+
<td>{param.schema.type}</td>
19+
<td>{param.in}</td>
20+
<td>
21+
{param.descriptionHTML && (
22+
<div dangerouslySetInnerHTML={{ __html: param.descriptionHTML }} />
23+
)}
24+
{param.schema.default && (
25+
<p>
26+
{t('rest.reference.default')}: <code>{param.schema.default}</code>
27+
</p>
28+
)}
29+
</td>
30+
</tr>
31+
))}
32+
</>
33+
)
34+
}

components/rest/PreviewsRow.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { xGitHub } from './types'
2+
import { useTranslation } from 'components/hooks/useTranslation'
3+
4+
type Props = {
5+
slug: string
6+
hasRequiredPreviews: boolean
7+
xGitHub: xGitHub
8+
}
9+
10+
export function PreviewsRow({ slug, hasRequiredPreviews, xGitHub }: Props) {
11+
const { t } = useTranslation('products')
12+
13+
return (
14+
<tr>
15+
<td>
16+
<code>accept</code>
17+
</td>
18+
<td>string</td>
19+
<td>header</td>
20+
<td>
21+
{hasRequiredPreviews ? (
22+
<p>{t('rest.reference.preview_notice_to_change')}.</p>
23+
) : (
24+
<p className="m-0">
25+
Setting to
26+
<code>application/vnd.github.v3+json</code> is recommended.
27+
{xGitHub.previews && (
28+
<a href={`#${slug}-preview-notices`} className="d-inline">
29+
{xGitHub.previews.length > 1
30+
? ` ${t('rest.reference.see_preview_notices')}`
31+
: ` ${t('rest.reference.see_preview_notice')}`}
32+
</a>
33+
)}
34+
</p>
35+
)}
36+
</td>
37+
</tr>
38+
)
39+
}

components/rest/RestCodeSamples.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,23 @@ export function RestCodeSamples({ slug, xCodeSamples }: Props) {
1212

1313
return (
1414
<>
15-
<h4 className="pt-3 my-4" id={`${slug}--code-samples`}>
15+
<h4 id={`${slug}--code-samples`}>
1616
<a href={`#${slug}--code-samples`}>{`${t('rest.reference.code_samples')}`}</a>
1717
</h4>
18-
{xCodeSamples.map((sample: xCodeSample, index: number) => {
18+
{xCodeSamples.map((sample, index) => {
1919
const sampleElements: JSX.Element[] = []
2020
if (sample.lang !== 'Ruby') {
2121
sampleElements.push(
2222
sample.lang === 'JavaScript' ? (
23-
<h5 key={`${sample.lang}-${index}`} className="pt-3">
23+
<h5 key={`${sample.lang}-${index}`}>
2424
{sample.lang} (
2525
<a className="text-underline" href="https://github.com/octokit/core.js#readme">
2626
@octokit/core.js
2727
</a>
2828
)
2929
</h5>
3030
) : (
31-
<h5 key={`${sample.lang}-${index}`} className="pt-3">
32-
{sample.lang}
33-
</h5>
31+
<h5 key={`${sample.lang}-${index}`}>{sample.lang}</h5>
3432
)
3533
)
3634
sampleElements.push(

components/rest/RestParameterTable.module.scss

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
.parameterTable {
2-
display: table;
3-
border-collapse: collapse;
4-
position: relative;
5-
width: 100%;
6-
line-height: 1.5;
7-
table-layout: auto;
2+
table-layout: fixed !important;
83

94
thead {
105
tr {
@@ -25,6 +20,7 @@
2520
padding: 0.75rem 0.5rem !important;
2621
border: 0 !important;
2722
vertical-align: top;
23+
width: 100%;
2824
}
2925

3026
tbody {

0 commit comments

Comments
 (0)