@@ -4,17 +4,18 @@ import styles from "./styles.module.css";
44
55class Description extends React . Component {
66 render ( ) {
7- const item = this . props . for || "Whoops" ;
8- const placeholderTitle = `${ item } : There's nothing here yet :(` ;
9- const fallback = < Placeholder title = { placeholderTitle } /> ;
7+ const fallback = (
8+ < >
9+ < div className = { styles . descriptionBox } > </ div >
10+ </ >
11+ ) ;
1012
11- const children = this . props . childre ;
13+ const children = this . props . children ;
1214 if ( ! this . props . children ) return fallback ;
13- if ( this . props . children ) return fallback ;
1415
15- const hasMultipleChildren = children instanceof Array ;
16+ const hasMultipleChildren =
17+ children instanceof Array && children . length > 0 ;
1618 const content = hasMultipleChildren ? children : [ children ] ;
17-
1819 const description = (
1920 < >
2021 < div className = { styles . descriptionBox } > { content } </ div >
@@ -25,9 +26,28 @@ class Description extends React.Component {
2526}
2627
2728class Function extends React . Component {
29+ mdxTypeToPlaceholderComponent ( mdxType ) {
30+ const placeholdersByType = {
31+ Description : < Description for = { mdxType } /> ,
32+ Parameters : < Description for = { mdxType } /> ,
33+ Returns : < Description for = { mdxType } /> ,
34+ Structures : < Description for = { mdxType } /> ,
35+ } ;
36+ return placeholdersByType [ mdxType ] ;
37+ }
38+ findFirstChildByType ( mdxType ) {
39+ const fallback = this . mdxTypeToPlaceholderComponent ( mdxType ) ;
40+ const children =
41+ this . props . children instanceof Array ? this . props . children : [ ] ;
42+ if ( ! children || children . length === 0 ) return fallback ;
43+ return children . find ( ( child ) => child . props . mdxType == mdxType ) || fallback ;
44+ }
2845 render ( ) {
2946 const since = this . props . since ;
30- const children = this . props . children ;
47+ const description = this . findFirstChildByType ( "Description" ) ;
48+ const parameters = this . findFirstChildByType ( "Parameters" ) ;
49+ const returnValues = this . findFirstChildByType ( "Returns" ) ;
50+ const structs = this . findFirstChildByType ( "Structures" ) ;
3151
3252 const isRunningInDevelopmentMode = process . env . NODE_ENV !== "production" ;
3353 if ( isRunningInDevelopmentMode ) {
@@ -57,12 +77,26 @@ class Function extends React.Component {
5777 return (
5878 < >
5979 { sinceBlock }
60- < div className = { styles . function } > { children } </ div >
80+ < div className = { styles . flexColumn } >
81+ < div className = { styles . flexRow } > { description } </ div >
82+ < div className = { styles . flexRow } >
83+ { parameters }
84+ { returnValues }
85+ </ div >
86+ { structs }
87+ </ div >
88+ < hr />
6189 </ >
6290 ) ;
6391 }
6492}
6593
94+ class Structures extends React . Component {
95+ render ( ) {
96+ return < > { this . props . children } </ > ;
97+ }
98+ }
99+
66100class NilableInfo extends React . Component {
67101 render ( ) {
68102 return < > ?</ > ;
@@ -417,4 +451,5 @@ export {
417451 Placeholder ,
418452 Blocking ,
419453 Description ,
454+ Structures ,
420455} ;
0 commit comments