MCPcopy Index your code
hub / github.com/bernaferrari/FigmaToCode / generateSvelteComponent

Function generateSvelteComponent

packages/backend/src/html/htmlMain.ts:291–309  ·  view source on GitHub ↗
(html: string)

Source from the content-addressed store, hash-verified

289
290// Generate Svelte component from the collected styles and HTML
291function generateSvelteComponent(html: string): string {
292 // Build CSS classes similar to styled-components but for Svelte
293 const cssRules: string[] = [];
294
295 Object.entries(cssCollection).forEach(([className, { styles }]) => {
296 if (!styles.length) return;
297
298 // Always use class selector to avoid conflicts
299 cssRules.push(
300 `.${className} {\n ${styles.join(";\n ")}${styles.length ? ";" : ""}\n}`,
301 );
302 });
303
304 return `${html}
305
306<style>
307${cssRules.join("\n\n")}
308</style>`;
309}
310
311export const htmlMain = async (
312 sceneNode: Array<SceneNode>,

Callers 1

generateComponentCodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected