Skip to content

Commit 1c85bcc

Browse files
docs: Fix formatting of prop descriptions with multiple paragraphs (#9574)
* docs: Fix formatting of prop descriptions with multiple paragraphs * lint --------- Co-authored-by: Robert Snow <rsnow@adobe.com>
1 parent c45221b commit 1c85bcc

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

packages/dev/s2-docs/src/PropTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function Rows({props, showDefault, showRequired}: {props: TInterface['properties
196196
}
197197
</TableRow>
198198
{prop.description && <TableRow>
199-
<TableCell colSpan={3}>{renderHTMLfromMarkdown(prop.description, {forceInline: true})}</TableCell>
199+
<TableCell colSpan={3}>{renderHTMLfromMarkdown(prop.description, {forceInline: false, forceBlock: true})}</TableCell>
200200
</TableRow>}
201201
</React.Fragment>
202202
));

packages/dev/s2-docs/src/types.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,16 @@ export function TypeLink({type}: {type: Extract<TType, {id: string, name: string
479479
return res;
480480
}
481481

482+
const mdComponents = {
483+
a: {component: SpectrumLink},
484+
code: {component: Code},
485+
p: {component: (props) => <p {...props} className={style({marginTop: {':first-child': 0}, marginBottom: {':last-child': 0}})} />},
486+
ul: {component: (props) => <ul {...props} className={style({paddingStart: 12, marginTop: {':first-child': 0}, marginBottom: {':last-child': 0}})} />}
487+
};
488+
482489
export function renderHTMLfromMarkdown(description: string | null | undefined, opts: object): ReactNode {
483490
if (description) {
484-
const options = {forceInline: true, overrides: {a: {component: SpectrumLink}, code: {component: Code}}, disableParsingRawHTML: true, ...opts};
491+
const options = {forceInline: true, overrides: mdComponents, disableParsingRawHTML: true, ...opts};
485492
return <Markdown options={options}>{description}</Markdown>;
486493
}
487494
return null;

packages/react-aria-components/src/utils.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,10 @@ export interface DOMRenderProps<E extends keyof React.JSX.IntrinsicElements, T>
274274
* such as router links, animation libraries, and pre-styled components.
275275
*
276276
* Requirements:
277-
* - You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`).
278-
* - Only a single root DOM element can be rendered (no fragments).
279-
* - You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
277+
*
278+
* * You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`).
279+
* * Only a single root DOM element can be rendered (no fragments).
280+
* * You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
280281
*/
281282
render?: DOMRenderFunction<E, T>
282283
}
@@ -294,9 +295,10 @@ export interface PossibleLinkDOMRenderProps<Fallback extends keyof React.JSX.Int
294295
* Note: You can check if `'href' in props` in order to tell whether to render an `<a>` element.
295296
*
296297
* Requirements:
297-
* - You must render the expected element type (e.g. if `<a>` is expected, you cannot render a `<button>`).
298-
* - Only a single root DOM element can be rendered (no fragments).
299-
* - You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
298+
*
299+
* * You must render the expected element type (e.g. if `<a>` is expected, you cannot render a `<button>`).
300+
* * Only a single root DOM element can be rendered (no fragments).
301+
* * You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
300302
*/
301303
render?: (props: DetailedHTMLProps<LinkWithRequiredHref, HTMLAnchorElement> | React.JSX.IntrinsicElements[Fallback], renderProps: T) => ReactElement
302304
}

0 commit comments

Comments
 (0)