Skip to content

Commit b1357c6

Browse files
SutuSebastianSebastian Sutu
and
Sebastian Sutu
authored
fix: CodePreview - show explicit false props (themesberg#985)
fix: code preview - show explicit false props; removing `sortProps` since it defaults to `true` Co-authored-by: Sebastian Sutu <[email protected]>
1 parent 10b54e3 commit b1357c6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/components/code-preview.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Tooltip } from '~/src';
1414
const reactElementToJSXStringOptions: Options = {
1515
filterProps: ['key', 'ref'],
1616
showFunctions: true,
17-
sortProps: true,
17+
useBooleanShorthandSyntax: false,
1818
};
1919

2020
interface CodePreviewProps extends PropsWithChildren, ComponentProps<'div'> {
@@ -62,6 +62,7 @@ export const CodePreview: FC<CodePreviewProps> = ({
6262
code = deleteJSXSpaces(code);
6363
code = deleteSVGs(code);
6464
code = replaceWebpackImportsOnFunctions(code);
65+
code = explicitTruthyPropsToShorthandSyntax(code);
6566
code = `'use client';
6667
6768
import { ${importFlowbiteReact ?? firstComponentDisplayName(code)} } from 'flowbite-react';
@@ -231,3 +232,7 @@ const slugToUpperCamelCase = (str: string) => {
231232
.replaceAll(/\b[a-z]/g, (letter) => letter.toUpperCase())
232233
.replaceAll(/\s/g, '');
233234
};
235+
236+
const explicitTruthyPropsToShorthandSyntax = (str: string) => {
237+
return str.replaceAll(/={true}/g, '');
238+
};

0 commit comments

Comments
 (0)