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

Function convertNode

packages/backend/src/html/htmlMain.ts:388–428  ·  view source on GitHub ↗
(settings: HTMLSettings)

Source from the content-addressed store, hash-verified

386};
387
388const convertNode = (settings: HTMLSettings) => async (node: SceneNode) => {
389 if (settings.embedVectors && (node as any).canBeFlattened) {
390 const altNode = await renderAndAttachSVG(node);
391 if (altNode.svg) {
392 return htmlWrapSVG(altNode, settings);
393 }
394 }
395
396 switch ((node as any).type) {
397 case "RECTANGLE":
398 case "ELLIPSE":
399 return await htmlContainer(node, "", [], settings);
400 case "GROUP":
401 return await htmlGroup(node, settings);
402 case "FRAME":
403 case "COMPONENT":
404 case "INSTANCE":
405 case "COMPONENT_SET":
406 case "SLOT":
407 return await htmlFrame(node, settings);
408 case "SECTION":
409 return await htmlSection(node, settings);
410 case "TEXT":
411 return htmlText(node, settings);
412 case "LINE":
413 return htmlLine(node, settings);
414 case "VECTOR":
415 if (!settings.embedVectors && !isPreviewGlobal) {
416 addWarning("Vector is not supported");
417 }
418 return await htmlContainer(
419 { ...node, type: "RECTANGLE" } as any,
420 "",
421 [],
422 settings,
423 );
424 default:
425 addWarning(`${node.type} node is not supported`);
426 return "";
427 }
428};
429
430const htmlWrapSVG = (
431 node: AltNode<SceneNode>,

Callers 1

htmlWidgetGeneratorFunction · 0.70

Calls 9

renderAndAttachSVGFunction · 0.90
addWarningFunction · 0.90
htmlWrapSVGFunction · 0.85
htmlContainerFunction · 0.85
htmlGroupFunction · 0.85
htmlFrameFunction · 0.85
htmlSectionFunction · 0.85
htmlTextFunction · 0.85
htmlLineFunction · 0.85

Tested by

no test coverage detected