Update SVG to React converter output format#35
Conversation
kzuraw
commented
Jan 14, 2026
- Change output to use TypeScript types with separate imports
- Use arrow function with forwardRef pattern
- Format SVG attributes on separate lines with ref and props spread
- Change layout to stack textareas vertically
- Change output to use TypeScript types with separate imports - Use arrow function with forwardRef pattern - Format SVG attributes on separate lines with ref and props spread - Change layout to stack textareas vertically
Pull Request Review: SVG to React Converter Output FormatI've reviewed PR #35 and have the following feedback: ✅ Positive Changes
🐛 Critical BugLine 304-309 ( // For other elements, put attributes inline
attrs.forEach(attr => {
result += `\n${indent} ${attr.name}="${attr.value}"`;
});
if (attrs.length > 0) {
result += `\n${indent}/>`;
return result;
}Issues:
Example broken output: <path
d="M10 10"
fill="red"
/>Suggested fix: // For other elements
if (attrs.length === 0) {
result += ' />';
return result;
} else if (attrs.length <= 2 && children.length === 0) {
// Put few attributes inline for simple elements
attrs.forEach(attr => {
result += ` ${attr.name}="${attr.value}"`;
});
result += ' />';
return result;
} else {
// Many attributes on separate lines
attrs.forEach(attr => {
result += `\n${indent} ${attr.name}="${attr.value}"`;
});
result += children.length > 0 ? `\n${indent}>` : `\n${indent}/>`;
}
|
- Put {...props} before ref={ref} to maintain ref precedence
- Use inline attributes for elements with 2 or fewer attributes
- Put many attributes on separate lines for readability
- Properly handle elements with and without children
Pull Request Review: Update SVG to React converter output formatOverviewThis PR modernizes the SVG to React converter with TypeScript-focused output and improved formatting. Overall, the changes are well-implemented with good attention to detail. ✅ Strengths
🐛 Potential Issues
💡 Code Quality Suggestions
🔒 Security✅ No security concerns identified. The code properly:
⚡ Performance✅ Performance is appropriate for client-side tool:
🧪 Test Coverageℹ️ This is a standalone HTML tool with no automated tests (per project conventions). Manual testing recommended for:
📝 Minor Suggestions
SummaryRecommendation: Approve with minor suggestions The PR delivers solid improvements to the tool's output format. The only notable issue is the missing Great work modernizing the component output! 🚀 |