Skip to content

Commit 4837abd

Browse files
committed
fix one small bug in StatePropsPanel (class to className); fix eventhandler declaration do not show up in code preview for nested elements
1 parent 4b57cd4 commit 4837abd

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

app/src/components/StateManagement/CreateTab/components/StatePropsPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ const StatePropsPanel = ({ isThemeLight, data}): JSX.Element => {
267267
</div>
268268

269269
<div style={{display: 'flex', flexDirection: 'column', width: `${40}px`, color: 'black', justifyContent: 'center'}}>
270-
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" fill="currentColor" class="bi bi-arrow-right-circle-fill" viewBox="0 0 16 16">
270+
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" fill="currentColor" className="bi bi-arrow-right-circle-fill" viewBox="0 0 16 16">
271271
<path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0zM4.5 7.5a.5.5 0 0 0 0 1h5.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3a.5.5 0 0 0 0-.708l-3-3a.5.5 0 1 0-.708.708L10.293 7.5H4.5z"/>
272272
</svg>
273273
</div>

app/src/helperFunctions/generateCode.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,16 @@ const generateUnformattedCode = (
392392
};
393393

394394
// ------------------------------------------- added code below -------------------------------------------
395-
const createEventHandler = () => {
395+
const createEventHandler = (children) => {
396396
let importStr = '';
397-
enrichedChildren.map((child) => {
397+
children.map((child) => {
398398
if (child.type === 'HTML Element') {
399399
if (child.events) {
400400
for (const [event, funcName] of Object.entries(child.events)) {
401401
importStr += `\tconst ${funcName} = () => {};\n`;
402402
}
403403
}
404+
if (child.children.length !== 0) importStr += createEventHandler(child.children);
404405
}
405406
});
406407

@@ -415,7 +416,7 @@ const generateUnformattedCode = (
415416
// below is the return statement of the codepreview
416417
generatedCode += `const ${currComponent.name} = (props) => {\n`;
417418
generatedCode += writeStateProps(currComponent.useStateCodes) ? `\t${writeStateProps(currComponent.useStateCodes)}\n` : '';
418-
generatedCode += createEventHandler() ? `${createEventHandler()}\n` : '';
419+
generatedCode += createEventHandler(enrichedChildren) ? `${createEventHandler(enrichedChildren)}\n` : '';
419420
generatedCode += `
420421
return(
421422
<>

0 commit comments

Comments
 (0)