Skip to content

Commit

Permalink
Merge pull request #32 from idesigncode/components
Browse files Browse the repository at this point in the history
Components: Corrected use of React fragment for JSX elements
  • Loading branch information
idesigncode authored Jul 29, 2023
2 parents 8e08864 + 5b8aa0c commit eeeabfb
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 23 deletions.
Binary file modified __snapshots__/components-propstable--all-prop-types.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 74 additions & 20 deletions __snapshots__/components-propstable.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,6 @@ exports[`Components/PropsTable All Prop Types test 1`] = `
<span class="token tag punctuation">
&lt;
</span>
<span class="token tag punctuation">
&gt;
</span>
<span class="token plain-text">
</span>
<span class="token plain-text">
</span>
<span class="token tag punctuation">
&lt;
</span>
<span class="token tag class-name">
Input
</span>
Expand All @@ -134,16 +124,6 @@ exports[`Components/PropsTable All Prop Types test 1`] = `
<span class="token tag punctuation">
/&gt;
</span>
<span class="token plain-text">
</span>
<span class="token plain-text">
</span>
<span class="token tag punctuation">
&lt;/
</span>
<span class="token tag punctuation">
&gt;
</span>
<span class="token punctuation">
,
</span>
Expand Down Expand Up @@ -875,6 +855,80 @@ exports[`Components/PropsTable All Prop Types test 1`] = `
<input style="display: none;">
`;

exports[`Components/PropsTable Array Of Children test 1`] = `
<div class="propsTable sb-unstyled">
<table aria-hidden="false">
<thead>
<tr>
<th>
Prop
</th>
<th>
Type
</th>
<th>
Value
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
children
<span class="requiredProp">
*
</span>
</td>
<td>
<code>
node
</code>
</td>
<td>
<div class="Source sb-unstyled ">
<pre class="prismjs">
<code class="language-jsx"
style="white-space: pre;"
>
<span class="token tag punctuation">
&lt;
</span>
<span class="token tag class-name">
Component
</span>
<span class="token tag">
</span>
<span class="token tag punctuation">
/&gt;
</span>
<span class>
</span>
<span class>
</span>
<span class="token tag punctuation">
&lt;
</span>
<span class="token tag">
div
</span>
<span class="token tag">
</span>
<span class="token tag punctuation">
/&gt;
</span>
</code>
</pre>
<button>
Copy
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
`;

exports[`Components/PropsTable Automatic Props Source test 1`] = `
<div class="Source sb-unstyled ">
<pre class="prismjs">
Expand Down
6 changes: 3 additions & 3 deletions src/formatValueToString.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ const formatValueToString = (code, type) => {

// JSX elements
return addRemoveOuterQuotes(
`<>${
`${
value instanceof Array
? addRemoveOuterQuotes(value.map(formatNodeToJsxString).join(''))
? `<>${value.map(formatNodeToJsxString).join('')}</>`
: formatNodeToJsxString(value)
}</>`,
}`,
);
}

Expand Down
12 changes: 12 additions & 0 deletions stories/PropsTable.stories.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@ export const AllPropTypes = {
render: ComponentExample,
};

export const ArrayOfChildren = {
args: {
children: (
<PropsTable>
<Component />
<div />
</PropsTable>
),
hideChildren: true,
},
};

export const RefValueUpdates = {
render: () => {
const [value, setValue] = React.useState('');
Expand Down

0 comments on commit eeeabfb

Please sign in to comment.