( html: string, sceneNode: Array<SceneNode>, )
| 265 | |
| 266 | // Generate React component from HTML, with optional styled-components |
| 267 | function generateReactComponent( |
| 268 | html: string, |
| 269 | sceneNode: Array<SceneNode>, |
| 270 | ): string { |
| 271 | const styledComponentsCode = generateStyledComponents(); |
| 272 | |
| 273 | const componentName = getReactComponentName(sceneNode[0]); |
| 274 | |
| 275 | const imports = [ |
| 276 | 'import React from "react";', |
| 277 | 'import styled from "styled-components";', |
| 278 | ]; |
| 279 | |
| 280 | return `${imports.join("\n")} |
| 281 | ${styledComponentsCode ? `\n${styledComponentsCode}` : ""} |
| 282 | |
| 283 | export const ${componentName} = () => { |
| 284 | return ( |
| 285 | ${indentString(html, 4)} |
| 286 | ); |
| 287 | };`; |
| 288 | } |
| 289 | |
| 290 | // Generate Svelte component from the collected styles and HTML |
| 291 | function generateSvelteComponent(html: string): string { |
no test coverage detected